A sphere every 10 seconds

Hi all,
I am trying now to make a sphere appears on the screen every 10 seconds…
I tried drawing the sphere inside the timer function but it didn’t work?
Can anybody tell me how can I make a new sphere appears every certain amount of time so that the spheres will be increasing on the screen by time?
Thank you in advance =)

I tried drawing the sphere inside the timer function but it didn’t work?
depends how you draw your scene and what didnt work.
every 10 secs you should:

  • glClear
  • drawSphere
  • swapBuffers

but when I clear every 10 seconds that means that the old spheres will disappear…
I mean by “didn’t work” that it draws nothing
simply I need a scene of spheres increasing by time that’s all
Thank u

they will of course be erased from screen, if you need multiple spheres then you need to draw them multiple times. its just how it is. clearing the buffers is essential and swapping after the drawing so you can see the rendered scene.

Yea what you need a simple scene graph, essentially you make a class that has and manages an array of objects (a struct containing position, size, shape, visibility and so on), you use this array to render from each frame.
then every 10 seconds you just add a new object.

“Yea what you need a simple scene graph, essentially you make a class that has and manages an array of objects (a struct containing position, size, shape, visibility and so on), you use this array to render from each frame.”
seems a bit overwhelming for a beginner.

try to draw 2 spheres only at the moment, next to each other. you can use glTranslate to move them around. when you figure out how you do it you can draw as many spheres as you want. i guess you use one function call to draw one single sphere.

My suggestion for a first step is to write a routine that is called with one parameter - the number of spheres to be drawn. Use gluSphere, glTranslate, glScale, etc., to draw and position the spheres so they are not on top of each other, inside each other, etc., and are all within the volume of space visible to your camera. Check your code by calling this routine with different numbers of spheres to be drawn.

Once you get that done, the business of making a new sphere appear every 10 seconds will be trivial.

I did it
thank you so much :):slight_smile: