Jump to content
  • Advertisement
Sign in to follow this  
Fabio de T P

low performance on scene graph

This topic is 4318 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

Hi... i made my own scenegraph to organize my scene and help me to draw until i make an octree.. so, the node is a abstract node, basic like this sceneGraphNode { virtual void draw () =0; mat4 transformationMatrix; vector< sceneGraphNode*> sons; }; so, all the others type of node needs to inherite from sceneGraphNode then, a basic mesh node has this draw method void draw () { glPushMatrix (); glMultMatrixf ( (GLfloat*) transformationMatrix.get_pData ()); glBegin (GL_TRIANGLES); for (unsigned int i=0; i<indexs->size(); i+=1) { glNormal3fv (normalV->at(indexs->at(i).getA()).getData()); glVertex3fv (vertices->at(indexs->at(i).getA()).getData()); glNormal3fv (normalV->at(indexs->at(i).getB()).getData()); glVertex3fv (vertices->at(indexs->at(i).getB()).getData()); glNormal3fv (normalV->at(indexs->at(i).getC()).getData()); glVertex3fv (vertices->at(indexs->at(i).getC()).getData()); } glEnd (); for (unsigned int i=0; i<sons.size(); i+=1) sons->draw (); glPopMatrix (); } i know i can use VBO, drawElements.. etc... but the big problems is: i have tested with a model that has 100.000 polygon and are made of others mesh, as several roofing tiles, so to draw it roofing tile, the program needs to multiply his transformation matrix and start a glBegin () and glEnd (), etc... i tested with fraps and in my geforce 7800GT this scene, and it got just 30fps... when i used one display list for all the house, its go to more than 1000 fps (just need one matrix multiplication, because with display list, the house isnt made of a lot os submeshes, but just one instance of display list) is there any problem with my sceneGraph?

Share this post


Link to post
Share on other sites
Advertisement
Its not your scene graph thats slow, its the use of the immediate 3d calls:

glBegin (GL_TRIANGLES);
for (unsigned int i=0; i<indexs->size(); i+=1)
{
glNormal3fv (normalV->at(indexs->at(i).getA()).getData());
glVertex3fv (vertices->at(indexs->at(i).getA()).getData());
glNormal3fv (normalV->at(indexs->at(i).getB()).getData());
glVertex3fv (vertices->at(indexs->at(i).getB()).getData());
glNormal3fv (normalV->at(indexs->at(i).getC()).getData());
glVertex3fv (vertices->at(indexs->at(i).getC()).getData());
}
glEnd ();

If your using that for models with 100,000 polygons you are going to be seeing the slowdowns in this loop.

what you want to do is to use indexed vertex arrays via the glDrawArray functionality - that way you upload your geometry and index arrays in a single batch without looping through every vertex.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!