shared textures / context

So I’m close to release of my game, but I still have a couple major openGL issues that are driving me crazy. One is the textRenderer issue I mentioned already on here. I still can’t solve that, but I’m wondering if it might be related to another bug… I have this sequence of events:

1 Main Screen Displayed (with GLCanvas in center panel)
2 Popup displayed with second GLCanvas (shared context)
3 Switch main screen to new view (third GLCanvas with same shared context)

in this case the textures are displayed fine.

However if I drop step 2 then textures are displayed in step 1, but not displayed in step 3, and are subsequently lost when returning to main screen, or popups.

I could really do with a few suggestions as to what I could be doing wrong. I’ve had the opengl debug pipeline in there, but nothing out of that so far. Can anyone help please?

I think I’ve found this offending line of code:

centerPanel.removeAll();

This is called when step 3 replaces the content from step 1. So now my question is why would this cause the textures to be lost? I’m still holding a reference to the step 1 GLCanvas, so it shouldn’t be anything to do with the garbage collector. Although the implication here is that step 2 is holding an extra reference to something which is keeping the textures available for step 3. Any ideas?

When you remove a GLCanvas from its container, the state of its context is lost. I’d guess that without the second popup sharing the context that your Main Screen’s context is being lost when it is removed.

One option would be to create a PBuffer at application start and use that as the shared context object for all the other views.

(I’m not sure if GLJPanel has the same problem, since it uses PBuffers internally)

I’ve switched to CardLayout now for that functionality and things are working much better ie I don’t need to add / remove any GLCanvas this way. Thanks :slight_smile: