Skip to content

Commit

Permalink
add unpushed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleP committed Dec 7, 2024
1 parent ee85c86 commit 9030513
Show file tree
Hide file tree
Showing 53 changed files with 1,063 additions and 336 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ source/modules/font/GenericShaper.cpp
source/modules/font/wrap_Font.cpp
source/modules/font/wrap_Rasterizer.cpp
source/modules/font/wrap_GlyphData.cpp
source/modules/graphics/Buffer.cpp
# source/modules/graphics/Buffer.cpp
source/modules/graphics/DrawCommand.cpp
source/modules/graphics/Graphics.cpp
source/modules/graphics/FontBase.cpp
source/modules/graphics/Mesh.cpp
Expand Down
18 changes: 6 additions & 12 deletions include/common/Exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,14 @@ namespace love

#if __DEBUG__
#include <cstdio>
#define __FILENAME__ (__FILE__ + (sizeof(__FILE__) - 1) - sizeof(basename(__FILE__)))

// Macro to log to both stdout and a debug.log file
#define LOG(format, ...) \
do \
{ \
std::FILE* outFile = std::fopen("debug.log", "a"); \
static const char* data = "%s %s:%d: " format "\n"; \
\
if (outFile) \
{ \
std::fprintf(outFile, data, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
std::fclose(outFile); \
} \
std::printf(data, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
#define LOG(format, ...) \
do \
{ \
static const char* data = "[C++] %s %s:%d: " format "\n"; \
std::printf(data, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
} while (0)
#endif
} // namespace love
4 changes: 4 additions & 0 deletions include/common/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@ namespace love
// Thread
#define E_CHANNEL_VARIANT_UNKNOWN "boolean, number, string, love type, or table expected."
#define E_THREAD_VARIANT_UNKNOWN "boolean, number, string, love type, or flat table expected."

// Window
#define E_WINDOW_CLOSING_RENDERTARGET_ACTIVE \
"love.window.close cannot be called while a render target is active in love.graphics."
} // namespace love
9 changes: 8 additions & 1 deletion include/driver/DigitalSound.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "common/Map.hpp"
#include "common/Singleton.tcc"

#include <atomic>

namespace love
{
template<class T>
Expand All @@ -23,12 +25,17 @@ namespace love
ENCODING_MAX_ENUM
};

virtual void initialize()
DigitalSoundBase() : initialized(false)
{}

virtual void initialize() = 0;

void update()
{
static_cast<T*>(this)->updateImpl();
}

protected:
std::atomic<bool> initialized;
};
} // namespace love
11 changes: 2 additions & 9 deletions include/driver/graphics/DrawCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ namespace love
constexpr size_t INIT_VERTEX_BUFFER_SIZE = sizeof(Vertex) * 4096 * 1;
constexpr size_t INIT_INDEX_BUFFER_SIZE = sizeof(uint16_t) * LOVE_UINT16_MAX * 1;

inline StreamBuffer<Vertex>* newVertexBuffer(size_t size)
{
return new StreamBuffer<Vertex>(BUFFERUSAGE_VERTEX, size);
}

inline StreamBuffer<uint16_t>* newIndexBuffer(size_t size)
{
return new StreamBuffer<uint16_t>(BUFFERUSAGE_INDEX, size);
}
StreamBuffer<Vertex>* newVertexBuffer(size_t size);
StreamBuffer<uint16_t>* newIndexBuffer(size_t size);
} // namespace love
4 changes: 1 addition & 3 deletions include/modules/graphics/TextBatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "common/Range.hpp"

#include "modules/graphics/Buffer.tcc"
// #include "modules/graphics/Buffer.tcc"
#include "modules/graphics/Drawable.hpp"
#include "modules/graphics/Font.tcc"

Expand Down Expand Up @@ -61,8 +61,6 @@ namespace love
VertexAttributes vertexAttributes;
BufferBindings vertexBuffers;

StrongRef<BufferBase> vertexBuffer;

std::vector<Vertex> buffer;
Range modifiedVertices;

Expand Down
4 changes: 4 additions & 0 deletions include/modules/graphics/wrap_Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ namespace Wrap_Graphics

int printf(lua_State* L);

int getDefaultFilter(lua_State* L);

