mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 23:07:18 +00:00
[host/test] center text in the window
This commit is contained in:
parent
3336f27b5a
commit
7d7074e9f6
@ -23,8 +23,9 @@ int main(int argc, char * argv[])
|
|||||||
SDL_Rect fpsTextRect = {5, 5};
|
SDL_Rect fpsTextRect = {5, 5};
|
||||||
SDL_Texture * fpsText = NULL;
|
SDL_Texture * fpsText = NULL;
|
||||||
|
|
||||||
int boxX = 100;
|
int width = 1000;
|
||||||
int boxY = 100;
|
int boxX = 100;
|
||||||
|
int boxY = 100;
|
||||||
|
|
||||||
fpsFont = TTF_OpenFont("C:\\Windows\\Fonts\\cour.ttf", 24);
|
fpsFont = TTF_OpenFont("C:\\Windows\\Fonts\\cour.ttf", 24);
|
||||||
|
|
||||||
@ -53,8 +54,9 @@ int main(int argc, char * argv[])
|
|||||||
switch (event.window.event)
|
switch (event.window.event)
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
boxX = event.window.data1 / 10;
|
width = event.window.data1;
|
||||||
boxY = (event.window.data2 - 40) / 10;
|
boxX = event.window.data1 / 10;
|
||||||
|
boxY = (event.window.data2 - 40) / 10;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,6 +92,7 @@ int main(int argc, char * argv[])
|
|||||||
if (fpsText)
|
if (fpsText)
|
||||||
SDL_DestroyTexture(fpsText);
|
SDL_DestroyTexture(fpsText);
|
||||||
fpsText = SDL_CreateTextureFromSurface(renderer, fpsSurf);
|
fpsText = SDL_CreateTextureFromSurface(renderer, fpsSurf);
|
||||||
|
fpsTextRect.x = width / 2 - fpsSurf->w / 2;
|
||||||
fpsTextRect.w = fpsSurf->w;
|
fpsTextRect.w = fpsSurf->w;
|
||||||
fpsTextRect.h = fpsSurf->h;
|
fpsTextRect.h = fpsSurf->h;
|
||||||
SDL_FreeSurface(fpsSurf);
|
SDL_FreeSurface(fpsSurf);
|
||||||
|
Loading…
Reference in New Issue
Block a user