Sign in to follow this  
stu2000

glusphere and display list

Recommended Posts

I have used display lists before for constantly rendering the static environment (by static i mean it just doesnt change at all which is perfect for display lists)

I tried to do the same again to create a 'space' environment with lots (10 * 10 * 10) gluSpheres randomly placed around in black space. Simple yet effective.

Unfortunately, the code actually works better when i run this code at render:

for(unsigned int s=0; s<asteroids.size();s++)
{
asteroids[s].Render();
}

rather than this:
glCallList(universeListId);


I set up the render list as follows in the universe constructor:

universeListId = glGenLists(1); //Make room for the display list

glNewList(universeListId, GL_COMPILE); //Begin the display list
{
for(unsigned int s=0; s<asteroids.size();s++)
{
asteroids[s].Render();
}

}
glEndList();

where asteroids is just an array of Multiple 'Particle' which has the following render function:

void Render()
{
//draw the ball
glPushMatrix();
glColor3f(1, 1, 1 );
glTranslatef(position.x, position.y, position.z);
gluSphere(gluNewQuadric(), radius, 20, 20);
glPopMatrix();
};



I am thinking that the problem could be with this line:
gluSphere(gluNewQuadric(), radius, 20, 20);

being in the display list. It looks like it constantly creates new vertices etc.
Is there a way to just create and store a glusphere and then render that, or would that not fix the issue.


I have GTX260 graphics card and duel-core 2.66ghz processor just in case someone asks about hardware.

Thx in advance
Stu


---------------------
i have since changed the code to use:
pQuadric = gluNewQuadric(); //in constructor(pQuadric is member variable)
gluSphere(pQuadric, radius, 20, 20); //in render method

I think that makes the program work well for a tiny bit longer but it still suddenly chugs down. It seems like theres a leak somewhere.

------------
Ran some time tests, and it seems that it isnt the call to display list that is taking time, its the glutSwapBuffers();
that takes roughly 940 to 970 ms, basically a whole second.

[Edited by - stu2000 on October 1, 2010 6:54:50 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this