summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-3.2.20/examples/template.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/SDL-3.2.20/examples/template.c')
-rw-r--r--src/contrib/SDL-3.2.20/examples/template.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/examples/template.c b/src/contrib/SDL-3.2.20/examples/template.c
new file mode 100644
index 0000000..6719cc9
--- /dev/null
+++ b/src/contrib/SDL-3.2.20/examples/template.c
@@ -0,0 +1,53 @@
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, 0, &window, &renderer)) {
27 SDL_Log("Couldn't create window/renderer: %s", SDL_GetError());
28 return SDL_APP_FAILURE;
29 }
30 return SDL_APP_CONTINUE; /* carry on with the program! */
31}
32
33/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
34SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
35{
36 if (event->type == SDL_EVENT_QUIT) {
37 return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
38 }
39 return SDL_APP_CONTINUE; /* carry on with the program! */
40}
41
42/* This function runs once per frame, and is the heart of the program. */
43SDL_AppResult SDL_AppIterate(void *appstate)
44{
45 return SDL_APP_CONTINUE; /* carry on with the program! */
46}
47
48/* This function runs once at shutdown. */
49void SDL_AppQuit(void *appstate, SDL_AppResult result)
50{
51 /* SDL will clean up the window/renderer for us. */
52}
53