glGetString(GL_VERSION)会获得哪个版本? [英] Which version does glGetString(GL_VERSION) get?
问题描述
glGetString(GL_VERSION)
是否获得系统的最大支持版本或当前上下文的版本?
Does glGetString(GL_VERSION)
get the maximum supported version for your system, or the version for your current context?
我知道您需要创建一个上下文才能使glGetString()
工作,所以这使我想知道它是当前上下文还是可用的最高上下文.
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.
推荐答案
摘自规范(从3.3规范文档复制):
From the spec (copied from 3.3 spec document):
字符串查询返回指向UTF-8编码,以NULL终止的静态字符串的指针,这些字符串描述了当前GL上下文的属性.
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返回当前GL上下文可以支持的版本号(在VERSION字符串中).因此,如果客户端和服务器支持不同的版本,则会返回兼容版本.
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.
使用glGetIntegerv()
检查版本通常更容易.这样,您不必开始解析字符串,还可以获取其他详细信息:
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) {
...
}
这篇关于glGetString(GL_VERSION)会获得哪个版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!