From: Mikko Rasa Date: Sun, 2 Oct 2016 21:10:01 +0000 (+0300) Subject: Add support for swap interval control X-Git-Url: http://git.tdb.fi/?p=libs%2Fgui.git;a=commitdiff_plain;h=213ca43656411a06bbf1c0d18e4ebacaf545eb34 Add support for swap interval control --- diff --git a/source/graphics/cgl/glcontext.cpp b/source/graphics/cgl/glcontext.cpp index 4d51052..02c4d44 100644 --- a/source/graphics/cgl/glcontext.cpp +++ b/source/graphics/cgl/glcontext.cpp @@ -67,6 +67,11 @@ GLContext::~GLContext() delete priv; } +void GLContext::set_swap_interval(unsigned) +{ + // TODO +} + void GLContext::swap_buffers() { flush_gl_buffer(priv->context); diff --git a/source/graphics/egl_android/glcontext.cpp b/source/graphics/egl_android/glcontext.cpp index 0e98739..7853b21 100644 --- a/source/graphics/egl_android/glcontext.cpp +++ b/source/graphics/egl_android/glcontext.cpp @@ -109,6 +109,11 @@ GLContext::~GLContext() delete priv; } +void GLContext::set_swap_interval(unsigned) +{ + // TODO +} + void GLContext::swap_buffers() { eglSwapBuffers(priv->display, priv->surface); diff --git a/source/graphics/glcontext.cpp b/source/graphics/glcontext.cpp index ab0ea7a..47e1e59 100644 --- a/source/graphics/glcontext.cpp +++ b/source/graphics/glcontext.cpp @@ -41,6 +41,9 @@ void GLContext::platform_init(const GLOptions &) GLContext::~GLContext() { } +void GLContext::set_swap_interval(unsigned) +{ } + void GLContext::swap_buffers() { } diff --git a/source/graphics/glcontext.h b/source/graphics/glcontext.h index a248090..8cf75c8 100644 --- a/source/graphics/glcontext.h +++ b/source/graphics/glcontext.h @@ -44,6 +44,8 @@ private: public: ~GLContext(); + void set_swap_interval(unsigned); + void swap_buffers(); private: void window_resized(unsigned, unsigned); diff --git a/source/graphics/glx/glcontext.cpp b/source/graphics/glx/glcontext.cpp index e4662f3..46da6d1 100644 --- a/source/graphics/glx/glcontext.cpp +++ b/source/graphics/glx/glcontext.cpp @@ -84,6 +84,15 @@ GLContext::~GLContext() delete priv; } +void GLContext::set_swap_interval(unsigned i) +{ + const GLubyte *name = reinterpret_cast("glXSwapIntervalEXT"); + PFNGLXSWAPINTERVALEXTPROC func = reinterpret_cast(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); diff --git a/source/graphics/wgl/glcontext.cpp b/source/graphics/wgl/glcontext.cpp index 844f7a7..3df83f3 100644 --- a/source/graphics/wgl/glcontext.cpp +++ b/source/graphics/wgl/glcontext.cpp @@ -1,8 +1,11 @@ #include #include +#include #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(wglGetProcAddress("wglSwapIntervalEXT")); + if(!func) + throw runtime_error("wglSwapIntervalEXT not found"); + func(i); +} + void GLContext::swap_buffers() { HDC dc = GetDC(window.get_private().window);