2016-12-02 190 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英特爾集成顯卡驅動程序的問題?