From 34de2139264ce96c6b9bae91b49fb471c8e5d250 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 20 Jul 2018 00:10:29 +1000 Subject: [PATCH] [opengl] render alerts and fps on wait screen --- client/renderers/opengl.c | 75 ++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/client/renderers/opengl.c b/client/renderers/opengl.c index 457027a6..dd1cfb7c 100644 --- a/client/renderers/opengl.c +++ b/client/renderers/opengl.c @@ -190,6 +190,12 @@ void opengl_deinitialize(void * opaque) if (!this) return; + if (this->preConfigured) + { + glDeleteLists(this->fpsList , 1); + glDeleteLists(this->alertList, 1); + } + deconfigure(this); if (this->mouseData) free(this->mouseData); @@ -426,21 +432,22 @@ bool opengl_render(void * opaque, SDL_Window * window) this->resizeWindow = false; } + bool wait = false; if (!configure(this, window)) { render_wait(this); - SDL_GL_SwapWindow(window); - return true; + wait = true; } - - if (!draw_frame(this)) - return false; - - if (!this->texReady) + else { - render_wait(this); - SDL_GL_SwapWindow(window); - return true; + if (!draw_frame(this)) + return false; + + if (!this->texReady) + { + render_wait(this); + wait = true; + } } if (this->params.showFPS && this->renderTime > 1e9) @@ -501,13 +508,17 @@ bool opengl_render(void * opaque, SDL_Window * window) glEndList(); } - bool newShape; - update_mouse_shape(this, &newShape); + if (!wait) + { + bool newShape; + update_mouse_shape(this, &newShape); + + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + glCallList(this->texList + this->texIndex); + draw_mouse(this); + } - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - glCallList(this->texList + this->texIndex); - draw_mouse(this); if (this->fpsTexture) glCallList(this->fpsList); @@ -786,8 +797,24 @@ static bool pre_configure(struct Inst * this, SDL_Window *window) } } + glEnable(GL_TEXTURE_2D); + glEnable(GL_COLOR_MATERIAL); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendEquation(GL_FUNC_ADD); glEnable(GL_MULTISAMPLE); + this->fpsList = glGenLists(1); + this->alertList = glGenLists(1); + + // create the overlay textures + glGenTextures(TEXTURE_COUNT, this->textures); + if (check_gl_error("glGenTextures")) + { + LG_UNLOCK(this->formatLock); + return false; + } + this->hasTextures = true; + SDL_GL_SetSwapInterval(this->opt.vsync ? 1 : 0); this->preConfigured = true; return true; @@ -859,9 +886,7 @@ static bool configure(struct Inst * this, SDL_Window *window) // generate lists for drawing this->texList = glGenLists(BUFFER_COUNT); - this->fpsList = glGenLists(1); this->mouseList = glGenLists(1); - this->alertList = glGenLists(1); // generate the pixel unpack buffers if the decoder isn't going to do it for us if (!this->decoder->has_gl) @@ -932,15 +957,6 @@ static bool configure(struct Inst * this, SDL_Window *window) } } - // create the overlay textures - glGenTextures(TEXTURE_COUNT, this->textures); - if (check_gl_error("glGenTextures")) - { - LG_UNLOCK(this->formatLock); - return false; - } - this->hasTextures = true; - // create the frame textures glGenTextures(BUFFER_COUNT, this->frames); if (check_gl_error("glGenTextures")) @@ -1014,11 +1030,6 @@ static bool configure(struct Inst * this, SDL_Window *window) glBindTexture(GL_TEXTURE_2D, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); - glEnable(GL_TEXTURE_2D); - glEnable(GL_COLOR_MATERIAL); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBlendEquation(GL_FUNC_ADD); - this->resizeWindow = true; this->drawStart = nanotime();