]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/wgl/glcontext.cpp
Add support for swap interval control
[libs/gui.git] / source / graphics / wgl / glcontext.cpp
index b6b2c5f91a68dc1d9260aec31ef3dc38d7c1beb2..3df83f3119a294fa8472729d95e84451957881a6 100644 (file)
@@ -1,8 +1,11 @@
 #include <windows.h>
 #include <GL/gl.h>
+#include <GL/wglext.h>
 #include "glcontext.h"
 #include "window_private.h"
 
+using namespace std;
+
 namespace Msp {
 namespace Graphics {
 
@@ -53,6 +56,14 @@ GLContext::~GLContext()
        delete priv;
 }
 
+void GLContext::set_swap_interval(unsigned i)
+{
+       PFNWGLSWAPINTERVALEXTPROC func = reinterpret_cast<PFNWGLSWAPINTERVALEXTPROC>(wglGetProcAddress("wglSwapIntervalEXT"));
+       if(!func)
+               throw runtime_error("wglSwapIntervalEXT not found");
+       func(i);
+}
+
 void GLContext::swap_buffers()
 {
        HDC dc = GetDC(window.get_private().window);
@@ -60,7 +71,7 @@ void GLContext::swap_buffers()
        ReleaseDC(window.get_private().window, dc);
 }
 
-void GLContext::window_resized(unsigned w, unsigned h)
+void GLContext::window_resized(unsigned, unsigned)
 { }
 
 } // namespace Graphics