OpenGL & createComponentSnapshot


#1

We tested our plugins with the OpenGL renderer but ran into occasional crashes during createComponentSnapshot() calls. My understanding is that this is caused by OpenGL being rendered on a different thread while the createComponentSnapshot() calls most likely appear on the main thread.

Is there a save way to call createComponentSnapshot() when using OpenGL?
I think I could get rid of it in several places where I’d prefere another approach anyway but it is for example also used to create the drag image for drag & drop.
I had a look whether an OpenGL lock is available but neither found one nor do I think this would be be the best idea as it might create a dead lock.


#2

Hmm, yes, there would be issues if you try calling that method. And not really sure what a good workaround would be for it. The nature of GL means that it could only possibly be rendered on the openGL thread itself, so perhaps you might get away with calling it if you were to call it from inside a paint() callback (yuck!)

If you can do it, then the best way to do it would be to manually draw your GL content into an Image during the paint callback, which is really the only safe time to do GL stuff.


#3

Would it be possible to have the snapshot rendered using the software renderer if the image created in createComponentSnapshot() would use SoftwareImageType?

I tried this and had a look with the debugger but gave up after stepping through various Graphics methods without reaching anything near the actual renderer.


#4

Yes, absoutely. But you'd need to detach the component from the GL renderer first.