Skip to content

Commit

Permalink
push changes, wii u renders on debug build but not release
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleP committed Oct 29, 2024
1 parent 902f6e2 commit 15b0fcd
Show file tree
Hide file tree
Showing 52 changed files with 1,376 additions and 773 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ target/
*.wuhb
*.py
__pycache__/
todo.md
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ if (NINTENDO_WIIU)
source/modules/image/magpie/PNGHandler.cpp
source/modules/font/freetype/Font.cpp
source/modules/font/freetype/TrueTypeRasterizer.cpp
source/modules/graphics/Font.cpp
source/modules/graphics/freetype/Font.cpp
)

add_library(ddsparse
Expand Down
21 changes: 21 additions & 0 deletions include/common/Exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,25 @@ namespace love
private:
std::string message;
};

#if !(__DEBUG__)
#define LOG()
#else
#include <cstdio>

// 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__); \
} while (0)
#endif
} // namespace love
15 changes: 1 addition & 14 deletions include/common/screen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace love

static constexpr inline Screen INVALID_SCREEN = (Screen)-1;
static constexpr inline Screen DEFAULT_SCREEN = (Screen)0;
inline Screen currentScreen = INVALID_SCREEN;
inline Screen currentScreen = DEFAULT_SCREEN;

std::span<ScreenInfo> getScreenInfo();

Expand Down Expand Up @@ -56,17 +56,4 @@ namespace love

currentScreen = id;
}

inline void nextScreen()
{
const auto& info = getScreenInfo();

if (currentScreen == INVALID_SCREEN)
currentScreen = DEFAULT_SCREEN;
else
currentScreen = (Screen)((int)currentScreen + 1);

if (currentScreen >= (Screen)info.size())
currentScreen = DEFAULT_SCREEN;
}
} // namespace love
2 changes: 1 addition & 1 deletion include/driver/EventQueue.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "common/Singleton.tcc"
#include "events.hpp"

#include "modules/joystick/Joystick.hpp"
#include "modules/joystick/Joystick.tcc"

#include <list>
#include <memory>
Expand Down
5 changes: 2 additions & 3 deletions include/modules/graphics/Font.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include "modules/graphics/Font.tcc"

namespace love
Expand All @@ -10,8 +12,5 @@ namespace love
virtual void createTexture() override;

bool loadVolatile() override;

private:
virtual const FontBase::Glyph& addGlyph(TextShaper::GlyphIndex glyphIndex) override;
};
} // namespace love
4 changes: 4 additions & 0 deletions include/modules/graphics/Shader.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ namespace love
static ShaderBase* current;
static ShaderBase* standardShaders[STANDARD_MAX_ENUM];

ShaderBase(StandardShader type);

virtual ~ShaderBase();

virtual void attach() = 0;

static void attachDefault(StandardShader type);

static bool isDefaultActive();

StandardShader shaderType;
};
} // namespace love
20 changes: 20 additions & 0 deletions include/modules/graphics/freetype/Font.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include "modules/font/freetype/TrueTypeRasterizer.hpp"
#include "modules/graphics/Font.tcc"

namespace love
{
class Font : public FontBase
{
public:
Font(Rasterizer* rasterizer, const SamplerState& samplerState);

virtual void createTexture() override;

bool loadVolatile() override;

private:
virtual const FontBase::Glyph& addGlyph(TextShaper::GlyphIndex glyphIndex) override;
};
} // namespace love
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,8 @@ namespace Wrap_Graphics

int getScreens(lua_State* L);

int getActiveScreen(lua_State* L);

int setActiveScreen(lua_State* L);

int is3D(lua_State* L);
Expand All @@ -211,5 +213,7 @@ namespace Wrap_Graphics

int getDepth(lua_State* L);

int copyCurrentScanBuffer(lua_State* L);

int open(lua_State* L);
} // namespace Wrap_Graphics
12 changes: 6 additions & 6 deletions include/modules/joystick/Joystick.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace love
GAMEPAD_BUTTON_DPAD_DOWN,
GAMEPAD_BUTTON_DPAD_LEFT,
GAMEPAD_BUTTON_DPAD_RIGHT,
GAMEPAD_BUTTON_MISC1,
GAMEPAD_BUTTON_MISC2,
GAMEPAD_BUTTON_MAX_ENUM
};

Expand Down Expand Up @@ -202,7 +204,9 @@ namespace love
{ "dpup", GAMEPAD_BUTTON_DPAD_UP },
{ "dpdown", GAMEPAD_BUTTON_DPAD_DOWN },
{ "dpleft", GAMEPAD_BUTTON_DPAD_LEFT },
{ "dpright", GAMEPAD_BUTTON_DPAD_RIGHT }
{ "dpright", GAMEPAD_BUTTON_DPAD_RIGHT },
{ "misc1", GAMEPAD_BUTTON_MISC1 },
{ "misc2", GAMEPAD_BUTTON_MISC2 }
);

