main_gui.c 1016 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #define SDL_MAIN_USE_CALLBACKS
  2. #include <SDL3/SDL_main.h>
  3. #include <SDL3/SDL.h>
  4. static SDL_Window *window;
  5. SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
  6. {
  7. return SDL_APP_CONTINUE;
  8. }
  9. SDL_AppResult SDL_AppIterate(void *appstate)
  10. {
  11. SDL_Surface *screenSurface = NULL;
  12. screenSurface = SDL_GetWindowSurface(window);
  13. SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapSurfaceRGB(screenSurface, 0xff, 0xff, 0xff));
  14. SDL_UpdateWindowSurface(window);
  15. return SDL_APP_CONTINUE;
  16. }
  17. SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
  18. {
  19. if (!SDL_Init(SDL_INIT_VIDEO)) {
  20. SDL_Log("Could not initialize SDL: %s", SDL_GetError());
  21. return SDL_APP_FAILURE;
  22. }
  23. window = SDL_CreateWindow("Hello SDL", 640, 480, 0);
  24. if (!window) {
  25. SDL_Log("could not create window: %s", SDL_GetError());
  26. return SDL_APP_FAILURE;
  27. }
  28. return SDL_APP_CONTINUE;
  29. }
  30. void SDL_AppQuit(void *appstate, SDL_AppResult result) {
  31. SDL_DestroyWindow(window);
  32. }