[host/test] center text in the window

This commit is contained in:
Geoffrey McRae 2017-12-07 23:00:36 +11:00
parent 3336f27b5a
commit 7d7074e9f6

View File

@ -23,6 +23,7 @@ int main(int argc, char * argv[])
SDL_Rect fpsTextRect = {5, 5};
SDL_Texture * fpsText = NULL;
int width = 1000;
int boxX = 100;
int boxY = 100;
@ -53,6 +54,7 @@ int main(int argc, char * argv[])
switch (event.window.event)
{
case SDL_WINDOWEVENT_RESIZED:
width = event.window.data1;
boxX = event.window.data1 / 10;
boxY = (event.window.data2 - 40) / 10;
break;
@ -90,6 +92,7 @@ int main(int argc, char * argv[])
if (fpsText)
SDL_DestroyTexture(fpsText);
fpsText = SDL_CreateTextureFromSurface(renderer, fpsSurf);
fpsTextRect.x = width / 2 - fpsSurf->w / 2;
fpsTextRect.w = fpsSurf->w;
fpsTextRect.h = fpsSurf->h;
SDL_FreeSurface(fpsSurf);