resizing a JSplitpane causes GLEventListener's "init" to be called

hello,
i am using a JSplitpane to separate a jogl-glcanvas from a swing-ui.

now whenever i resize the jSplitPane, the gleventlistener’s “init” function is called again.

i have also tried a GLJPanel, which results in init being called less often, but it is still called too often :wink:

how can i avoid this? thanks!

You can’t. This is a known limitation, so you have to find ways to make sure init() can be called multiple times (maybe using flags to prevent resources to be loaded again etc.).

ok thanks! well, calling init multiple times itself isnt the real problem here.

the problem is, that all my shader-objects (and maybe also VBOs and FBOs) seem to get destroyed as well and i need to recreate them.

does noone smell a memoryleak here?

Afaik this shouldn’t be a problem, since those objects are managed by the opengl driver and should get destroyed when the gl context is destroyed (which most probably happens before the next init() call). I read somewhere in this forum before that it would be possible to use a pbuffer to create a backing gl context that can be used to share such objects over multiple init() calls or across multiple GLCanvases.

thanks for the information.

yeah the objects on the graphicscard are probably disposed by the driver, but if i have corresponding java-objects, i will need to dispose them manually, right?

is this issue only valid with JSplitPanes? is there any other way to have an opengl context in a resizable swing-component?

If you have corresponding java objects you should make sure, that they are able to recreate the gl objects they represent if those were destroyed.

I think the issue is inherent for every swing component, not only for JSplitPanes. After searching a bit in the forum, I found this short explanation: http://www.java-gaming.org/index.php/topic,18054.msg141639.html#msg141639, but it is targeted at GLJPanel. I would have expected that GLCanvas are safe from multiple init() calls as long as you don’t switch to fullscreen or something. But apparently…

just FYI: the problem could be solved by putting a JPanel between the splitpane and the GLCanvas.