Commit 7fdd1630 authored by hybrid's avatar hybrid

Combine the vsync setting functions into one common extension function. Also...

Combine the vsync setting functions into one common extension function. Also added support for more swap_interval methods on X11 systems.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3638 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 79b3cc2f
......@@ -440,14 +440,7 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
genericDriverInit(params.WindowSize, params.Stencilbuffer);
#ifdef WGL_EXT_swap_control
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
// vsync extension
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
// set vsync
if (wglSwapIntervalEXT)
wglSwapIntervalEXT(params.Vsync ? 1 : 0);
#endif
extGlSwapInterval(params.Vsync ? 1 : 0);
return true;
}
......@@ -542,16 +535,7 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi
genericDriverInit(params.WindowSize, params.Stencilbuffer);
// set vsync
//TODO: Check GLX_EXT_swap_control and GLX_MESA_swap_control
#ifdef GLX_SGI_swap_control
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (params.Vsync && glxSwapIntervalSGI)
glxSwapIntervalSGI(1);
#else
if (params.Vsync)
glXSwapIntervalSGI(1);
#endif
#endif
extGlSwapInterval(params.Vsync ? 1 : 0);
return true;
}
......
......@@ -51,7 +51,16 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0),
pGlCompressedTexImage2D(0),
#if defined(GLX_SGI_swap_control)
glxSwapIntervalSGI(0),
pGlxSwapIntervalSGI(0),
#endif
#if defined(GLX_EXT_swap_control)
pGlxSwapIntervalEXT(0),
#endif
#if defined(GLX_MESA_swap_control)
pGlxSwapIntervalMESA(0),
#endif
#if defined(WGL_EXT_swap_control)
pWglSwapIntervalEXT(0),
#endif
pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0),
pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0),
......@@ -258,6 +267,10 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlEndOcclusionQueryNV = (PFNGLENDOCCLUSIONQUERYNVPROC) wglGetProcAddress("glEndOcclusionQueryNV");
pGlGetOcclusionQueryivNV = (PFNGLGETOCCLUSIONQUERYIVNVPROC) wglGetProcAddress("glGetOcclusionQueryivNV");
pGlGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC) wglGetProcAddress("glGetOcclusionQueryuivNV");
#if defined(WGL_EXT_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
// get vsync extension
pWglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT");
#endif
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined (_IRR_COMPILE_WITH_SDL_DEVICE_)
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
......@@ -458,9 +471,15 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)
IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glCompressedTexImage2D"));
// get vsync extension
#if defined(GLX_SGI_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
// get vsync extension
glxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glXSwapIntervalSGI"));
pGlxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glXSwapIntervalSGI"));
#endif
#if defined(GLX_EXT_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
pGlxSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glXSwapIntervalEXT"));
#endif
#if defined(GLX_MESA_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
pGlxSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glXSwapIntervalMESA"));
#endif
// FrameBufferObjects
......
......@@ -1046,6 +1046,9 @@ class COpenGLExtensionHandler
void extGlGetQueryObjectiv(GLuint id, GLenum pname, GLint *params);
void extGlGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params);
// generic vsync setting method for several extensions
void extGlSwapInterval(int interval);
// the global feature array
bool FeatureAvailable[IRR_OpenGL_Feature_Count];
......@@ -1106,9 +1109,6 @@ class COpenGLExtensionHandler
PFNGLSTENCILFUNCSEPARATEATIPROC pGlStencilFuncSeparateATI;
PFNGLSTENCILOPSEPARATEATIPROC pGlStencilOpSeparateATI;
PFNGLCOMPRESSEDTEXIMAGE2DPROC pGlCompressedTexImage2D;
#if defined(_IRR_LINUX_PLATFORM_) && defined(GLX_SGI_swap_control)
PFNGLXSWAPINTERVALSGIPROC glxSwapIntervalSGI;
#endif
PFNGLBINDFRAMEBUFFEREXTPROC pGlBindFramebufferEXT;
PFNGLDELETEFRAMEBUFFERSEXTPROC pGlDeleteFramebuffersEXT;
PFNGLGENFRAMEBUFFERSEXTPROC pGlGenFramebuffersEXT;
......@@ -1157,6 +1157,18 @@ class COpenGLExtensionHandler
PFNGLENDOCCLUSIONQUERYNVPROC pGlEndOcclusionQueryNV;
PFNGLGETOCCLUSIONQUERYIVNVPROC pGlGetOcclusionQueryivNV;
PFNGLGETOCCLUSIONQUERYUIVNVPROC pGlGetOcclusionQueryuivNV;
#if defined(WGL_EXT_swap_control)
PFNWGLSWAPINTERVALEXTPROC pWglSwapIntervalEXT;
#endif
#if defined(GLX_SGI_swap_control)
PFNGLXSWAPINTERVALSGIPROC pGlxSwapIntervalSGI;
#endif
#if defined(GLX_EXT_swap_control)
PFNGLXSWAPINTERVALEXTPROC pGlxSwapIntervalEXT;
#endif
#if defined(GLX_MESA_swap_control)
PFNGLXSWAPINTERVALMESAPROC pGlxSwapIntervalMESA;
#endif
#endif
};
......@@ -2302,6 +2314,47 @@ inline void COpenGLExtensionHandler::extGlGetQueryObjectuiv(GLuint id, GLenum pn
#endif
}
inline void COpenGLExtensionHandler::extGlSwapInterval(int interval)
{
// we have wglext, so try to use that
#if defined(_IRR_WINDOWS_API_) && defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
#ifdef WGL_EXT_swap_control
if (pWglSwapIntervalEXT)
pWglSwapIntervalEXT(interval);
#endif
#endif
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
//TODO: Check GLX_EXT_swap_control and GLX_MESA_swap_control
#ifdef GLX_SGI_swap_control
// does not work with interval==0
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (interval && pGlxSwapIntervalSGI)
pGlxSwapIntervalSGI(interval);
#else
if (interval)
glXSwapIntervalSGI(interval);
#endif
#elif defined(GLX_EXT_swap_control)
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
Display *dpy = glXGetCurrentDisplay();
GLXDrawable drawable = glXGetCurrentDrawable();
if (pGlxSwapIntervalEXT)
pGlxSwapIntervalEXT(dpy, drawable, interval);
#else
pGlXSwapIntervalEXT(dpy, drawable, interval);
#endif
#elif defined(GLX_MESA_swap_control)
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlxSwapIntervalMESA)
pGlxSwapIntervalMESA(interval);
#else
pGlXSwapIntervalMESA(interval);
#endif
#endif
#endif
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment