diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 5b969d7b9..5cca167d3 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -91,6 +91,7 @@ extern bool r_showviewer; DWORD gl_fixedcolormap; area_t in_area; TArray currentmapsection; +int camtexcount; void gl_ParseDefs(); @@ -1356,6 +1357,7 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, in } tex->SetUpdated(); + camtexcount++; } //========================================================================== diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index f20c9e502..6d4fdcff8 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -207,22 +207,25 @@ void OpenGLFrameBuffer::Update() // //========================================================================== -CVAR(Bool, gl_finishbeforeswap, false, 0); +CVAR(Bool, gl_finishbeforeswap, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +extern int camtexcount; void OpenGLFrameBuffer::Swap() { + bool swapbefore = gl_finishbeforeswap && camtexcount == 0; Finish.Reset(); Finish.Clock(); - if (gl_finishbeforeswap) glFinish(); + if (swapbefore) glFinish(); if (needsetgamma) { //DoSetGamma(); needsetgamma = false; } SwapBuffers(); - if (!gl_finishbeforeswap) glFinish(); + if (!swapbefore) glFinish(); Finish.Unclock(); swapped = true; + camtexcount = 0; FHardwareTexture::UnbindAll(); mDebug->Update(); }