[client] changed opengl to process every frame

This commit is contained in:
Geoffrey McRae 2017-12-13 14:10:24 +11:00
parent d0e5bd02bd
commit b5cb796b7c

View File

@ -29,7 +29,6 @@ struct LGR_OpenGL
bool initialized; bool initialized;
SDL_GLContext glContext; SDL_GLContext glContext;
bool resizeWindow; bool resizeWindow;
bool mouseUpdate;
bool frameUpdate; bool frameUpdate;
LG_RendererFormat format; LG_RendererFormat format;
@ -123,7 +122,7 @@ bool lgr_opengl_initialize(void ** opaque, const LG_RendererParams params, const
} }
} }
SDL_GL_SetSwapInterval(1); SDL_GL_SetSwapInterval(0);
// check if the GPU supports GL_ARB_buffer_storage first // check if the GPU supports GL_ARB_buffer_storage first
// there is no advantage to this renderer if it is not present. // there is no advantage to this renderer if it is not present.
@ -425,10 +424,9 @@ bool lgr_opengl_on_mouse_event(void * opaque, const bool visible, const int x, c
if (!this || !this->initialized) if (!this || !this->initialized)
return false; return false;
if (this->mousePos.x == x && this->mousePos.y == y) if (this->mousePos.x == x && this->mousePos.y == y && this->mouseVisible == visible)
return true; return true;
this->mouseUpdate = true;
this->mouseVisible = visible; this->mouseVisible = visible;
this->mousePos.x = x; this->mousePos.x = x;
this->mousePos.y = y; this->mousePos.y = y;
@ -636,40 +634,30 @@ bool lgr_opengl_render(void * opaque)
{ {
glCallList(this->texList + this->texIndex); glCallList(this->texList + this->texIndex);
this->mouseRepair = false; this->mouseRepair = false;
}
lgr_opengl_draw_mouse(this); lgr_opengl_draw_mouse(this);
if (this->fpsTexture) if (this->fpsTexture)
glCallList(this->fpsList); glCallList(this->fpsList);
glXGetVideoSyncSGI(&this->gpuFrameCount); GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
SDL_GL_SwapWindow(this->params.window); glWaitSync(sync, 0, 1000);
glDeleteSync(sync);
unsigned int count; unsigned int count;
glXGetVideoSyncSGI(&count); glXGetVideoSyncSGI(&count);
while(count == this->gpuFrameCount) if (count == this->gpuFrameCount)
{ glXWaitVideoSyncSGI(1, 0, &count);
unsigned int remainder;
glXWaitVideoSyncSGI(1, 0, &remainder); SDL_GL_SwapWindow(this->params.window);
glXGetVideoSyncSGI(&count); glXGetVideoSyncSGI(&this->gpuFrameCount);
glFinish();
}
++this->frameCount; ++this->frameCount;
const uint64_t t = nanotime(); const uint64_t t = nanotime();
this->renderTime += t - this->lastFrameTime; this->renderTime += t - this->lastFrameTime;
this->lastFrameTime = t; this->lastFrameTime = t;
}
else
if (this->mouseUpdate)
{
glDrawBuffer(GL_FRONT);
lgr_opengl_draw_mouse(this);
glFlush();
glDrawBuffer(GL_BACK);
}
this->frameUpdate = false; this->frameUpdate = false;
this->mouseUpdate = false;
return true; return true;
} }