Reputation: 300
Does glGetString(GL_VERSION)
get the maximum supported version for your system, or the version for your current context?
I know that you need to create a context in order for glGetString()
to work, so that is what made me wonder if it was the current context or the highest available.
Upvotes: 4
Views: 6049
Reputation: 54642
From the spec (copied from 3.3 spec document):
String queries return pointers to UTF-8 encoded, NULL-terminated static strings describing properties of the current GL context.
So it's the version supported by the current context. There's a subtle aspect if you're operating in a client/server setup:
GetString returns the version number (in the VERSION string) that can be supported by the current GL context. Thus, if the client and server support different versions a compatible version is returned.
The way I read this, it will return the minimum between the client and server if the two versions are different.
It's generally easier to use glGetIntegerv()
to check the version. This way, you don't have to start parsing strings, and you can also get additional detail:
GLint majVers = 0, minVers = 0, profile = 0, flags = 0;
glGetIntegerv(GL_MAJOR_VERSION, &majVers);
glGetIntegerv(GL_MINOR_VERSION, &minVers);
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
if (profile & GL_CONTEXT_CORE_PROFILE_BIT) {
...
}
if (profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) {
...
}
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) {
...
}
Upvotes: 6
Reputation: 1890
The current context, it is a valid way to query what context you're currently rendering under.
See:
http://www.opengl.org/wiki/GLAPI/glGetString
glGetString: return a string describing the current GL connection
Upvotes: 1