c++ - 来自 glxinfo 的 opengl 版本

标签 c++ opengl x11 glut

我正在尝试确定我的 OpenGL 版本。我在 win10 主机上运行 Fedora 29 vmware guest。如果我使用软件渲染(通过 Mesa),我会得到

$ LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVE=softpipe glxinfo | grep OpenGL
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 7.0, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 18.3.6
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.1 Mesa 18.3.6
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

为什么会报告 3.3(核心)和 3.1 两个版本?是因为对于 3.3,我只能获得核心兼容性,而对于 3.1,它可以是核心配置文件,也可以是兼容性配置文件?但是当我用要求 3.3(核心或兼容性配置文件)的代码(使用 freeglut)测试它时,我只能得到 3.1。我已经用 softpipe 和 llvmpipe 测试了代码。此外,以下代码中返回的配置文件始终为 0。

glutInitContextVersion(3, 3); 
glutInitContextProfile(GLUT_CORE_PROFILE);   
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << '\n';
std::cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION)
          << '\n';
int major = 0;
int minor = 0;
int profile = 0;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
std::cout << "major:" << major << '\n'
          << "minor:" << minor << '\n'
          << "profile:" << profile << '\n';

那么为什么 glxinfo 在我无法请求时报告 3.3 核心(除了 3.1)?还是我读错了 glxinfo?

最佳答案

我知道这听起来有点傻,但是您已经在调用 glGetIntegerv 之前调用了 glutCreateWindow 对吗? (否则 GL 上下文将不存在,返回的上下文版本将为 0)。

核心为 3.3 而兼容性为 3.1 的主要原因是规范中的边缘情况。例如,实现遵循核心规范的顶点数组对象可能很容易,但可能需要更长的时间才能使其与古老的遗留功能(如编译的顶点数组、显示列表等)一起正常工作。

基本上对于驱动程序开发人员来说,支持核心配置文件所涉及的工作较少 - 兼容性配置文件本质上更难维护(这是决定引入核心配置文件的主要因素)。

关于c++ - 来自 glxinfo 的 opengl 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56896106/

相关文章:

c++ - 在 std vector 中存储对象的正确方法

c++ - SDL OpenGL 应用程序在 Release模式下崩溃

c - 如何创建与 EGL 一起使用的 native X11 窗口

c++ SDL 一起绘制文本和图形

在 Emscripten 中使用的 C++ mangling 名称

java - GL_QUADS 以我不希望的方式渲染

algorithm - 不变尺度几何

c++ - 使用 GLX(opengl 和 Xlib)设置图像(jpeg | png)背景

c++ - OpenGL - 在 ubuntu 中的线程上创建 vbo?

c++ - ISO C++ 禁止初始化 private const unsigned long?