PDA

View Full Version : Display Sphere



ajmrm
09-05-2002, 08:38 AM
1. trying to generate 50 random sphere in random location.

2. using random # to find coordinates and using glTranslatef() to move.

the problem is when i am trying to display the next sphere the previous sphere is disappaearing... is there anyway to retain the previous frame into the memory and when the next sphere is drawn update with the previous frame???

commands used:
glTranslatef(rand()%50, rand()%30, rand()%10)

glutSolidSphere(rand()%20, 50, 50)

i am using double buffering to accomplish the task.

pls help asap with this problem. to retain r to merge each sphere when trying to draw the next sphere.

thanx.

Deiussum
09-05-2002, 09:05 AM
You should be drawing all the spheres every frame before you swap the buffers.

nexusone
09-05-2002, 03:59 PM
Simple code to draw 50 circles.




int i;

for(i=0; i < 50; i++) Draw Sphere 50 times
{
glPushMatrix();
glTranslatef(rand()%50, rand()%30, rand()%10)
glutSolidSphere(rand()%20, 50, 50)
glPopMatrix();
}




Originally posted by ajmrm:
1. trying to generate 50 random sphere in random location.

2. using random # to find coordinates and using glTranslatef() to move.

the problem is when i am trying to display the next sphere the previous sphere is disappaearing... is there anyway to retain the previous frame into the memory and when the next sphere is drawn update with the previous frame???

commands used:
glTranslatef(rand()%50, rand()%30, rand()%10)

glutSolidSphere(rand()%20, 50, 50)

i am using double buffering to accomplish the task.

pls help asap with this problem. to retain r to merge each sphere when trying to draw the next sphere.

thanx.