From 85c83d2417703ed056d29bf474e82b333bdbf6d4 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 13 Dec 2017 05:55:01 +1100 Subject: [PATCH] [client] enable vsync again but draw to front for cursor updates --- client/main.c | 1 - client/renderers/opengl.c | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/main.c b/client/main.c index a79beef6..ba2c8a2d 100644 --- a/client/main.c +++ b/client/main.c @@ -661,7 +661,6 @@ int run() FcPatternDestroy(pat); } - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); state.window = SDL_CreateWindow( "Looking Glass (Client)", params.center ? SDL_WINDOWPOS_CENTERED : params.x, diff --git a/client/renderers/opengl.c b/client/renderers/opengl.c index a5e7e5e5..285ca5b7 100644 --- a/client/renderers/opengl.c +++ b/client/renderers/opengl.c @@ -124,7 +124,7 @@ bool lgr_opengl_initialize(void ** opaque, const LG_RendererParams params, const } } - SDL_GL_SetSwapInterval(0); + SDL_GL_SetSwapInterval(1); // check if the GPU supports GL_ARB_buffer_storage first // there is no advantage to this renderer if it is not present. @@ -669,16 +669,24 @@ bool lgr_opengl_render(void * opaque) glEnable(GL_SCISSOR_TEST); } - glXWaitVideoSyncSGI(1, 0, &this->gpuFrameCount); - glFinish(); - glCallList(this->texList + this->texIndex); this->mouseRepair = false; lgr_opengl_draw_mouse(this); if (this->fpsTexture) glCallList(this->fpsList); - glFlush(); + glXGetVideoSyncSGI(&this->gpuFrameCount); + SDL_GL_SwapWindow(this->params.window); + + unsigned int count; + glXGetVideoSyncSGI(&count); + while(count == this->gpuFrameCount) + { + unsigned int remainder; + glXWaitVideoSyncSGI(1, 0, &remainder); + glXGetVideoSyncSGI(&count); + glFinish(); + } ++this->frameCount; const uint64_t t = nanotime(); @@ -688,8 +696,10 @@ bool lgr_opengl_render(void * opaque) else if (this->mouseUpdate) { + glDrawBuffer(GL_FRONT); lgr_opengl_draw_mouse(this); glFlush(); + glDrawBuffer(GL_BACK); }