Would this GLCanvas idea work?

Would this work for solving the Z-order problem with GLCanvas and Swing lightweight components?

Two Swing components, one hosting a GLCanvas. The two components are overlapping and hence the GLCanvas always shows through.

Try this? :
When the GLCanvas component loses focus, make a bitmap of some sort of the openGL displayed bits, then unload the GLCanvas from its Swing container ( e.g. getContentPane().remove(glcanvas) ), then display the static bitmap image.

When the GLCanvas component gains focus again, simply clear the bitmap and reload the GLCanvas.

I’ve tried doing the unload/reload of the GLCanvas and it works pretty well (a little flicker though). I’m trying to get the bitmap part to work right now.

One problem I see is that the background windows could not be dynamically updating their images without gaining focus first.

I’d like to hear anyone’s opinion of this and suggestions. Also, I’m still trying to figure out how to create the Image from the GLCanvas.

Mark

I have no idea if that will work or not but you will need to call glReadPixels to get the frame buffer and then you will just need to use that data as the input for a bufferedimage.