SDL
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{
19if (!SDL_Init(SDL_INIT_VIDEO)) {20SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);21return SDL_APP_FAILURE;22}23
24if (!SDL_CreateWindowAndRenderer("examples/CATEGORY/NAME", 640, 480, 0, &window, &renderer)) {25SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);26return SDL_APP_FAILURE;27}28return SDL_APP_CONTINUE; /* carry on with the program! */29}
30
31/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
32SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)33{
34if (event->type == SDL_EVENT_QUIT) {35return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */36}37return SDL_APP_CONTINUE; /* carry on with the program! */38}
39
40/* This function runs once per frame, and is the heart of the program. */
41SDL_AppResult SDL_AppIterate(void *appstate)42{
43return SDL_APP_CONTINUE; /* carry on with the program! */44}
45
46/* This function runs once at shutdown. */
47void SDL_AppQuit(void *appstate)48{
49/* SDL will clean up the window/renderer for us. */50}
51
52