]> git.tdb.fi Git - libs/gui.git/commitdiff
Add support for swap interval control
authorMikko Rasa <tdb@tdb.fi>
Sun, 2 Oct 2016 21:10:01 +0000 (00:10 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 2 Oct 2016 21:12:31 +0000 (00:12 +0300)
source/graphics/cgl/glcontext.cpp
source/graphics/egl_android/glcontext.cpp
source/graphics/glcontext.cpp
source/graphics/glcontext.h
source/graphics/glx/glcontext.cpp
source/graphics/wgl/glcontext.cpp

index 4d51052175902d85db9805ee34a2c0c81aaae135..02c4d4421a4b0716cc75fb0bcd13d7520ec6a049 100644 (file)
@@ -67,6 +67,11 @@ GLContext::~GLContext()
        delete priv;
 }
 
+void GLContext::set_swap_interval(unsigned)
+{
+       // TODO
+}
+
 void GLContext::swap_buffers()
 {
        flush_gl_buffer(priv->context);
index 0e9873980606316bc6cf381383479e165741bf8e..7853b217a36df35e76862f5511836786133b0038 100644 (file)
@@ -109,6 +109,11 @@ GLContext::~GLContext()
        delete priv;
 }
 
+void GLContext::set_swap_interval(unsigned)
+{
+       // TODO
+}
+
 void GLContext::swap_buffers()
 {
        eglSwapBuffers(priv->display, priv->surface);
index ab0ea7ad59267eb55625c42c2a26a72852450601..47e1e59456cf50478cd3df8798b925407c643ec9 100644 (file)
@@ -41,6 +41,9 @@ void GLContext::platform_init(const GLOptions &)
 GLContext::~GLContext()
 { }
 
+void GLContext::set_swap_interval(unsigned)
+{ }
+
 void GLContext::swap_buffers()
 { }
 
index a2480909416e29d9e1aa96c49ae410ad66d8382b..8cf75c82948fc657869e1d3685dbfcfeb4133233 100644 (file)
@@ -44,6 +44,8 @@ private:
 public:
        ~GLContext();
 
+       void set_swap_interval(unsigned);
+
        void swap_buffers();
 private:
        void window_resized(unsigned, unsigned);
index e4662f37627ceb18685c660692704f065b45e5f1..46da6d1a231091f6aed597e17e7f0f6eeb65911a 100644 (file)
@@ -84,6 +84,15 @@ GLContext::~GLContext()
        delete priv;
 }
 
+void GLContext::set_swap_interval(unsigned i)
+{
+       const GLubyte *name = reinterpret_cast<const GLubyte *>("glXSwapIntervalEXT");
+       PFNGLXSWAPINTERVALEXTPROC func = reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(glXGetProcAddress(name));
+       if(!func)
+               throw runtime_error("glXSwapIntervalEXT not found");
+       func(display.get_private().display, priv->subwnd, i);
+}
+
 void GLContext::swap_buffers()
 {
        glXSwapBuffers(display.get_private().display, priv->subwnd);
index 844f7a712c990a1442a7f442c4d50e5034e5b602..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);