Arch 上的 OpenGL 3.3 Linux
OpenGL 3.3 on Arch Linux
我需要帮助使用核心配置文件进行一些 OpenGL 3.3 编程。我 运行 在 Arch Linux OS 上安装了软件包 xf86-video-intel
和 mesa-libgl
。我的 CPU
中内置了 Intel HD 4400
当我在终端输入glxinfo | grep OpenGL
时,显示我可以支持OpenGL 3.3
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 12.0.3
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.0 Mesa 12.0.3
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 12.0.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
我正在使用 GLFW3 和 GLEW 来设置 OpenGL
if(!glfwInit()) {
return -1;
}
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello Guys", NULL, NULL);
if(!window) {
glfwTerminate();
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwMakeContextCurrent(window);
if(glewInit() != GLEW_OK) {
printf("GLEW did not initialize\n");
glfwTerminate();
return -1;
}
但是,当我尝试编译着色器时,出现错误 GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
Mesa 或 GLFW3 似乎让我的 PC 使用向前兼容的配置文件而不是核心配置文件。我该如何解决这个问题?
来自 the docs(强调我的):
void glfwWindowHint( int hint, int value )
This function sets hints for the next call to
glfwCreateWindow
. ...
因此:除非您想要 the defaults,否则请确保在创建 window 之前 设置提示 :
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello Guys", NULL, NULL);
if(!window) {
glfwTerminate();
return -1;
}
我需要帮助使用核心配置文件进行一些 OpenGL 3.3 编程。我 运行 在 Arch Linux OS 上安装了软件包 xf86-video-intel
和 mesa-libgl
。我的 CPU
当我在终端输入glxinfo | grep OpenGL
时,显示我可以支持OpenGL 3.3
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 12.0.3
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.0 Mesa 12.0.3
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 12.0.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
我正在使用 GLFW3 和 GLEW 来设置 OpenGL
if(!glfwInit()) {
return -1;
}
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello Guys", NULL, NULL);
if(!window) {
glfwTerminate();
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwMakeContextCurrent(window);
if(glewInit() != GLEW_OK) {
printf("GLEW did not initialize\n");
glfwTerminate();
return -1;
}
但是,当我尝试编译着色器时,出现错误 GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
Mesa 或 GLFW3 似乎让我的 PC 使用向前兼容的配置文件而不是核心配置文件。我该如何解决这个问题?
来自 the docs(强调我的):
void glfwWindowHint( int hint, int value )
This function sets hints for the next call to
glfwCreateWindow
. ...
因此:除非您想要 the defaults,否则请确保在创建 window 之前 设置提示 :
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello Guys", NULL, NULL);
if(!window) {
glfwTerminate();
return -1;
}