我在装有Intel HD 3000 GPU的HP笔记本电脑上运行带有Mesa 10的Arch Linux。(还有一张ATI卡,但我在启动时将其关闭了。)我正在尝试使用核心配置文件运行OpenGL代码。根据glxinfo,应支持OpenGL 3.1和GLSL 1.4:
-> % glxinfo | grep version
OpenGL core profile version string: 3.1 (Core Profile) Mesa 10.0.1
OpenGL core profile shading language version string: 1.40
OpenGL version string: 3.0 Mesa 10.0.1
OpenGL shading language version string: 1.3
但是,当我编译GLFW程序时,请尝试强制使用核心配置文件,并要求提供OpenGL版本,如下所示:
#include <GL/glew.h>
#include <GLFW/glfw3.h>
int main(void)
{
// Use OpenGL 3.1 core profile
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_CONTEXT_REVISION, 0);
// Create opengl context
int window_width = 1024;
int window_height = 768;
GLFWwindow* window = initialize_glfw(window_width, window_height);
if (!window)
{
glfwTerminate();
std::exit(EXIT_FAILURE);
}
// Display OpenGL version
int major, minor, rev, client, forward, profile;
glfwGetVersion(&major, &minor, &rev);
std::cout << "OpenGL - " << major << "." << minor << "." << rev << std::endl;
}
以及使用GLSL #version 140编译着色器,这是打印输出:
-> % ./main
OpenGL - 3.0.3
Shader compilation failed with this message:
0:1(10): error: GLSL 1.40 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
因此,似乎应该支持OpenGL 3.1和GLSL 1.4,但在我的GLFW程序中并未使用它们。谁能告诉我可能是什么问题?
重新阅读文档后,似乎出现了两个问题。正如elmindreda指出的那样,在创建窗口提示后调用init会将窗口提示恢复为默认值,因此必须首先调用init。
其次,我使用的是OpenGL 3.1,GLFW文档说: “如果要求3.2以下的OpenGL版本,则必须使用GLFW_OPENGL_ANY_PROFILE。” 我正在尝试使用GLFW_OPENGL_CORE_PROFILE。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句