mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 13:41:05 +00:00
Make sure SwapInterval is only ever called while the default frame buffer is bound to avoid problems with some drivers
This commit is contained in:
parent
1761da6079
commit
6055f136d8
2 changed files with 24 additions and 1 deletions
|
@ -83,7 +83,7 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int
|
|||
{
|
||||
// SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver.
|
||||
// If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed!
|
||||
SetVSync(vid_vsync);
|
||||
Super::SetVSync(vid_vsync);
|
||||
|
||||
// Make sure all global variables tracking OpenGL context state are reset..
|
||||
FHardwareTexture::InitGlobalState();
|
||||
|
@ -230,6 +230,27 @@ void OpenGLFrameBuffer::Swap()
|
|||
mDebug->Update();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Enable/disable vertical sync
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void OpenGLFrameBuffer::SetVSync(bool vsync)
|
||||
{
|
||||
// Switch to the default frame buffer because some drivers associate the vsync state with the bound FB object.
|
||||
GLint oldDrawFramebufferBinding = 0, oldReadFramebufferBinding = 0;
|
||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldDrawFramebufferBinding);
|
||||
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &oldReadFramebufferBinding);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
|
||||
Super::SetVSync(vsync);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDrawFramebufferBinding);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, oldReadFramebufferBinding);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// DoSetGamma
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
bool Is8BitMode() { return false; }
|
||||
bool IsHWGammaActive() const { return HWGammaActive; }
|
||||
|
||||
void SetVSync(bool vsync);
|
||||
|
||||
private:
|
||||
PalEntry Flash;
|
||||
|
||||
|
|
Loading…
Reference in a new issue