[client] renderer: add ability to toggle the FPS display

Before, if you want to see the FPS, you need to close the client and
restart it with the -k switch to see the FPS. This is annoying.

This PR introduces a new keybind, ScrollLock+D, which, when pressed,
toggles the display of the FPS.

This is implemented for both EGL and OpenGL backends.
This commit is contained in:
Quantum
2021-01-31 22:09:03 -05:00
committed by Geoffrey McRae
parent b45f7a6733
commit 89b73512ad
10 changed files with 57 additions and 9 deletions

View File

@@ -42,6 +42,7 @@ struct EGL_FPS
EGL_Shader * shaderBG;
EGL_Model * model;
bool display;
bool ready;
int iwidth, iheight;
float width, height;
@@ -132,8 +133,16 @@ void egl_fps_free(EGL_FPS ** fps)
*fps = NULL;
}
void egl_fps_set_display(EGL_FPS * fps, bool display)
{
fps->display = display;
}
void egl_fps_update(EGL_FPS * fps, const float avgFPS, const float renderFPS)
{
if (!fps->display)
return;
char str[128];
snprintf(str, sizeof(str), "UPS: %8.4f, FPS: %8.4f", avgFPS, renderFPS);
@@ -174,7 +183,7 @@ void egl_fps_update(EGL_FPS * fps, const float avgFPS, const float renderFPS)
void egl_fps_render(EGL_FPS * fps, const float scaleX, const float scaleY)
{
if (!fps->ready)
if (!fps->display || !fps->ready)
return;
glEnable(GL_BLEND);