PDA

View Full Version : A sphere every 10 seconds



Madonna
05-08-2009, 12:51 AM
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 =)

_NK47
05-08-2009, 01:52 AM
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

Madonna
05-08-2009, 02:33 AM
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

_NK47
05-08-2009, 02:37 AM
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.

zeoverlord
05-08-2009, 02:45 AM
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.

_NK47
05-08-2009, 03:55 AM
"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.

MaxH
05-08-2009, 11:36 AM
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.

Madonna
05-15-2009, 04:26 AM
I did it
thank you so much :):)