mirror of
https://github.com/shadps4-emu/ext-SDL.git
synced 2024-11-23 18:19:40 +00:00
52 lines
1.6 KiB
C
52 lines
1.6 KiB
C
/*
|
|
* This example code $WHAT_IT_DOES.
|
|
*
|
|
* This code is public domain. Feel free to use it for any purpose!
|
|
*/
|
|
|
|
#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL_main.h>
|
|
|
|
/* We will use this renderer to draw into this window every frame. */
|
|
static SDL_Window *window = NULL;
|
|
static SDL_Renderer *renderer = NULL;
|
|
|
|
|
|
/* This function runs once at startup. */
|
|
int SDL_AppInit(void **appstate, int argc, char *argv[])
|
|
{
|
|
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
|
return SDL_APP_FAILURE;
|
|
}
|
|
|
|
if (SDL_CreateWindowAndRenderer("examples/CATEGORY/NAME", 640, 480, 0, &window, &renderer) == -1) {
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
|
return SDL_APP_FAILURE;
|
|
}
|
|
return SDL_APP_CONTINUE; /* carry on with the program! */
|
|
}
|
|
|
|
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
|
|
int SDL_AppEvent(void *appstate, const 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; /* carry on with the program! */
|
|
}
|
|
|
|
/* This function runs once per frame, and is the heart of the program. */
|
|
int SDL_AppIterate(void *appstate)
|
|
{
|
|
return SDL_APP_CONTINUE; /* carry on with the program! */
|
|
}
|
|
|
|
/* This function runs once at shutdown. */
|
|
void SDL_AppQuit(void *appstate)
|
|
{
|
|
/* SDL will clean up the window/renderer for us. */
|
|
}
|
|
|