SDL window open
This commit is contained in:
+80
@@ -0,0 +1,80 @@
|
||||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include <stdlib.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <glib-2.0/glib.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
SDL_Window *sdl_window;
|
||||
SDL_Renderer *sdl_renderer;
|
||||
|
||||
SDL_AppResult
|
||||
SDL_AppInit (void **appstate, int argc, char **argv)
|
||||
{
|
||||
UNUSED (appstate, argc, argv);
|
||||
|
||||
setenv ("GIO_USE_VFS", "local", 1);
|
||||
setenv ("GSETTINGS_BACKEND", "memory", 1);
|
||||
|
||||
#ifdef DEBUG
|
||||
setenv ("G_MESSAGES_DEBUG", "all", 1);
|
||||
#endif
|
||||
|
||||
SDL_SetAppMetadata ("LibreFront", "0.1",
|
||||
"https://git.cfpi-fpsi.eu:8443/chopin-interactive/librefront");
|
||||
|
||||
if (!SDL_Init (SDL_INIT_VIDEO))
|
||||
{
|
||||
g_error ("Couldn't initialize SDL: %s", SDL_GetError ());
|
||||
}
|
||||
|
||||
sdl_window = SDL_CreateWindow ("LibreFront", 800, 600, SDL_WINDOW_RESIZABLE);
|
||||
|
||||
if (!sdl_window)
|
||||
{
|
||||
g_error ("Couldn't create window: %s", SDL_GetError ());
|
||||
}
|
||||
|
||||
sdl_renderer = SDL_CreateRenderer (sdl_window, NULL);
|
||||
|
||||
if (!sdl_renderer)
|
||||
{
|
||||
g_error ("Couldn't create renderer: %s", SDL_GetError ());
|
||||
}
|
||||
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
SDL_AppResult
|
||||
SDL_AppEvent (void *appstate, SDL_Event *event)
|
||||
{
|
||||
UNUSED (appstate);
|
||||
|
||||
if (event->type == SDL_EVENT_QUIT)
|
||||
{
|
||||
return SDL_APP_SUCCESS;
|
||||
}
|
||||
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
SDL_AppResult
|
||||
SDL_AppIterate (void *appstate)
|
||||
{
|
||||
UNUSED (appstate);
|
||||
|
||||
SDL_RenderClear (sdl_renderer);
|
||||
SDL_RenderPresent (sdl_renderer);
|
||||
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_AppQuit (void *appstate, SDL_AppResult result)
|
||||
{
|
||||
UNUSED (appstate, result);
|
||||
|
||||
SDL_DestroyRenderer (sdl_renderer);
|
||||
SDL_DestroyWindow (sdl_window);
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#define UNUSED(...) (UNUSED_1 (__VA_ARGS__, 0))
|
||||
#define UNUSED_1(arg, ...) (void) arg, UNUSED_2 (__VA_ARGS__, 0)
|
||||
#define UNUSED_2(arg, ...) (void) arg, UNUSED_3 (__VA_ARGS__, 0)
|
||||
#define UNUSED_3(arg, ...) (void) arg
|
||||
|
||||
/*
|
||||
|
||||
GLib log levels:
|
||||
|
||||
g_debug
|
||||
g_info
|
||||
g_message
|
||||
g_warning
|
||||
g_critical
|
||||
g_error
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user