53 lines
1 KiB
C
53 lines
1 KiB
C
#include <SDL.h>
|
|
#include "libutils/utils.h"
|
|
|
|
static SDL_Window *window = NULL;
|
|
static SDL_Renderer *renderer = NULL;
|
|
static SDL_Texture *fonts = NULL;
|
|
|
|
int
|
|
monitor_setup(void)
|
|
{
|
|
SDL_Surface *surface;
|
|
|
|
window = SDL_CreateWindow("65∞2",
|
|
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
|
320, 200, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
|
if (window == NULL)
|
|
{
|
|
fatal("SDL: %s", SDL_GetError());
|
|
}
|
|
|
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
|
if (renderer == NULL)
|
|
{
|
|
fatal("SDL: %s", SDL_GetError());
|
|
}
|
|
|
|
SDL_RenderSetLogicalSize(renderer, 320, 200);
|
|
|
|
surface = SDL_LoadBMP("res/fonts.bmp");
|
|
if (surface == NULL)
|
|
{
|
|
fatal("SDL: %s", SDL_GetError());
|
|
}
|
|
fonts = SDL_CreateTextureFromSurface(renderer, surface);
|
|
if (fonts == NULL)
|
|
{
|
|
fatal("SDL: %s", SDL_GetError());
|
|
}
|
|
SDL_FreeSurface(surface);
|
|
}
|
|
|
|
void
|
|
monitor_draw(void)
|
|
{
|
|
SDL_RenderPresent(renderer);
|
|
}
|
|
|
|
void
|
|
monitor_cleanup(void)
|
|
{
|
|
SDL_DestroyRenderer(renderer);
|
|
SDL_DestroyWindow(window);
|
|
} |