mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Merge pull request #1318 from ada-tv/fix/gl-swapinterval
Fix VR Preview on Linux with Mesa drivers
This commit is contained in:
commit
5b6cda34dc
1 changed files with 28 additions and 2 deletions
|
@ -76,8 +76,23 @@ static void* getGlProcessAddress(const char *namez) {
|
||||||
|
|
||||||
|
|
||||||
typedef Bool (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
|
typedef Bool (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
|
||||||
|
typedef int (*PFNGLXSWAPINTERVALMESAPROC)(unsigned int interval);
|
||||||
|
typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
|
||||||
|
|
||||||
PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC QueryCurrentRendererIntegerMESA;
|
PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC QueryCurrentRendererIntegerMESA;
|
||||||
|
|
||||||
|
// NOTE: On Linux, we can only really use MESA_swap_control.
|
||||||
|
// SGI_swap_control is useless (can't set swap interval to zero),
|
||||||
|
// and EXT_swap_control requires Xlib structures that Qt5 doesn't
|
||||||
|
// expose to us. From what I could tell, Nvidia's driver doesn't
|
||||||
|
// have this extension, so vsync will always be enabled there.
|
||||||
|
// Because Qt5 doesn't expose Xlib structures, we can't properly
|
||||||
|
// check if the GLX extension for these is supported and we have
|
||||||
|
// to hope the driver returns NULL for them.
|
||||||
|
// (QueryCurrentRenderIntegerMESA was already doing this)
|
||||||
|
PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
|
||||||
|
PFNGLXGETSWAPINTERVALMESAPROC GetSwapIntervalMESA;
|
||||||
|
|
||||||
static void* getGlProcessAddress(const char *namez) {
|
static void* getGlProcessAddress(const char *namez) {
|
||||||
return (void*)glXGetProcAddressARB((const GLubyte*)namez);
|
return (void*)glXGetProcAddressARB((const GLubyte*)namez);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +113,8 @@ void gl::initModuleGl() {
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
QueryCurrentRendererIntegerMESA = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)getGlProcessAddress("glXQueryCurrentRendererIntegerMESA");
|
QueryCurrentRendererIntegerMESA = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)getGlProcessAddress("glXQueryCurrentRendererIntegerMESA");
|
||||||
|
SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)getGlProcessAddress("glXSwapIntervalMESA");
|
||||||
|
GetSwapIntervalMESA = (PFNGLXGETSWAPINTERVALMESAPROC)getGlProcessAddress("glXGetSwapIntervalMESA");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_GLES)
|
#if defined(USE_GLES)
|
||||||
|
@ -115,8 +132,13 @@ int gl::getSwapInterval() {
|
||||||
GLint interval;
|
GLint interval;
|
||||||
CGLGetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &interval);
|
CGLGetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &interval);
|
||||||
return interval;
|
return interval;
|
||||||
#else
|
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
// TODO: Fill in for linux
|
if (GetSwapIntervalMESA) {
|
||||||
|
return GetSwapIntervalMESA();
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -128,6 +150,10 @@ void gl::setSwapInterval(int interval) {
|
||||||
CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &interval);
|
CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &interval);
|
||||||
#elif defined(Q_OS_ANDROID)
|
#elif defined(Q_OS_ANDROID)
|
||||||
eglSwapInterval(eglGetCurrentDisplay(), interval);
|
eglSwapInterval(eglGetCurrentDisplay(), interval);
|
||||||
|
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
|
if (SwapIntervalMESA) {
|
||||||
|
SwapIntervalMESA(interval);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(interval);
|
Q_UNUSED(interval);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue