PDA

View Full Version : arrays not seenable



01-08-2002, 12:50 AM
hello,

i would like to use arrays but i failed.
i've done it like this:

float v[]={0,0,0, 10,10,10, 20,20,20,
30,30,30, 40,40,40, 50,50,50};
int i[]={0,1,2,3,4,5};

glEnableClientState( GL_VERTEX_ARRAY);
glVertexArray( GL_FLOAT, 0, &v[0]);
glDrawElements( GL_TRIANGLES, 2, &i[0]);

But nothing is seen at the screen !!

help me please !

Lev
01-08-2002, 01:53 AM
I never heard of glVertexArray function!

-Lev

Bob
01-08-2002, 03:16 AM
1: The function to set vertex pointer is called glVertexPointer and takes five parameters.
2: The second parameter in glDrawElements is the number of vertices to draw from the vertex arrays. Drawing a triangle using two vertices won't produce anything, since a triangle requires three vertices.

nemesis
01-08-2002, 03:24 AM
That's it.

void VertexPointer ( int size, enum type, sizei stride, void *pointer ) ;

void DrawElements ( enum mode, sizei count, enum type, void *indices );

This link may be interesting:
http://www.opengl.org/developers/documentation/Specs/glspec1.1/node21.html?Vertex+Arrays#first_hit

-nemesis-

01-08-2002, 03:46 AM
OK, is this better ? (i still haven't time to test)

float v[]={0,0,0, 10,10,10, 20,20,20,
30,30,30, 40,40,40, 50,50,50};
int i[]={0,1,2,3,4,5};

glEnableClientState( GL_VERTEX_ARRAY);
glVertexPointer( 3, GL_FLOAT, 0, &v[0]);
glDrawElements( GL_TRIANGLES, 3, UNSIGNED_INT, &i[0]);
glDisableClientState( GL_VERTEX_ARRAY);

thanks

Bob
01-08-2002, 05:07 AM
Well, apart from the fact that you missed a GL_ before UNSIGNED_INT in glDrawElements, that looks a whole lot better.