STRINGMAP_DECLARE(GamepadAxes, GamepadAxis,
Expand Down Expand Up @@ -260,11 +264,7 @@ namespace love
return std::clamp(value / MAX_AXIS_VALUE, -1.0f, 1.0f);
}

JoystickBase(int id) :
joystickType(JOYSTICK_TYPE_UNKNOWN),
instanceId(-1),
id(id),
sensors()
JoystickBase(int id) : joystickType(JOYSTICK_TYPE_UNKNOWN), instanceId(-1), id(id), sensors()
{
this->sensors[Sensor::SENSOR_ACCELEROMETER] = false;
this->sensors[Sensor::SENSOR_GYROSCOPE] = false;
Expand Down
2 changes: 1 addition & 1 deletion include/modules/joystick/JoystickModule.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "common/Module.hpp"
#include "modules/joystick/Joystick.hpp"
#include "modules/joystick/Joystick.tcc"

#include <list>
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion include/modules/joystick/wrap_Joystick.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "common/luax.hpp"
#include "modules/joystick/Joystick.hpp"
#include "modules/joystick/Joystick.tcc"

namespace love
{
Expand Down
3 changes: 2 additions & 1 deletion platform/cafe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ source/modules/audio/Source.cpp
source/modules/graphics/Graphics.cpp
source/modules/graphics/Shader.cpp
source/modules/graphics/Texture.cpp
source/modules/joystick/Joystick.cpp
source/modules/joystick/vpad/Joystick.cpp
source/modules/joystick/kpad/Joystick.cpp
source/modules/joystick/JoystickModule.cpp
source/modules/keyboard/Keyboard.cpp
source/modules/system/System.cpp
Expand Down
6 changes: 4 additions & 2 deletions platform/cafe/include/driver/EventQueue.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include "driver/EventQueue.tcc"
#include "modules/joystick/Joystick.hpp"

#include "modules/joystick/kpad/Joystick.hpp"
#include "modules/joystick/vpad/Joystick.hpp"

#include <vpad/input.h>

Expand All @@ -17,7 +19,7 @@ namespace love
void pollInternal() override;

private:
Joystick* gamepad;
vpad::Joystick* gamepad;
VPADTouchData previousTouch;
};
} // namespace love
6 changes: 3 additions & 3 deletions platform/cafe/include/driver/display/Framebuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ namespace love

void copyScanBuffer();

void useState()
operator GX2ContextState*()
{
GX2SetContextState(this->state);
return this->state;
}

private:
static constexpr auto FORMAT = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
static constexpr auto BUFFER_MODE = GX2_BUFFERING_MODE_SINGLE;
static constexpr auto BUFFER_MODE = GX2_BUFFERING_MODE_DOUBLE;
static constexpr auto INVALIDATE_COLOR_BUFFER =
GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_COLOR_BUFFER;

Expand Down
2 changes: 2 additions & 0 deletions platform/cafe/include/driver/display/GX2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ namespace love

void setMode(int width, int height);

void copyCurrentScanBuffer();

// clang-format off
ENUMMAP_DECLARE(PixelFormats, PixelFormat, GX2SurfaceFormat,
{ PIXELFORMAT_R8_UNORM, GX2_SURFACE_FORMAT_UNORM_R8 },
Expand Down
15 changes: 14 additions & 1 deletion platform/cafe/include/driver/display/Uniform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

namespace love
{
glm::mat4 updateMatrix(const glm::mat4& matrix);
// void updateMatrix(glm::mat4& modelView, const Matrix4& matrix);
glm::mat4 createTransposedSwappedMatrix(const Matrix4& matrix);

struct Uniform
{
Expand All @@ -26,6 +27,18 @@ namespace love
for (size_t index = 0; index < count; index++)
std::printf("projection[%zu] = %u\n", index, projection[index]);
}

void update(const Matrix4& matrix)
{
const auto count = sizeof(glm::mat4) / sizeof(uint32_t);
uint32_t* destination = (uint32_t*)glm::value_ptr(this->modelView);

glm::mat4 sourceMatrix = glm::transpose(glm::make_mat4(matrix.getElements()));
uint32_t* source = (uint32_t*)glm::value_ptr(sourceMatrix);

for (int i = 0; i < count; ++i)
destination[i] = __builtin_bswap32(source[i]);
}
};

} // namespace love
2 changes: 2 additions & 0 deletions platform/cafe/include/modules/graphics/Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ namespace love

GX2ColorBuffer getInternalBackbuffer() const;

void copyCurrentScanBuffer();

// clang-format off
virtual TextureBase* newTexture(const TextureBase::Settings& settings, const TextureBase::Slices* data = nullptr) override;
// clang-format on
Expand Down
2 changes: 1 addition & 1 deletion platform/cafe/include/modules/graphics/Texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ namespace love

GX2Texture* texture = nullptr;
GX2ColorBuffer* target = nullptr;
GX2Sampler* sampler = nullptr;
GX2Sampler sampler;
};
} // namespace love
Loading

0 comments on commit 15b0fcd

Please sign in to comment.