How to add render object during the animator is running?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to add render object during the animator is running?

robbiezl
In my programe. all the render objects are in a ArrayList to save.When the animator start running, all these object in ArrayList call public void init(GLAutoDrawable arg0) method and rendering these object in the method public void display(GLAutoDrawable arg0)

when the animator is running ,i add a new render object in the ArrayList,but i must to recall the init method of this object.
how i can do this? if I use animator.stop() and then use animator.start(),the programe frame may block a few time.
how to solve this problem?Any other advise?

sorry for my poor English.
Reply | Threaded
Open this post in threaded view
|

Re: How to add render object during the animator is running?

gouessej
Administrator
Hi

You should not do this. init() is called once and can be called again if the OpenGL context is destroyed and recreated, you should not have to call it several times to do something else. In my humble opinion, your method display(GLAutoDrawable) should look at your list, check whether the initialization needs to be (re)done and do it if necessary for each object, and display all objects. The initialization should be redone in init only when the OpenGL context is destroyed and recreated.

If you don't want to waste your time in reinventing the wheel, maybe you should use a scenegraph instead of making your own one except for pedagogical purposes.
Julien Gouesse | Personal blog | Website