2
* This example code $WHAT_IT_DOES.
4
* This code is public domain. Feel free to use it for any purpose!
7
#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
9
#include <SDL3/SDL_main.h>
11
/* We will use this renderer to draw into this window every frame. */
12
static SDL_Window *window = NULL;
13
static SDL_Renderer *renderer = NULL;
16
/* This function runs once at startup. */
17
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
19
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
20
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
21
return SDL_APP_FAILURE;
24
if (SDL_CreateWindowAndRenderer("examples/CATEGORY/NAME", 640, 480, 0, &window, &renderer) == -1) {
25
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
26
return SDL_APP_FAILURE;
28
return SDL_APP_CONTINUE; /* carry on with the program! */
31
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
32
SDL_AppResult SDL_AppEvent(void *appstate, const SDL_Event *event)
34
if (event->type == SDL_EVENT_QUIT) {
35
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
37
return SDL_APP_CONTINUE; /* carry on with the program! */
40
/* This function runs once per frame, and is the heart of the program. */
41
SDL_AppResult SDL_AppIterate(void *appstate)
43
return SDL_APP_CONTINUE; /* carry on with the program! */
46
/* This function runs once at shutdown. */
47
void SDL_AppQuit(void *appstate)
49
/* SDL will clean up the window/renderer for us. */