Original Post
Ive used Vertex arrays in the past but today when I set this up it dosn't work. perhapes im forgeting something or making a stupid mistake. I can't seem to find the problem. I would be greatful if you could take a look over the code and point out anything wrong. I have narrowed it down to drawing Vertices only.
Array Setup code
float * VArray;
void SetupVA()
{
VArray = new float[Faces * 3 * 3]; // Total Size = 3 dimentions per point, and 3 points per Face
for ( int x = 0; x < Faces; x++ )
{
VArray[( x * 9 ) ] = Vertices[Face[x].A].x;
VArray[( x * 9 ) + 1] = Vertices[Face[x].A].y;
VArray[( x * 9 ) + 2] = Vertices[Face[x].A].z;
VArray[( x * 9 ) + 3] = Vertices[Face[x].B].x;
VArray[( x * 9 ) + 4] = Vertices[Face[x].B].y;
VArray[( x * 9 ) + 5] = Vertices[Face[x].B].z;
VArray[( x * 9 ) + 6] = Vertices[Face[x].C].x;
VArray[( x * 9 ) + 7] = Vertices[Face[x].C].y;
VArray[( x * 9 ) + 8] = Vertices[Face[x].C].z;
}
}
Drawing code (glDrawArrays)
glVertexPointer( 3, GL_FLOAT, sizeof( VArray[0] ), & VArray[0] );
glEnableClientState( GL_VERTEX_ARRAY );
glDrawArrays( GL_TRIANGLES, 0, Faces * 3 );
glDisableClientState( GL_VERTEX_ARRAY );
Alternate Working Drawing Code (glBegin/glEnd)
glBegin( GL_TRIANGLES );
for ( int x = 0; x < Faces; x++ )
{
glVertex3fv( & Vertices[Face[x].A].x );
glVertex3fv( & Vertices[Face[x].B].x );
glVertex3fv( & Vertices[Face[x].C].x );
}
glEnd();
Other Notes:
143 fps on glBegin/glEnd 66 fps on NonWorking glDrawArrays Polygons are drawn when using glDrawArrays but the Vertices is completely incorrect."I seek knowledge and to help those who also seek it" Edit: Code Tag changes [edited by - Xero-X2 on April 27, 2004 10:40:39 PM]