Opengl glVertexAttrib4fv doesn't work?
- by Naor
This is my vertex shader:
static const GLchar * vertex_shader_source[] =
{
"#version 430 core \n"
"layout (location = 0) in vec4 offset; \n"
"void main(void) \n"
"{ \n"
" const vec4 vertices[3] = vec4[3](vec4( 0.25, -0.25, 0.5, 1.0),\n"
" vec4(-0.25, -0.25, 0.5, 1.0), \n"
" vec4( 0.25, 0.25, 0.5, 1.0)); \n"
" gl_Position = vertices[gl_VertexID] + offset; \n"
"} \n"
};
and this is what im trying to do:
glUseProgram(rendering_program);
GLfloat attrib[] = { (float)sin(currentTime) * 0.5f,
(float)cos(currentTime) * 0.6f,
0.0f, 0.0f };
glVertexAttrib4fv(0, attrib);
glDrawArrays(GL_TRIANGLES, 0, 3);
currentTime - The number in seconds since the program has started.
Expected result - Triangle moving around the window.
Its from the SuperBible book (sixth edition), this is the full code:http://pastebin.com/xA3eCKz1
The triangle should move across the screen but it doesn't.