2016-12-02 138 views
-3

我以前在Ubuntu上使用GLFW时遇到了OpenGL问题,但通过使用glfwWindowHints()方法设法解决了这个问题。 Link供参考。GLFW - 无法编译片段着色器

现在,我偶然发现了另一个错误,这次与片段着色器有关。

Failed to compile fragment shader! 
0:60(12): error: `gl_FragColor' undeclared 
0:60(2): error: no matching function for call to `mainImage(error, vec2)'; candidates are: 
0:60(2): error: void mainImage(vec4, vec2) 

下面是命令glxinfo | grep OpenGL的输出:

OpenGL vendor string: Intel Open Source Technology Center 
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2) 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 13.1.0-devel - padoka PPA 
OpenGL core profile shading language version string: 4.50 
OpenGL core profile context flags: (none) 
OpenGL core profile profile mask: core profile 
OpenGL core profile extensions: 
OpenGL version string: 3.0 Mesa 13.1.0-devel - padoka PPA 
OpenGL shading language version string: 1.30 
OpenGL context flags: (none) 
OpenGL extensions: 
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 13.1.0-devel - padoka PPA 
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20 
OpenGL ES profile extensions: 

在我的着色器的文件,我已经定义版本#version 450 core

我在其他地方的论坛上看到0:60(12): error: 'gl_FragColor' undeclared中的(12)表示版本1.2,但我不确定这是否正确。

shader.frag - PasteBin

shader.vert - PasteBin

回答

3

gl_FragColor以来的OpenGL 3.3核心配置文件已被删除。现代的方法是在片段着色器中定义自己的输出变量。您可以使用glBindFragDataLocation​方法或使用布局限定符来指定着色器输出变量和帧缓冲区附件之间的映射。

-1

我发现了一个可能的解决方案。

  1. 在片段着色器初始化GLEW
  2. 替换gl_FragColor与新出的变量out vec4 color;之前设置glewExperimental = GL_TRUE;

然而,我的朋友不需要使用NVIDIA GPU来做到这一点。

也许这只是目前针对Skylake英特尔集成显卡驱动程序的问题?