Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

penetrator

display list to vertex array conversion

This topic is 5932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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
-------------------------

Share this post


Link to post
Share on other sites
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[i][j+3];
int ti=face_indicies[i][j+6];

Normal[counter*3+0]= normals[ni][0];
Normal[counter*3+1]= normals[ni][1];
Normal[counter*3+2]= normals[ni][2];

TexCo[counter*2+0] = textures[ti][0];
TexCo[counter*2+1] = textures[ti][1];

Verts[counter*3+0] = vertices[vi][0];
Verts[counter*3+1] = vertices[vi][1];
Verts[counter*3+2] = vertices[vi][2];
counter++;
}
}

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);

glVertexPointer(3,GL_FLOAT,0,Verts);
glTexCoordPointer(2,GL_FLOAT,0,TexCo);
glNormalPointer(GL_FLOAT,0,Normal);


}

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!