68 lines
1.3 KiB
C
68 lines
1.3 KiB
C
#define SDL_MAIN_USE_CALLBACKS 1
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL_main.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "shader.h"
|
|
|
|
static SDL_Window *window = NULL;
|
|
static SDL_GLContext context = NULL;
|
|
|
|
SDL_AppResult
|
|
SDL_AppInit (void **appstate, int argc, char **argv)
|
|
{
|
|
(void) appstate; (void) argc; (void) argv;
|
|
|
|
INFO ("Running game with debugging facilities.");
|
|
SDL_SetAppMetadata ("Wschód", VERSION, "eur.chopininteractive.wschod-game");
|
|
|
|
if (!SDL_Init (SDL_INIT_VIDEO)) {
|
|
ERROR ("Couldn't initialize SDL: %s", SDL_GetError());
|
|
return SDL_APP_FAILURE;
|
|
}
|
|
|
|
window = SDL_CreateWindow ("Wschód", 640, 480, SDL_WINDOW_OPENGL);
|
|
|
|
if (!window) {
|
|
ERROR ("Couldn't create window: %s", SDL_GetError());
|
|
return SDL_APP_FAILURE;
|
|
}
|
|
|
|
context = SDL_GL_CreateContext (window);
|
|
|
|
return SDL_APP_CONTINUE;
|
|
}
|
|
|
|
SDL_AppResult
|
|
SDL_AppEvent (void *appstate, SDL_Event *event)
|
|
{
|
|
(void) appstate;
|
|
|
|
if (event->type == SDL_EVENT_QUIT) {
|
|
return SDL_APP_SUCCESS;
|
|
}
|
|
|
|
return SDL_APP_CONTINUE;
|
|
}
|
|
|
|
SDL_AppResult
|
|
SDL_AppIterate (void *appstate)
|
|
{
|
|
(void) appstate;
|
|
|
|
glClearColor (0, 0, 0, 1);
|
|
glClear (GL_COLOR_BUFFER_BIT);
|
|
SDL_GL_SwapWindow (window);
|
|
|
|
return SDL_APP_CONTINUE;
|
|
}
|
|
|
|
void
|
|
SDL_AppQuit (void *appstate, SDL_AppResult result)
|
|
{
|
|
(void) appstate;
|
|
(void) result;
|
|
SDL_GL_DestroyContext (context);
|
|
}
|