Pixels, Surfaces, Renderer, oh my...

This commit is contained in:
BadQuanta
2026-05-11 10:28:21 +00:00
parent 97c8847eb0
commit 28e9c4ba18
35 changed files with 4578 additions and 1210 deletions
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#define SDL_MAIN_USE_CALLBACKS 1
#include <SDL3/SDL_main.h>
#include <hdk/sdl/Application.hpp>
/// @macro HDK_SDL_MAIN_CLASS(klass)
/// @brief Define the SDL main entry point using a class implementing hdk::sdl::ApplicationInterface.
/// @param klass Class name of the application implementation. Must implement hdk::sdl::ApplicationInterface with Init,
/// Event, Iterate, and Quit methods.
/// @details This macro generates the SDL main entry point functions (SDL_AppInit, SDL_AppEvent, SDL_AppIterate,
/// SDL_AppQuit) that create an instance of the specified class and delegate to its methods. This allows users to write
/// their application logic in a clean class structure while still integrating with SDL's application lifecycle. The
/// generated main functions handle the boilerplate of managing the application instance and connecting it to SDL's
/// event loop and lifecycle callbacks.
#define HDK_SDL_MAIN_CLASS(klass) \
SDL_AppResult SDL_AppInit(void** appstate, int argc, char* argv[]) { \
klass* app = new klass(); \
*appstate = app; \
return app->Init(argc, argv); \
} \
SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) { \
klass* app = static_cast<klass*>(appstate); \
return app->Event(event); \
} \
SDL_AppResult SDL_AppIterate(void* appstate) { \
klass* app = static_cast<klass*>(appstate); \
return app->Iterate(); \
} \
void SDL_AppQuit(void* appstate, SDL_AppResult result) { \
klass* app = static_cast<klass*>(appstate); \
app->Quit(result); \
delete app; \
}
// end of file