when does jogl call its init() function?

hello, i am doing all the loading of my textures on the init function.

now i want to monitor the loading process a little bit, so i am incrementing a variable after each texture is loaded and checking this variable in another thread.

unfortunately it seems as if this variable is never changed, which is very weird.

when exactly is the init() function called? when i do canvas = new GLCanvas(); ?

thanks!

It’s called when the canvas is visualized, so when the parent container is made visible.

thanks for the info!

so that would be on

Frame.setVisible(true);

Yes, or soon afterward. Note that it’s called asynchronously and on another thread, not at exactly that point in your code.

ok, what if i hide the frame and then show it again? will the opengl init be called again?

Probably. Whenever the underlying OS-level widget is destroyed and re-created, your init() method will be called again. This definitely happens when the component is removed from its parent container, but I’m not 100% sure whether it happens on setVisible(false) / setVisible(true). It may only happen when the parent container is explicitly disposed.

I’ve noticed that it sometimes takes a few second before init is called? Is there anything special that influences the time taken for init to be called? Is there anyways I can reduce this delay?

Alex

If you’re seeing a pause like that, I don’t think the time is being spent in JOGL’s code, but in OS-level code causing the widget to be created. I haven’t seen startup delays that long myself. If you run a profiler and find that the time does appear to be going into JOGL’s code please let us know.