Files
librefront/src/client/gfx_context.c
T

65 lines
1.6 KiB
C

/*
LibreFront --- an OpenFront clone
Copyright (C) 2025 CFPI-FPSI
Copyright (C) 2025 Emil Kosz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <client/gfx_context.h>
GfxContext *
GfxContext_new ()
{
GfxContext *self = g_new0 (GfxContext, 1);
self->window = SDL_CreateWindow (GAME_NAME, 800, 600, SDL_WINDOW_RESIZABLE);
if (!self->window)
{
g_critical ("Couldn't create window for context %p: %s", self, SDL_GetError ());
}
self->renderer = SDL_CreateRenderer (self->window, NULL);
if (!self->window)
{
g_critical ("Couldn't create renderer for context %p: %s", self, SDL_GetError ());
}
return self;
}
void
GfxContext_prerender (GfxContext *self)
{
SDL_RenderClear (self->renderer);
}
void
GfxContext_postrender (GfxContext *self)
{
SDL_RenderPresent (self->renderer);
}
void
GfxContext_free (GfxContext *self)
{
SDL_DestroyRenderer (self->renderer);
SDL_DestroyWindow (self->window);
g_free (self);
}