Re: useful Java2D bridge
Posted by Brandon Borkholder on Mar 01, 2012; 4:52pm
URL: https://forum.jogamp.org/useful-Java2D-bridge-tp3391708p3791047.html
Martin, I'm sorry for taking so long to reply. I've been looking into that issue and I have only a partial answer so far.
Component.getGraphics() is not the right way check if the component is being drawn with GLGraphics2D. I'm still learning a lot about Swing painting, but most painting calls happen when *something* calls JComponent.paint(Graphics) on the top level, which then calls paint(Graphics) on all the children with the same Graphics object. So it doesn't matter what JComponent.getGraphics() returns, it matters what's being passed in. And in my testing, I can verify that's usually the case (unless there's a bug).
The second part of your question - what's the right way to verify then? Well, I've been trying to use Javassist, Guice, ASM or other libraries to instrument JComponent.paint(Graphics) and print out the Graphics class if it's not GLGraphics2D. That would tell us painting is not being done into OpenGL.
But that's a work in progress...