創建上下文:錯誤時,編譯着色器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。
GL_ARB_explicit_uniform_location'擴展名是否實際存在?從錯誤消息的措辭我猜,即使glsl 3.30可用,它也需要。 –
它是可用的,但有消息稱'或GLSL 3.30'我有'OpenGL的核心配置着色語言版本字符串:3.30'所以程序應該工作。 – bajos