很高兴,没有加载扩展
GLAD, extensions not being loaded
当我尝试 运行 GLSL3.3 着色器时,我的应用程序向我发送了这条消息
#version 330
layout(location = 0) in vec2 position;
layout(location = 1) uniform float TimeUniform = 0.0f;
out float TimeUniformFrag;
void main() {
gl_Position = vec4(position.x - 1.0f, position.y - 1.0f, 0.0f, 1.0f);
TimeUniformFrag = TimeUniform;
}
...
Vertex Shader: 0:3(1): error: uniform explicit location requires GL_ARB_explicit_uniform_location and either GL_ARB_explicit_attrib_location or GLSL 3.30.
所以我返回并在 GLAD 生成器中添加了上述扩展:
你可以在下面看到我的选择!
http://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gl%3D3.3&extensions=GL_ARB_explicit_uniform_location
之后,我将 glad.c 和 glad.h 文件复制粘贴回我的文件并编译...令我惊讶的是,我得到了同样的错误! (不包括 KHR.h 文件)
我做错了什么?
这与GLAD无关。它与扩展在 GLSL 中的工作方式有关。
在 OpenGL 中,扩展 存在 ;您的实现提供了它们并且它们具有效果,无论您是否明确使用它们。无论您是否使用扩展加载器,实现仍然提供它们的功能。
但在 GLSL 中,情况并非如此。当您说 #version 330 core
时,您是在说以下文本构成了 OpenGL 着色语言,如规范 3.30 版所定义。确切地说,只有那种语言。
GLSL 3.30 不允许在着色器中指定统一位置。为此,您必须使用 GLSL 版本 4.30 或 ARB_explicit_uniform_location 扩展。
在 GLSL 中,扩展仅在您明确要求时适用于该语言。由于您没有要求 ARB_explicit_uniform_location 扩展,因此其语法更改不适用于您的着色器。因此编译错误。
如果你想让着色器使用扩展,你必须specify it explicitly with a #extension
declaration:
#extension GL_ARB_explicit_uniform_location : require
这应该在您的 #version
声明之后,但 在 任何实际的 GLSL 文本之前。
当我尝试 运行 GLSL3.3 着色器时,我的应用程序向我发送了这条消息
#version 330
layout(location = 0) in vec2 position;
layout(location = 1) uniform float TimeUniform = 0.0f;
out float TimeUniformFrag;
void main() {
gl_Position = vec4(position.x - 1.0f, position.y - 1.0f, 0.0f, 1.0f);
TimeUniformFrag = TimeUniform;
}
...
Vertex Shader: 0:3(1): error: uniform explicit location requires GL_ARB_explicit_uniform_location and either GL_ARB_explicit_attrib_location or GLSL 3.30.
所以我返回并在 GLAD 生成器中添加了上述扩展:
你可以在下面看到我的选择!
http://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gl%3D3.3&extensions=GL_ARB_explicit_uniform_location
之后,我将 glad.c 和 glad.h 文件复制粘贴回我的文件并编译...令我惊讶的是,我得到了同样的错误! (不包括 KHR.h 文件)
我做错了什么?
这与GLAD无关。它与扩展在 GLSL 中的工作方式有关。
在 OpenGL 中,扩展 存在 ;您的实现提供了它们并且它们具有效果,无论您是否明确使用它们。无论您是否使用扩展加载器,实现仍然提供它们的功能。
但在 GLSL 中,情况并非如此。当您说 #version 330 core
时,您是在说以下文本构成了 OpenGL 着色语言,如规范 3.30 版所定义。确切地说,只有那种语言。
GLSL 3.30 不允许在着色器中指定统一位置。为此,您必须使用 GLSL 版本 4.30 或 ARB_explicit_uniform_location 扩展。
在 GLSL 中,扩展仅在您明确要求时适用于该语言。由于您没有要求 ARB_explicit_uniform_location 扩展,因此其语法更改不适用于您的着色器。因此编译错误。
如果你想让着色器使用扩展,你必须specify it explicitly with a #extension
declaration:
#extension GL_ARB_explicit_uniform_location : require
这应该在您的 #version
声明之后,但 在 任何实际的 GLSL 文本之前。