Hello.
I want to start using vertex arrays and am not quite sure how to best use them.
static GLfloat g_cube_vertices[] = { 1.0f, 1.0f, 1.0f, //0
-1.0f, 1.0f, 1.0f, //1
1.0f, -1.0f, 1.0f, //2
-1.0f, -1.0f, 1.0f, //31.0f, 1.0f, -1.0f, //4 -1.0f, 1.0f, -1.0f, //5 1.0f, -1.0f, -1.0f, //6 -1.0f, -1.0f, -1.0f}; //7
static GLubyte g_cube_strip[] = {0, 1, 2,
3, 6, 7,
3, 5, 1,
0, 5, 4,
0, 6, 3,
7, 4, 5};//somewhere in the drawing funtion
glVertexPointer(3, GL_FLOAT, 0, g_cube_vertices);
glEnableClientState(GL_VERTEX_ARRAY);glDrawElements(GL_TRIANGLE_STRIP, 18, GL_UNSIGNED_BYTE, g_cube_strip);
This will draw a cube. If I want to draw another cube I simply call glDrawElements again.
Now, when I had never used the vertex array yet I had the impression that you would feed more or less all of your vertex data in the array and then draw it. Now I still draw every cube alone, so I cannot see why I should use it instead of display lists.
Can you show the best way to draw more than 1 object, using the vertex array?
Also I am very confused about how to apply textures, normals and other stuff to the array.
Any help is very appreciated. Thanks.