我试图找出我的显卡和驱动程序当前支持哪个版本的 OpenGL。
这个答案建议运行glxinfo | grep OpenGLwhich if罚款,但这里是(一些)输出:
OpenGL vendor string: NVIDIA Corporation
OpenGL core profile version string: 4.5.0 NVIDIA 387.22
OpenGL version string: 4.6.0 NVIDIA 387.22
Run Code Online (Sandbox Code Playgroud)
所以很难说,是4.5还是4.6?
而且nVidia的官方文档也没有提及答案!
Run Code Online (Sandbox Code Playgroud)OpenGL version string: 4.6.0 NVIDIA 387.22
这是该实现将支持的最高旧版本。这里有几种可能性:
nvidia 专有驱动程序属于第 2 类。
对于核心配置文件,根本无法询问实现它可以支持什么,如 本答案所述:
Run Code Online (Sandbox Code Playgroud)OpenGL core profile version string: 4.5.0 NVIDIA 387.22
glxinfo 输出并不意味着您的驱动程序无法执行 4.6 核心。(实际上可以)。这只是意味着 glxinfo 目前不知道 GL 4.6 的存在,仅检查最多 4.5 的情况。
glxinfo的源代码将揭示以下逻辑:
if (coreProfile) {
/* Try to create a core profile, starting with the newest version of
* GL that we're aware of. If we don't specify the version
*/
int i;
for (i = 0; gl_versions[i].major > 0; i++) {
/* don't bother below GL 3.0 */
if (gl_versions[i].major == 3 &&
gl_versions[i].minor == 0)
return 0;
ctx = create_context_flags(dpy, config,
gl_versions[i].major,
gl_versions[i].minor,
0x0,
GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
direct);
if (ctx)
return ctx;
}
/* couldn't get core profile context */
return 0;
}
Run Code Online (Sandbox Code Playgroud)
所以它只是迭代一个数组gl_versions并检查是否可以创建具有该版本的上下文。
OpenGL 4.6 已在 2017 年 10 月 11 日的提交中添加到该数组中:
diff --git a/src/xdemos/glinfo_common.h b/src/xdemos/glinfo_common.h
index 0024f85..4d07f66 100644
--- a/src/xdemos/glinfo_common.h
+++ b/src/xdemos/glinfo_common.h
@@ -86,6 +86,7 @@ struct options
/** list of known OpenGL versions */
static const struct { int major, minor; } gl_versions[] = {
+ {4, 6},
{4, 5},
{4, 4},
{4, 3},
Run Code Online (Sandbox Code Playgroud)
因此,如果您使用glxinfo在 10 月 11 日之前的源代码版本上编译的版本(这意味着现在基本上每个发行版本),它根本不会显示 4.6,即使您的驱动程序可以做到这一点。
所以很难说,是4.5还是4.6?
兼容性和核心配置文件均为 4.6。但我只知道这一点,因为我认识那个司机。