efficient storing of data for fastest drawing in opengl

Started by
1 comment, last by LtJax 16 years, 2 months ago
I have a bunch of files exported, and they are in an interesting format, first of all they contain an array of uv coords and 3 triangle-index indices, so basically the indexes for vertices and uv maps are stored together, however the vertexes and normals are in separate array, now i checked out the glVertexPointer and other similar functions, but none od them offers a way to handle this without me converting a lot of this data at runtime, but maybe some of you can explain me a better way to handle such data with minimal overhead? [Edited by - Delfi on February 16, 2008 12:19:51 PM]

Projects: Top Down City: http://mathpudding.com/

Advertisement
If the indices are interlaced with the vertices, then you need to separate them.

For vertices, uv, normals, use the stride parameter in glVertexPointer, glTexCoordPointer, glNormalPointer.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
If you want to do this fast, you need to 'merge' all the vertex information so you just have one index array.

This topic is closed to new replies.

Advertisement