Dear All,
I am a beginner at openGL, but have managed to cobble together an otherwise quite nice program that is supposed to animate a number of spheres.
The trouble is that each frame takes a very long time to create (~1 sec). When I rotate the image, it moves quite smoothly, so I guess from that that it is definately my frame CREATION that takes too much time, not the rendering.
Here is my current code:
Code:
void CAnimationDialog::buildFrame(int f)
{
int i, n;
GLUquadricObj *quadratic; // Storage For Our Quadratic Objects ( NEW )
double X, Y, Z;
float r = 0.1f;
quadratic = gluNewQuadric();
::glNewList(1,GL_COMPILE_AND_EXECUTE);
glColor3f(1.0f,1.0f,1.0f);
for(i=0; i<m_ppf; i++)
{
n = m_ppf*f + i;
X = m_x[n];
Y = m_y[n];
Z = m_z[n];
glPushMatrix();
glTranslated(X, Y, Z);
gluSphere(quadratic, m_radius, 12, 12);
glPopMatrix();
}
::glEndList();
}
As you can see, m_ppf (this can often be ~1000) individual spheres are created in each frame.
Am I doing this a silly, time-consumiing way? Any suggestions to speed it up?
On a different topic, when I zoom out, all the spheres get very pale - which is the gl_command that controls this effect?
Thanks everyone - hope you can help,
Phil