how to send vertices array using buffer

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??

[QUOTE=shinx200;1265817]i want to print vertices arrays using buffer, but i can’t. please help me!!

my Open GL version is 4.2
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??[/QUOTE]
To show only one triangle is correct.
if you add this statement again,
glDrawArrays(GL_TRIANGLES, 3, 6);
you could get the second triangle,

beside, the pratice may be practice.

glDrawArrays(GL_TRIANGLES, 0, 6);

and the correct written should be
glDrawArrays(GL_TRIANGLES, 0, 3);
thus you can show up to four triangles. despite you can get 15 triangles.

You’re using backface-culling but your two triangles are in different winding order. The coordinates of the first triangle are in counterclockwise ordering, the 3 following coordinates of the second triangle are in clockwise order.

That means one of your triangles get culled away.

Always take care to specify your coordinates in a consistent manner.