int setDefaultFilter(lua_State* L);

int getScreens(lua_State* L);

int getActiveScreen(lua_State* L);
Expand Down
1 change: 0 additions & 1 deletion include/modules/math/wrap_Math.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,5 @@ function love_math.linearToGamma(r, g, b, a)
end
return linearToGamma(r), linearToGamma(g), linearToGamma(b), a
end

-- DO NOT REMOVE THE NEXT LINE. It is used to load this file as a C++ string.
--)luastring"--"
2 changes: 2 additions & 0 deletions include/modules/system/wrap_System.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ namespace Wrap_System

int setPlayCoins(lua_State* L);

int getTheme(lua_State* L);

int open(lua_State* L);
} // namespace Wrap_System
10 changes: 0 additions & 10 deletions include/modules/window/Window.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ namespace love
return this->open;
}

void close()
{
this->close(true);
}

void updateSettings(const WindowSettings& newSettings, bool updateGraphicsViewport)
{
this->pixelWidth = windowWidth;
Expand Down Expand Up @@ -297,11 +292,6 @@ namespace love
// clang-format on

protected:
void close(bool)
{
this->open = false;
}

bool createWindowAndContext(int x, int y, int width, int height, uint32_t flags)
{
this->open = true;
Expand Down
2 changes: 1 addition & 1 deletion platform/cafe/include/driver/display/GX2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace love

void initialize();

~GX2();
void deInitialize();

int onForegroundAcquired();

Expand Down
4 changes: 4 additions & 0 deletions platform/cafe/include/modules/window/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace love

virtual ~Window();

void close();

void setGraphics(Graphics* graphics)
{
this->graphics.set(graphics);
Expand All @@ -33,6 +35,8 @@ namespace love
using WindowBase::getConstant;

private:
void close(bool allowExceptions);

StrongRef<Graphics> graphics;
};
} // namespace love
9 changes: 9 additions & 0 deletions platform/cafe/include/modules/window/wrap_Window.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
R"luastring"--(
-- DO NOT REMOVE THE ABOVE LINE. It is used to load this file as a C++ string.
-- There is a matching delimiter at the bottom of the file.
local title, message, buttons = ...
local result = nil

return true
-- DO NOT REMOVE THE NEXT LINE. It is used to load this file as a C++ string.
--)luastring"--"
2 changes: 1 addition & 1 deletion platform/cafe/source/driver/display/GX2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace love
dirtyProjection(false)
{}

GX2::~GX2()
void GX2::deInitialize()
{
if (this->inForeground)
this->onForegroundReleased();
Expand Down
1 change: 1 addition & 0 deletions platform/cafe/source/modules/graphics/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ namespace love
return;

this->flushBatchedDraws();
gx2.deInitialize();
}

bool Graphics::isActive() const
Expand Down
18 changes: 18 additions & 0 deletions platform/cafe/source/modules/window/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ namespace love
this->graphics.set(nullptr);
}

void Window::close()
{
this->close(true);
}

void Window::close(bool allowExceptions)
{
if (this->graphics.get())
{
if (allowExceptions && this->graphics->isRenderTargetActive())
throw love::Exception(E_WINDOW_CLOSING_RENDERTARGET_ACTIVE);

this->graphics->unsetMode();
}

this->open = false;
}

bool Window::setWindow(int width, int height, WindowSettings* settings)
{
if (!this->graphics.get())
Expand Down
2 changes: 1 addition & 1 deletion platform/ctr/include/driver/display/citro3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace love

void setupContext();

~citro3d();
void deInitialize();

void clear(const Color& color);

Expand Down
4 changes: 4 additions & 0 deletions platform/ctr/include/modules/window/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace love
this->graphics.set(graphics);
}

void close();

bool setWindow(int width = 800, int height = 600, WindowSettings* settings = nullptr);

void updateSettingsImpl(const WindowSettings& settings, bool updateGraphicsViewport);
Expand All @@ -33,6 +35,8 @@ namespace love
using WindowBase::getConstant;

private:
void close(bool allowExceptions);

StrongRef<Graphics> graphics;
};
} // namespace love
Loading

0 comments on commit 9030513

Please sign in to comment.