When trying to compile GLSL shaders in C/C++ using GLFW/GLEW I get the following error:
0(12) : error C5052: gl_Position is not accessible in this profile
I followed a tutorial from learnopengl.com. The code runs and displays a empty while square with the above error message being printed to the command line. Any ideas what is happening and how I might fix it?
The fragment shader is:
#version 410
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aColor;
layout (location = 2) in vec2 aTexCoord;
out vec3 ourColor;
out vec2 TexCoord;
void main()
{
gl_Position = vec4(aPos, 1.0);
ourColor = aColor;
TexCoord = aTexCoord;
}
And the vertex shader is:
#version 410
out vec4 FragColor;
in vec3 ourColor;
in vec2 TexCoord;
uniform sampler2D ourTexture;
void main()
{
FragColor = texture(ourTexture, TexCoord);
}
If you would like to see the rest of the code please refer to the tutorial link above.
Looks like you tried to load the fragment shader as the vertex shader and vice versa. gl_Position
can only be set from within the vertex shader, since it's a per-vertex attribute. Loading the shaders in correct order should get rid of that problem though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With