Detect GLX version, patch by Philip Falkner.
svn path=/branches/work/kwin_composite/; revision=604801
This commit is contained in:
parent
012be9b663
commit
e86e1cf88f
2 changed files with 24 additions and 8 deletions
30
glutils.cpp
30
glutils.cpp
|
@ -18,6 +18,8 @@ namespace KWinInternal
|
|||
// Variables
|
||||
// GL version, use MAKE_OPENGL_VERSION() macro for comparing with a specific version
|
||||
int glVersion;
|
||||
// GLX version, use MAKE_GLX_VERSION() macro for comparing with a specific version
|
||||
int glXVersion;
|
||||
// List of all supported GL extensions
|
||||
QStringList glExtensions;
|
||||
int glTextureUnitsCount;
|
||||
|
@ -43,17 +45,23 @@ static glXFuncPtr getProcAddress( const char* name )
|
|||
}
|
||||
|
||||
void initGLX()
|
||||
{
|
||||
{
|
||||
// handle OpenGL extensions functions
|
||||
glXGetProcAddress = (glXGetProcAddress_func) getProcAddress( "glxGetProcAddress" );
|
||||
if( glXGetProcAddress == NULL )
|
||||
glXGetProcAddress = (glXGetProcAddress_func) getProcAddress( "glxGetProcAddressARB" );
|
||||
glXBindTexImageEXT = (glXBindTexImageEXT_func) getProcAddress( "glXBindTexImageEXT" );
|
||||
glXReleaseTexImageEXT = (glXReleaseTexImageEXT_func) getProcAddress( "glXReleaseTexImageEXT" );
|
||||
}
|
||||
|
||||
|
||||
// Get GLX version
|
||||
int major, minor;
|
||||
glXQueryVersion( display(), &major, &minor );
|
||||
glXVersion = MAKE_GLX_VERSION( major, minor, 0 );
|
||||
}
|
||||
|
||||
void initGL()
|
||||
{
|
||||
{
|
||||
// handle OpenGL extensions functions
|
||||
glActiveTexture = (glActiveTexture_func) getProcAddress( "glActiveTexture" );
|
||||
if( !glActiveTexture )
|
||||
|
@ -69,16 +77,22 @@ void initGL()
|
|||
glExtensions = QString((const char*)glGetString(GL_EXTENSIONS)).split(" ");
|
||||
// Get number of texture units
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &glTextureUnitsCount);
|
||||
}
|
||||
}
|
||||
|
||||
bool hasGLVersion(int major, int minor, int release)
|
||||
{
|
||||
{
|
||||
return glVersion >= MAKE_OPENGL_VERSION(major, minor, release);
|
||||
}
|
||||
}
|
||||
|
||||
bool hasGLXVersion(int major, int minor, int release)
|
||||
{
|
||||
return glXVersion >= MAKE_GLX_VERSION(major, minor, release);
|
||||
}
|
||||
|
||||
bool hasGLExtension(const QString& extension)
|
||||
{
|
||||
{
|
||||
return glExtensions.contains(extension);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -23,6 +23,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
|
||||
#define MAKE_OPENGL_VERSION(major, minor, release) ( ((major) << 16) | ((minor) << 8) | (release) )
|
||||
#define MAKE_GLX_VERSION(major, minor, release) ( ((major) << 16) | ((minor) << 8) | (release) )
|
||||
|
||||
|
||||
namespace KWinInternal
|
||||
|
@ -42,6 +43,7 @@ extern int glTextureUnitsCount;
|
|||
|
||||
|
||||
bool hasGLVersion(int major, int minor, int release = 0);
|
||||
bool hasGLXVersion(int major, int minor, int release = 0);
|
||||
bool hasGLExtension(const QString& extension);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue