Unify the library on an akgl_ namespace

This commit is contained in:
2026-05-06 23:18:42 -04:00
parent f416cb5dee
commit 359ae23414
46 changed files with 1327 additions and 1270 deletions

View File

@@ -17,18 +17,18 @@
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
GAME_frame ball;
GAME_frame paddle1;
GAME_frame paddle2;
GAME_frame table;
tilemap gamemap;
akgl_Frame ball;
akgl_Frame paddle1;
akgl_Frame paddle2;
akgl_Frame table;
akgl_Tilemap gamemap;
MIX_Audio *bgm = NULL;
MIX_Mixer *GAME_mixer = NULL;
MIX_Track *GAME_tracks[64];
SDL_FRect camera;
Game game;
akgl_Game game;
akerr_ErrorContext AKERR_NOIGNORE *GAME_init()
akerr_ErrorContext AKERR_NOIGNORE *akgl_game_init()
{
int i = 0;
PREPARE_ERROR(errctx);
@@ -39,64 +39,64 @@ akerr_ErrorContext AKERR_NOIGNORE *GAME_init()
FAIL_ZERO_BREAK(errctx, strlen((char *)&game.name), AKERR_NULLPOINTER, "Must provide game name");
FAIL_ZERO_BREAK(errctx, strlen((char *)&game.version), AKERR_NULLPOINTER, "Must provide game version");
FAIL_ZERO_BREAK(errctx, strlen((char *)&game.uri), AKERR_NULLPOINTER, "Must provide game uri");
CATCH(errctx, heap_init());
CATCH(errctx, registry_init_actor());
CATCH(errctx, registry_init_sprite());
CATCH(errctx, registry_init_spritesheet());
CATCH(errctx, registry_init_character());
CATCH(errctx, registry_init_font());
CATCH(errctx, registry_init_music());
CATCH(errctx, registry_init_actor_state_strings());
CATCH(errctx, akgl_heap_init());
CATCH(errctx, akgl_registry_init_actor());
CATCH(errctx, akgl_registry_init_sprite());
CATCH(errctx, akgl_registry_init_spritesheet());
CATCH(errctx, akgl_registry_init_character());
CATCH(errctx, akgl_registry_init_font());
CATCH(errctx, akgl_registry_init_music());
CATCH(errctx, akgl_registry_init_actor_state_strings());
} CLEANUP {
} PROCESS(errctx) {
} FINISH(errctx, true)
SDL_SetAppMetadata(game.name, game.version, game.uri);
for ( i = 0 ; i < MAX_CONTROL_MAPS; i++ ) {
memset(&GAME_ControlMaps[i], 0x00, sizeof(SDL3GControlMap));
for ( i = 0 ; i < AKGL_MAX_CONTROL_MAPS; i++ ) {
memset(&GAME_ControlMaps[i], 0x00, sizeof(akgl_ControlMap));
}
FAIL_ZERO_RETURN(
errctx,
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD | SDL_INIT_AUDIO),
AKERR_SDL,
AKGL_ERR_SDL,
"Couldn't initialize SDL: %s",
SDL_GetError());
// Load the Game Controller DB
for ( i = 0; i < SDL_GAMECONTROLLER_DB_LEN ; i++ ) {
for ( i = 0; i < AKGL_SDL_GAMECONTROLLER_DB_LEN ; i++ ) {
if ( SDL_AddGamepadMapping(SDL_GAMECONTROLLER_DB[i]) == -1 ) {
FAIL_ZERO_RETURN(errctx, 0, AKERR_SDL, "%s", SDL_GetError());
FAIL_ZERO_RETURN(errctx, 0, AKGL_ERR_SDL, "%s", SDL_GetError());
}
}
FAIL_ZERO_RETURN(
errctx,
SDL_CreateWindowAndRenderer(game.uri, game.screenwidth, game.screenheight, 0, &window, &renderer),
AKERR_SDL,
AKGL_ERR_SDL,
"Couldn't create window/renderer: %s",
SDL_GetError());
FAIL_ZERO_RETURN(
errctx,
MIX_Init(),
AKERR_SDL,
AKGL_ERR_SDL,
"Couldn't initialize audio: %s",
SDL_GetError());
game.mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, 0);
FAIL_ZERO_RETURN(
errctx,
game.mixer,
AKERR_SDL,
AKGL_ERR_SDL,
"Unable to create mixer device: %s",
SDL_GetError());
FAIL_ZERO_RETURN(
errctx,
TTF_Init(),
AKERR_SDL,
AKGL_ERR_SDL,
"Couldn't initialize front engine: %s",
SDL_GetError());
@@ -106,11 +106,11 @@ akerr_ErrorContext AKERR_NOIGNORE *GAME_init()
camera.h = game.screenheight;
}
void GAME_updateFPS()
void akgl_game_updateFPS()
{
SDL_Time curTime;
curTime = SDL_GetTicksNS();
if ( (curTime - game.lastFPSTime) > TIME_ONESEC_NS ) {
if ( (curTime - game.lastFPSTime) > AKGL_TIME_ONESEC_NS ) {
game.fps = game.framesSinceUpdate;
game.framesSinceUpdate = 0;
game.lastFPSTime = curTime;