i want to print vertices arrays using buffer, but i can’t. please help me!!
my Open GL version is 4.2
in userinit part
bool userInit()
{
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
glEnable( GL_CULL_FACE );
glEnable( GL_DEPTH_TEST );
vec4 vertices[6];
vertices[0] = vec4(0.833f, -0.25f, 0, 1);
vertices[1] = vec4(0.0f, 0.5f, 0, 1);
vertices[2] = vec4(-0.833f, -0.25f, 0, 1);
vertices[3] = vec4(0.833f, -0.25f, 0, 1);
vertices[4] = vec4(0.0f, -0.8f, 0, 1);
vertices[5] = vec4(-0.833f, -0.25f, 0, 1);
glGenBuffers( 1, &vertexBuffer );
glBindBuffer( GL_ARRAY_BUFFER, vertexBuffer );
glBufferData( GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW );
return true;
}
in render part
void render()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glUseProgram( pratice );
GLuint vertexPositionLoc = glGetAttribLocation( pratice, "position" );
glEnableVertexAttribArray( vertexPos );
glBindBuffer( GL_ARRAY_BUFFER, vertexBuffer );
glVertexAttribPointer( vertexPos, 4, GL_FLOAT, GL_FALSE, 0, 0 );
glDrawArrays(GL_TRIANGLES, 0, 6);
glutSwapBuffers();
}
this source code prints only one triangle.
why!?!?!?! what’s wrong in this program??