template.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
  7. #include <SDL3/SDL.h>
  8. #include <SDL3/SDL_main.h>
  9. /* We will use this renderer to draw into this window every frame. */
  10. static SDL_Window *window = NULL;
  11. static SDL_Renderer *renderer = NULL;
  12. /* This function runs once at startup. */
  13. int SDL_AppInit(void **appstate, int argc, char *argv[])
  14. {
  15. if (SDL_CreateWindowAndRenderer("examples/renderer/clear", 640, 480, 0, &window, &renderer) == -1) {
  16. SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
  17. return SDL_APP_FAILURE;
  18. }
  19. return SDL_APP_CONTINUE; /* carry on with the program! */
  20. }
  21. /* This function runs when a new event (mouse input, keypresses, etc) occurs. */
  22. int SDL_AppEvent(void *appstate, const SDL_Event *event)
  23. {
  24. if (event->type == SDL_EVENT_QUIT) {
  25. return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
  26. }
  27. return SDL_APP_CONTINUE; /* carry on with the program! */
  28. }
  29. /* This function runs once per frame, and is the heart of the program. */
  30. int SDL_AppIterate(void *appstate)
  31. {
  32. }
  33. /* This function runs once at shutdown. */
  34. void SDL_AppQuit(void *appstate)
  35. {
  36. /* SDL will clean up the window/renderer for us. */
  37. }