PDA

View Full Version : Vertex arrays help..



Bruno
08-22-2000, 09:02 AM
Hi
I have this piece of functional code, that renders some geometric shapes to the screen.


apont=init;
int count=0;
do{
setTexture(apont->texture);

glBegin(GL_TRIANGLE_STRIP);

glTexture2d(apont->u,apont->v);
glVertex3f(apont->x,apont->y,apont->z);
apont=apont->prox;

glTexture2d(apont->u,apont->v);
glVertex3f(apont->x,apont->y,apont->z);
apont=apont->prox;

glTexture2d(apont->u,apont->v);
glVertex3f(apont->x,apont->y,apont->z);
apont=apont->prox;

glTexture2d(apont->u,apont->v);
glVertex3f(apont->x,apont->y,apont->z);
apont=apont->prox;
count+=4;
glEnd();

}while(apont!=NULL);


Now, i'm tryng to make this with vertex arrays, and this is what i
got so far:

I'm defining an array, where the first 3 digits, are for coords, the
next 2 are for u,v coords, and the last one if for the texture
identification.

float varray[count*6]; --> like this i should have the number
of positions i want in the array.
int total = count;
glVertexPointer ( 3, GL_FLOAT, 3, &v_array );

glTexCoordPointer (2, GL_FLOAT, 1 , &v_array[3]);

num=0;
do{

setTexture(v_array[num+4]);
glBegin(GL_TRIANGLE_STRIP);
glArrayElement(num);
num++;
glArrayElement(num);
num++;
glArrayElement(num);
num++;
glArrayElement(num);
num++;
glEnd();

}until(num!=count); -->the variable count comes

With the vertex arrays, i just get i piece of junk on the screen.
Can someone plese, look at this, and tell me what i'm doinf wrong here?

thanks
Bruno