I have a 3D grid of spheres. Each frame/update I add 1 or more spheres to the 3D grid. So over time more and more spheres are added. Once added they stay in the same positions. Think of it like a blob made from smaller spheres that grows as more spheres are added to the blob.
The basic flow each frame is;
Update the OpenGL Viewport, Lookat, Rotations, Lights, etc.
Then loop through the spheres and draw them by,
glpushmatrix; gltranslatef(xpos,ypos,zpos); quadric:=gluNewQuadric; gluQuadricNormals(quadric, GLU_SMOOTH); gluSphere(quadric,radius,precision,precision); glpopmatrix; gluDeleteQuadric(quadric);
Then display the result.
The problem is this gets very slow as the sphere count increases.
So my next idea was to only init/clear/lookat once before the main loop and then just render each sphere once as it gets added to the scene. This works but I cannot change the lookat position each frame (this is to auto zoom out to show the blob as it grows).
I have tried push and pop matrix at various points but cannot get it working.
So my basic flow is
InitOpenGL once before the sphere drawing begins
Draw next sphere (inside above glusphere code)
repeat loop until stopped
That works and the spheres are added (and a huge speedup from rendering them all each frame) but I cannot reset the view?
Any ideas? I hope I explained it clear enough and hope I am missing something obvious.