Hello OGL Experts
I’m currently warming up to OGL3.2 / GLSL 1.5 in C#, using OpenTK Wrapper which is close enough to the real API to make me think my issue is more an OpenGL issue than an OpenTK one.
I have created a small vertex shader & fragment shader. My vertex shader has 3 input (color, normal, and of course, vertex) and 2 output (color, normal), which are used in my fragment shader.
My issue, in short, is that the following code (after linking of the “ShaderProgram”, to which I attached my vertex and fragment shader)
int positionLocation = GL.GetAttribLocation(pipeline.ShaderProgram, "in_position");
int colorLocation = GL.GetAttribLocation(pipeline.ShaderProgram, "in_color");
int normalLocation = GL.GetAttribLocation(pipeline.ShaderProgram, "in_normal");
returns :
positionLocation = 0
colorLocation = 1
normalLocation = -1
The shader program compiled successfully, and glError contains “no error”…
The vertex shader program is as follow:
#version 150
precision highp float;
uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;
in vec3 in_position;
in vec3 in_color;
in vec3 in_normal;
out vec3 normal;
out vec3 color;
void main(void)
{
//works only for orthogonal modelview
normal = (modelview_matrix * vec4(in_normal, 0)).xyz;
//send color information to fragment shader
color = in_color;
gl_Position = projection_matrix * modelview_matrix * vec4(in_position, 1);
}
So, a quite simple shader, and of course “in_normal” is there…
Also, if I don’t call EnableVertexAttribArray(normalLocation), then the code runs fine, the vertex and colors are correct. Of course, not the normals…
Is there anything I need to set up to have more than 2 attribs?
Thanks!