Atlas - template.c

Home / ext / SDL / examples Lines: 1 | Size: 1805 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 * This example code $WHAT_IT_DOES. 3 * 4 * This code is public domain. Feel free to use it for any purpose! 5 */ 6 7#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */ 8#include <SDL3/SDL.h> 9#include <SDL3/SDL_main.h> 10 11/* We will use this renderer to draw into this window every frame. */ 12static SDL_Window *window = NULL; 13static SDL_Renderer *renderer = NULL; 14 15 16/* This function runs once at startup. */ 17SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) 18{ 19 SDL_SetAppMetadata("Example HUMAN READABLE NAME", "1.0", "com.example.CATEGORY-NAME"); 20 21 if (!SDL_Init(SDL_INIT_VIDEO)) { 22 SDL_Log("Couldn't initialize SDL: %s", SDL_GetError()); 23 return SDL_APP_FAILURE; 24 } 25 26 if (!SDL_CreateWindowAndRenderer("examples/CATEGORY/NAME", 640, 480, SDL_WINDOW_RESIZABLE, &window, &renderer)) { 27 SDL_Log("Couldn't create window/renderer: %s", SDL_GetError()); 28 return SDL_APP_FAILURE; 29 } 30 SDL_SetRenderLogicalPresentation(renderer, 640, 480, SDL_LOGICAL_PRESENTATION_LETTERBOX); 31 32 return SDL_APP_CONTINUE; /* carry on with the program! */ 33} 34 35/* This function runs when a new event (mouse input, keypresses, etc) occurs. */ 36SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) 37{ 38 if (event->type == SDL_EVENT_QUIT) { 39 return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */ 40 } 41 return SDL_APP_CONTINUE; /* carry on with the program! */ 42} 43 44/* This function runs once per frame, and is the heart of the program. */ 45SDL_AppResult SDL_AppIterate(void *appstate) 46{ 47 return SDL_APP_CONTINUE; /* carry on with the program! */ 48} 49 50/* This function runs once at shutdown. */ 51void SDL_AppQuit(void *appstate, SDL_AppResult result) 52{ 53 /* SDL will clean up the window/renderer for us. */ 54} 55 56
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.