GLFW - 无法编译片段着色器

时间:2016-12-02 00:07:38

标签: ubuntu opengl fragment shader

我以前在使用GLFW的Ubuntu上遇到了OpenGL的问题但是设法通过使用glfwWindowHints()方法解决了这个问题。 Link供参考。

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

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

2 个答案:

答案 0 :(得分:3)

自从OpenGL 3.3 Core Profile以来,

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

答案 1 :(得分:-1)

我找到了解决问题的可能方法。

  1. 在初始化glew之前设置glewExperimental = GL_TRUE;
  2. 在片段着色器中用新的变量out vec4 color;替换了gl_FragColor。
  3. 我的朋友不需要使用NVIDIA GPU来做这件事。

    对于Skylake的英特尔集成显卡的当前驱动程序,这可能只是一个问题?