A little background:
I decided to use active rendering for an application I’ve been working on. This application has an abstract notion of various types of render surfaces (e.g. fullscreen, window, or a texture). For this, I made the assumption that “buffer swapping” on these surfaces could be done before they were completely released from my rendering thread.
This caused the following situation:
- render into an onscreen GLCanvas in my active thread
- call swapBuffers on the canvas
- that method realizes its not on the AWT thread and tries to execute swapBuffers there
- when executing on the AWT thread, it realizes that it isn’t current there and tries to fix that
- since the canvas is still current on my thread, that call deadblocks
I got around it by calling Threading.disableSingleThreading(), but I really don’t like relying on this since the documentation is very scary about consequences. How dangerous is disabling single threading now? and are there better ways to handle swapping buffers in active rendering? (the example from Pro Java Game Programming does it this way and doesn’t mention any problems or should I just assume that it’s unsafe in general to call swapBuffers() while the canvas is still current?
Thanks, and sorry for the long question.