Skip to content

Commit

Permalink
ruby: use wglSwapInterval rather than DwmFlush
Browse files Browse the repository at this point in the history
Despite GFWL, and other sources recommending the DwmFlush approach, actual users are setting better results the old way.
  • Loading branch information
LukeUsher committed Jan 25, 2024
1 parent a938ef8 commit 527aaef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ruby/video/wgl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "opengl/opengl.hpp"
#include <dwmapi.h>

#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
Expand Down Expand Up @@ -41,6 +40,9 @@ struct VideoWGL : VideoDriver, OpenGL {
}

auto setBlocking(bool blocking) -> bool override {
acquireContext();
if(wglSwapInterval) wglSwapInterval(blocking);
releaseContext();
return true;
}

Expand Down Expand Up @@ -105,7 +107,6 @@ struct VideoWGL : VideoDriver, OpenGL {
OpenGL::output();

SwapBuffers(_display);
if(self.blocking) DwmFlush(); // DwmFlush waits for VSYNC at compositor level, bypassing OpenGL driver bugs
if(self.flush) glFinish();
releaseContext();
}
Expand Down Expand Up @@ -188,7 +189,7 @@ struct VideoWGL : VideoDriver, OpenGL {
}
}

if(wglSwapInterval) wglSwapInterval(0);
if(wglSwapInterval) wglSwapInterval(self.blocking);
_ready = OpenGL::initialize(self.shader);
releaseContext();
return _ready;
Expand Down

0 comments on commit 527aaef

Please sign in to comment.