Advertisement

display list to vertex array conversion

Started by September 16, 2002 08:28 AM
4 comments, last by penetrator 22 years, 5 months ago
So far i''m working with display lists, but i''d like to "upgrade" to Vertex arrays. I''ve tried to make it but i was not successful. At the following link, there is a complete VC++ project (only 28k) which render a textured cube using a display list. If someone could please modify it into vertex arrays i''d be very grateful. Thanks anyway here is the link: www.web-discovery.net/downloads/cube.zip
www.web-discovery.net

You data structure is not designed for vertex arrays.
In vertex arrays, you must have an array of "super-vertexes". But in the philosophy of vertex arrays, a "super-vertex" is not only a 3D vector. It also contains all the associated data (texture coordinates and normals in your example).

For your cube, you should have 24 "super-vertexes" ! That is you should have 24 vertexes, 24 texture coordinates and 24 normals.
But in your code, there's 8 vertexes, 12 texture coordinates and 6 normals. You don't want to duplicate coordinates, and that's an honourable purpose, but unfortunately it's not a valuable structure for vertex arrays.

[edited by - vincoof on September 16, 2002 10:59:18 AM]
Advertisement
penetrator, I have code that draws the nehe texture cube (lesson 7) both in vertex arrays and in vertex arrays using the VAR extension. If you want it email me at nitzanw@yahoo.com and I will email you this code.

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
void ConvertToDrawElements ( )
{

counter=0;


for(int i=0;i {
for(int j=0;j<3;j++)
{Indices[counter]=counter;
int vi=face_indicies[j];
int ni=face_indicies[j+3];<br> int ti=face_indicies[j+6];<br><br> Normal[counter*3+0]= normals[ni][0];<br> Normal[counter*3+1]= normals[ni][1];<br> Normal[counter*3+2]= normals[ni][2];<br><br> TexCo[counter*2+0] = textures[ti][0];<br> TexCo[counter*2+1] = textures[ti][1];<br><br> Verts[counter*3+0] = vertices[vi][0];<br> Verts[counter*3+1] = vertices[vi][1];<br> Verts[counter*3+2] = vertices[vi][2];<br> counter++;<br> }<br> }<br><br> glEnableClientState(GL_VERTEX_ARRAY);<br> glEnableClientState(GL_TEXTURE_COORD_ARRAY);<br> glEnableClientState(GL_NORMAL_ARRAY);<br><br> glVertexPointer(3,GL_FLOAT,0,Verts);<br> glTexCoordPointer(2,GL_FLOAT,0,TexCo);<br> glNormalPointer(GL_FLOAT,0,Normal);<br><br><br>} </i>
Game Core
quote:
Original post by vincoof
For your cube, you should have 24 "super-vertexes" ! That is you should have 24 vertexes, 24 texture coordinates and 24 normals.
But in your code, there''s 8 vertexes, 12 texture coordinates and 6 normals. You don''t want to duplicate coordinates, and that''s an honourable purpose, but unfortunately it''s not a valuable structure for vertex arrays.


I really think that cube is ''very bad'' example to demonstrate the use vertex array



-----------
RacingTreme - for fun multiplayer racing:
http://users.utu.fi/stkibr
I agree. not much change in speed.
Game Core

This topic is closed to new replies.

Advertisement