Completely separate drawing stuff into an internal api in case I wanna play with different renderers at some point

This commit is contained in:
2022-11-16 02:48:43 +11:00
parent 30cd5911a5
commit f4863ff56a
3 changed files with 90 additions and 19 deletions

29
draw.c
View File

@ -2,7 +2,29 @@
#include "maths.h"
#include <SDL_render.h>
SDL_Renderer* rend = NULL;
static SDL_Renderer* rend = NULL;
int InitDraw(SDL_Window* window)
{
const int rendflags = SDL_RENDERER_PRESENTVSYNC;
rend = SDL_CreateRenderer(window, -1, rendflags);
return (rend == NULL) ? -1 : 0;
}
void QuitDraw(void)
{
SDL_DestroyRenderer(rend);
rend = NULL;
}
rect GetDrawSizeInPixels(void)
{
rect out = {0, 0, 0, 0};
SDL_GetRendererOutputSize(rend, &out.w, &out.h);
return out;
}
void SetDrawColour(uint32_t c)
{
@ -60,3 +82,8 @@ void DrawCircleSteps(int x, int y, int r, int steps)
lasty = ofsy;
}
}
void DrawPresent(void)
{
SDL_RenderPresent(rend);
}