c2woody's picture

OpenGL3 example has incorrect attribute bindings

There's a problem with the OpenGL3-Example: attributes are bound after the shaders are linked, which does not produce an error but does not bind the attribute as expected either. This is no problem in some cases (where the program linking already produces the "correct" binding) where "in_position" will be at attribute index 0. In other cases (newer ATI cards) attributes are incorrectly bound (not visible in the example though since both the vertex and the normal buffer use positionVboData for some reason/by accident).

Easy way to see what's going wrong is using the following block

            GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, true, Vector3.SizeInBytes, 0);
            int in_position_loc = GL.GetAttribLocation(shaderProgramHandle, "in_position");
            GL.BindAttribLocation(shaderProgramHandle, 0, "in_position");
            in_position_loc = GL.GetAttribLocation(shaderProgramHandle, "in_position");

on a driver that initially assigns in_position to not-0.