I need help doing some OpenGL 3.3 programming with core profile. I'm running on an Arch Linux OS with the packages xf86-video-intel
and mesa-libgl
installed. I have Intel HD 4400 built into my CPU
我需要帮助做一些OpenGL 3.3的核心配置文件编程。我正在运行一个Arch Linux操作系统,并安装了xf86-video intel和mesa-libgl软件包。我的CPU内置了英特尔HD 4400。
When I enter glxinfo | grep OpenGL
into terminal, It shows I can support OpenGL 3.3
当我将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:
I'm using GLFW3 and GLEW to setup OpenGL
我使用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;
}
However, when I try to compile shaders, I get the error GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
然而,当我尝试编译着色器时,我得到错误GLSL 3.30不被支持。支持的版本有:1.10、1.20、1.30、1.00 ES和3.00 ES
It seems Mesa or GLFW3 is making my PC use the forward compatible profile instead of the core profile. How can I fix this?
似乎Mesa或GLFW3正在使我的PC使用前向兼容配置文件,而不是核心配置文件。我该怎么解决这个问题呢?
1 个解决方案
#1
3
From the docs (emphasis mine):
来自文档(重点是我的):
void glfwWindowHint( int hint, int value )
This function sets hints for the next call to
glfwCreateWindow
. ...这个函数为下一次调用glfwCreateWindow设置提示。
So: unless you want the defaults make sure to set hints before you create the 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;
}
#1
3
From the docs (emphasis mine):
来自文档(重点是我的):
void glfwWindowHint( int hint, int value )
This function sets hints for the next call to
glfwCreateWindow
. ...这个函数为下一次调用glfwCreateWindow设置提示。
So: unless you want the defaults make sure to set hints before you create the 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;
}