]> 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 05f9533de839322057b6b896eb8bc0cfabd3636d..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,10 +71,8 @@ void GLContext::swap_buffers()
        ReleaseDC(window.get_private().window, dc);
 }
 
-void GLContext::window_resized(unsigned w, unsigned h)
-{
-       glViewport(0, 0, w, h);
-}
+void GLContext::window_resized(unsigned, unsigned)
+{ }
 
 } // namespace Graphics
 } // namespace Msp