TheGecko
11-16-2000, 01:57 PM
Hey people...
OK I finally got a model to load up in my test application and now I want to render it onto the screen.I initially did this with a display list and lotsa glVertex3f() calls after the glBegin(GL_TRIANGLES) function.Now I know this is not optimised and not the best way to do it so I decided to use the glArrayElement() instead.But when I run my app,I get some really screwed up things on screen.Here's me code for you to look at:
void CMs3d::ConstructDList(void)
{
//This functon needs some serious optimisations!
glNewList(Model,GL_COMPILE);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,Vertex);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
for(int i=0;i<(int)nNumTriangles;i++)
{
glBegin(GL_TRIANGLES);
glArrayElement(Triangles[i].vertexIndices[0]);
glArrayElement(Triangles[i].vertexIndices[1]);
glArrayElement(Triangles[i].vertexIndices[2]);
/*glVertex3f(Vertex[(Triangles[i].vertexIndices[0])].vertex[0],
Vertex[(Triangles[i].vertexIndices[0])].vertex[1],
Vertex[(Triangles[i].vertexIndices[0])].vertex[2]);
glVertex3f(Vertex[(Triangles[i].vertexIndices[1])].vertex[0],
Vertex[(Triangles[i].vertexIndices[1])].vertex[1],
Vertex[(Triangles[i].vertexIndices[1])].vertex[2]);
glVertex3f(Vertex[(Triangles[i].vertexIndices[2])].vertex[0],
Vertex[(Triangles[i].vertexIndices[2])].vertex[1],
Vertex[(Triangles[i].vertexIndices[2])].vertex[2]);*/
glEnd();
}
glDisableClientState(GL_VERTEX_ARRAY);
glEndList();
}
Any ideas?I think the code is pretty self explanatory.If you still have any questions then I'll try to answer them.
Or do you guys suggest something else I can use? I was looking at glInterleavedArrays() and I was thinking that I should use that since it includes tex coordinates,normals,vertices,colors etc.
So...yeah...help me http://www.opengl.org/discussion_boards/ubb/smile.gif
Oh yeah...the commented code in the body of the glBegin()-glEnd() pair is the old way I used to do it and it works fine.
[This message has been edited by TheGecko (edited 11-16-2000).]
OK I finally got a model to load up in my test application and now I want to render it onto the screen.I initially did this with a display list and lotsa glVertex3f() calls after the glBegin(GL_TRIANGLES) function.Now I know this is not optimised and not the best way to do it so I decided to use the glArrayElement() instead.But when I run my app,I get some really screwed up things on screen.Here's me code for you to look at:
void CMs3d::ConstructDList(void)
{
//This functon needs some serious optimisations!
glNewList(Model,GL_COMPILE);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,Vertex);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
for(int i=0;i<(int)nNumTriangles;i++)
{
glBegin(GL_TRIANGLES);
glArrayElement(Triangles[i].vertexIndices[0]);
glArrayElement(Triangles[i].vertexIndices[1]);
glArrayElement(Triangles[i].vertexIndices[2]);
/*glVertex3f(Vertex[(Triangles[i].vertexIndices[0])].vertex[0],
Vertex[(Triangles[i].vertexIndices[0])].vertex[1],
Vertex[(Triangles[i].vertexIndices[0])].vertex[2]);
glVertex3f(Vertex[(Triangles[i].vertexIndices[1])].vertex[0],
Vertex[(Triangles[i].vertexIndices[1])].vertex[1],
Vertex[(Triangles[i].vertexIndices[1])].vertex[2]);
glVertex3f(Vertex[(Triangles[i].vertexIndices[2])].vertex[0],
Vertex[(Triangles[i].vertexIndices[2])].vertex[1],
Vertex[(Triangles[i].vertexIndices[2])].vertex[2]);*/
glEnd();
}
glDisableClientState(GL_VERTEX_ARRAY);
glEndList();
}
Any ideas?I think the code is pretty self explanatory.If you still have any questions then I'll try to answer them.
Or do you guys suggest something else I can use? I was looking at glInterleavedArrays() and I was thinking that I should use that since it includes tex coordinates,normals,vertices,colors etc.
So...yeah...help me http://www.opengl.org/discussion_boards/ubb/smile.gif
Oh yeah...the commented code in the body of the glBegin()-glEnd() pair is the old way I used to do it and it works fine.
[This message has been edited by TheGecko (edited 11-16-2000).]