The problem is your buffer offset (last parameter):
glVertexAttribPointer(positionEndLocation, 3, GL_FLOAT, GL_FALSE,
6 * sizeof(float), (GLvoid*)3);
You set it to 3
as you probably mean "start 3 floats (one attribute) later", but what it actually means is "start 3 bytes later". So what you actually need to set the stride to is the size of 3 floats in bytes and thus 3 * sizeof(float)
glVertexAttribPointer(positionEndLocation, 3, GL_FLOAT, GL_FALSE,
6 * sizeof(float), (GLvoid*)(3*sizeof(float)));
Or alternatively use pointer arithmetic:
glVertexAttribPointer(positionEndLocation, 3, GL_FLOAT, GL_FALSE,
6 * sizeof(float), (float*)0 + 3);
And by the way, your glGetAttribLocation
calls are pretty weird, too. As first parameter they expect a GLSL program object (an ID as obtained from glCreateProgram
). I've never seen somebody use an actual number in there (though GL objects are indeed just numbers to the outside world, so for debugging purposes it might be Ok to hardwire it, even if really weird).