/* LibreFront --- an OpenFront clone Copyright (C) 2025 Adrien Jaguenet Copyright (C) 2025 Emil Kosz This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ #define SDL_MAIN_USE_CALLBACKS 1 #include #include #include #include #include #include static GfxContext *gfx_ctx; SDL_AppResult SDL_AppInit (void **appstate, int argc, char **argv) { UNUSED (appstate, argc, argv); /* Makes GLib use less dumb useless shit. */ setenv ("GIO_USE_VFS", "local", 1); setenv ("GSETTINGS_BACKEND", "memory", 1); /* This is set in the Makefile. By default it's 1, so we get all the debug messages printed. */ #ifdef DEBUG setenv ("G_MESSAGES_DEBUG", "all", 1); #endif SDL_SetAppMetadata (GAME_NAME, GAME_VERSION, GAME_URL); if (!SDL_Init (SDL_INIT_VIDEO)) { g_error ("Couldn't initialize SDL: %s", SDL_GetError ()); } gfx_ctx = GfxContext_new (); return SDL_APP_CONTINUE; } SDL_AppResult SDL_AppEvent (void *appstate, SDL_Event *event) { UNUSED (appstate); if (event->type == SDL_EVENT_QUIT) { return SDL_APP_SUCCESS; } return SDL_APP_CONTINUE; } SDL_AppResult SDL_AppIterate (void *appstate) { UNUSED (appstate); GfxContext_prerender (gfx_ctx); GfxContext_postrender (gfx_ctx); return SDL_APP_CONTINUE; } void SDL_AppQuit (void *appstate, SDL_AppResult result) { UNUSED (appstate, result); GfxContext_free (gfx_ctx); }