2016-07-01 135 views
0

創建上下文:錯誤時,編譯着色器GLSL 3.30

new sf::Window(sf::VideoMode(800, 600), "OpenGL", 
              sf::Style::Default, 
              sf::ContextSettings(24, 8, 0, 3, 3, sf::ContextSettings::Core))); 

我加載擴展由glLoadGen對OpenGL 3.3的核心配置文件的一個擴展EXT_texture_compression_s3tc。當我編譯着色器:

#version 330 core 

layout (location = 0) in vec3 vertPos; 

layout (location = 5) uniform mat4 modelMat; 
layout (location = 6) uniform mat4 viewMat; 
layout (location = 7) uniform mat4 projectionMat; 

out vec4 fragColor; 

void main() 
{ 
    gl_Position = projectionMat * viewMat * modelMat * vec4(vertPos, 1.0); 
    fragColor = vec4(0.5, 0.5, 0.5, 1.0); 
} 

``

#version 330 core 

in vec4 fragColor; 
out vec4 outColor; 

void main() 
{ 
    outColor = fragColor; 
} 

我得到錯誤字符串:

ERROR: Shader compilation error at shader: "media/shaders/shader.vs.glsl" 
0:7(1): error: uniform explicit location requires GL_ARB_explicit_uniform_location and either GL_ARB_explicit_attrib_location or GLSL 3.30. 
0:8(1): error: uniform explicit location requires GL_ARB_explicit_uniform_location and either GL_ARB_explicit_attrib_location or GLSL 3.30. 
0:9(1): error: uniform explicit location requires GL_ARB_explicit_uniform_location and either GL_ARB_explicit_attrib_location or GLSL 3.30. 

但我的OpenGL 3.3(GLSL所以3.30)。 glxinfo打印:

Extended renderer info (GLX_MESA_query_renderer): 
    Vendor: X.Org (0x1002) 
    Device: AMD JUNIPER (DRM 2.43.0, LLVM 3.8.0) (0x68be) 
    Version: 11.2.0 
    Accelerated: yes 
    Video memory: 512MB 
    Unified memory: no 
    Preferred profile: core (0x1) 
    Max core profile version: 3.3 
    Max compat profile version: 3.0 
    Max GLES1 profile version: 1.1 
    Max GLES[23] profile version: 3.0 
OpenGL vendor string: X.Org 
OpenGL renderer string: Gallium 0.4 on AMD JUNIPER (DRM 2.43.0, LLVM 3.8.0) 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.2.0 
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: 

所以我應該能夠使用GLSL 3.30。

+0

GL_ARB_explicit_uniform_location'擴展名是否實際存在?從錯誤消息的措辭我猜,即使glsl 3.30可用,它也需要。 –

+0

它是可用的,但有消息稱'或GLSL 3.30'我有'OpenGL的核心配置着色語言版本字符串:3.30'所以程序應該工作。 – bajos

回答

0

你可以嘗試添加以下行,使下面#version 330 core擴展:

#extension GL_ARB_explicit_uniform_location : require 
3

在着色器指定統一的位置的能力是不是OpenGL的3.3版本或GLSL 3.30版的一部分。這只是GL 4.3或GLSL 4.30的核心功能。指定頂點着色器輸入和片段着色器輸出位置的能力是3.30,但是統一的位置不是。

明確統一的位置規範實際上並不需要特殊硬件;它純粹是一個界面的東西。因此,4.x之前的硬件可以實現它。但是,如果您的硬件僅限於GL 3.3,那麼很有可能硬件太舊,以至於IHV不再使用新的OpenGL功能進行更新。所以即使它可以支持它,IHV停止更新硬件後也會出現此功能。

雖然NVIDIA一直保持他們的一些3.3僅硬件上最新最近,非硬件的功能,同樣不能說是爲Intel或AMD。因此,即使您使用的是NVIDIA®(英偉達™)3.x GPU,但很可能英特爾或AMD的3.x GPU無法正常工作。

在你的情況,「瞻博網絡」指的Radeon 67XX線。這些是GL 4.x零件。但是,您使用的是開源驅動程序,而不是AMD的實際Linux驅動程序,因此您只能從中獲得3.3。

這將是更好地撞你需要的OpenGL版本,以配合您的着色器。但是,如果你想保持它作爲一個3.30着色器,並使用它作爲一個擴展(因爲你正在使用的開源驅動的,而不是AMD的驅動程序),您將需要一個extension declaration以下#version聲明:

#extension GL_ARB_explicit_uniform_location : require 
+0

我的Radeon HD5750,在Windows上我有OGL 4.4,但在Ubuntu Linux我只有OGL 3.3,在新的Linux內核4.x的fglrx的(OGL提供4.4)無法正常工作。我正在考慮用最新的libdrm,llvm和libmesa將發行版更改爲發行版(它會給我OpenGL 4.1)。 ( – bajos