PDA

View Full Version : Vertex arrays.



dxantos
08-26-2000, 10:35 AM
Having a cube with 8 vertex, it would seem that each of the 8 vertex need only be transformed once.

But since for each face I can only give one index per (the same for the vertex, vertex normal, vertex color and uv) if the cube has a different uv per face per vertex, each of the 8 vertex would transformed 3 times (once for each adjacent face) giving a total of 24 transformations instead of 8.

The question is, is there anyway to eliminate that 300% overhead (could be more if the vertex has more than 3 uvs), and transform each vertex only once?

Don't Disturb
08-26-2000, 11:54 AM
I haven't tried this, so I don't know if it works, but experiment with this:

glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (2, GL_INT, 0, vertices);
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0, 1.0);
glArrayElement (2);
glTexCoord2f(1.0, 1.0);
glArrayElement (3);
glTexCoord2f(0.0, 0.0);
glArrayElement (5);
glEnd();

Gorg
08-26-2000, 01:16 PM
No there is no way. The truth is, vertex arrays are good for large meshes. A cube isn't worth anything with VertexArrays, just call the standard glBegin, glEnd.

pavlos
08-26-2000, 01:51 PM
You can do it using the EXT_compiled_vertex_array extension.
Itís very easy to integrate to your current code, but keep in mind that there is some restrictions (like you must lock only the vertices you are going to use, or you may have a performance loss in simple scenes),so maybe you must redesign some parts of your engine.Also, is used by Quake 3 ,so itís optimized in most drivers if you define each vertex with 3 GLfloat,a color array with 4 Glubyte,a tex courd array for texture unit 0 using 2 Glfloats,and another one for texture unit 1(Yes, this is the format Quake 3 use).

zed
08-26-2000, 03:16 PM
"vertex arrays are good for large meshes"
did anyone see the mesh striperfier? from the nvidia site recently it'll breakup a model into tri_strips of IIRC 1-32 triangles im curious as to why they limit it to just 32 is it either
A/ trying to break the model up into larger strips will leave a lot of isolated triangels
B/ strips (with vert arrays) work best if kept quite small