#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
static SDL_Window *window = NULL;
static SDL_Renderer *renderer = NULL;
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) {
/* Create the window */
if (!SDL_CreateWindowAndRenderer("Hello World", 800, 600, SDL_WINDOW_RESIZABLE, &window, &renderer)) {
SDL_Log("Couldn't create window and renderer: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
if(!SDL_Init(SDL_INIT_VIDEO)){
SDL_Log("Error initializing SDL : %s", SDL_GetError());
return SDL_APP_FAILURE;
}
SDL_Log("App started");
return SDL_APP_CONTINUE;
}
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event){
if (event->type == SDL_EVENT_QUIT) {
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
}
return SDL_APP_CONTINUE;
}
/* This function runs once at shutdown. */
void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
SDL_DestroyRenderer(renderer);
renderer = NULL;
SDL_DestroyWindow(window);
window = NULL;
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
void update(){
}
void render(){
SDL_RenderClear(renderer);
SDL_SetRenderDrawColor(renderer, 10, 10, 50, 255);
SDL_RenderPresent(renderer);
}
/* This function runs once per frame, and is the heart of the program. */
SDL_AppResult SDL_AppIterate(void *appstate){
update();
render();
return SDL_APP_CONTINUE;
}