The following works, to draw a square:
float a[] = {
-1, 1, 0,
1, 1, 0,
-1,-1, 0,
1,1,0,
-1,-1,0,
1,-1,0,
};
glVertexPointer( 3, GL_FLOAT, 0, a );
glDrawArrays( GL_TRIANGLES, 0, 6 );
The following code has the same logic, but I have inserted an extra
float between each vertex. I tell opengl by setting the stride to be
sizeof(float). But the following make square scrambled.
float a[] = {
-1, 1, 0,
99,
1, 1, 0,
99,
-1,-1, 0,
99,
1,1,0,
99,
-1,-1,0,
99,
1,-1,0,
99,
};
glVertexPointer( 3, GL_FLOAT, sizeof(float), a );
glDrawArrays( GL_TRIANGLES, 0, 6 );
Thanks,
~S


|