2025-05-22 20:07:22 +02:00
|
|
|
#define SDL_MAIN_USE_CALLBACKS
|
2022-12-15 05:58:20 +01:00
|
|
|
#include <SDL3/SDL_main.h>
|
2025-05-22 20:07:22 +02:00
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
|
|
|
|
|
|
static SDL_Window *window;
|
2022-06-03 20:07:43 +02:00
|
|
|
|
2025-05-22 20:07:22 +02:00
|
|
|
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
|
|
|
|
{
|
|
|
|
|
return SDL_APP_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_AppResult SDL_AppIterate(void *appstate)
|
2023-03-05 14:44:38 -08:00
|
|
|
{
|
2022-06-03 20:07:43 +02:00
|
|
|
SDL_Surface *screenSurface = NULL;
|
2025-05-22 20:07:22 +02:00
|
|
|
screenSurface = SDL_GetWindowSurface(window);
|
|
|
|
|
SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapSurfaceRGB(screenSurface, 0xff, 0xff, 0xff));
|
|
|
|
|
SDL_UpdateWindowSurface(window);
|
|
|
|
|
return SDL_APP_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
|
|
|
|
{
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
2025-01-22 12:59:57 -08:00
|
|
|
SDL_Log("Could not initialize SDL: %s", SDL_GetError());
|
2025-05-22 20:07:22 +02:00
|
|
|
return SDL_APP_FAILURE;
|
2022-06-03 20:07:43 +02:00
|
|
|
}
|
2023-03-05 14:44:38 -08:00
|
|
|
window = SDL_CreateWindow("Hello SDL", 640, 480, 0);
|
2023-11-09 22:29:15 +01:00
|
|
|
if (!window) {
|
2025-01-22 12:59:57 -08:00
|
|
|
SDL_Log("could not create window: %s", SDL_GetError());
|
2025-05-22 20:07:22 +02:00
|
|
|
return SDL_APP_FAILURE;
|
2022-06-03 20:07:43 +02:00
|
|
|
}
|
2025-05-22 20:07:22 +02:00
|
|
|
return SDL_APP_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SDL_AppQuit(void *appstate, SDL_AppResult result) {
|
2022-06-03 20:07:43 +02:00
|
|
|
SDL_DestroyWindow(window);
|
|
|
|
|
}
|