I know this is not a new question and I did look through information I could find but this is still confusing. I would like to understand my options when it comes to thread management for JOGL.
Here are my options as I understand them so far:
- AWT mode. Basically, standard AWT event-based rendering model, where when some parameters of the model change I call .repaint and AWT thread calls .display. In this model I can still call .display as blocking, which detects that we are in a wrong thread and basically does an alternative or .repaint();.wait() and when display called from AWT (see above) finishes it sends a notify() to current thread. Or maybe this is not how it works but this is the basic effect.
Easy enough… - I can call Threading.disableSingleThreading() which… I am not really sure what it will do. Does it allow me to call GL instructions from my thread AND from AWT thread? In that case, if I do not add any listeners to the GLCanvas, am I safe putting my main loop in the current thread? Are there details on this mode anywhere?
- I can call Threading.invokeOnOpenGLThread(Runnable r). I am not sure what this does though. Will it call r only once (sort of like invokeLater())? It seems that by default (or in the current implementation) it is dropped into AWT thread so if I put my main loop there I will effectively lock rest of AWT. Would this be a correct assessment?
These are the options I see so far. Are these correct? What I want to do is the main loop as described in the User’s Guide. The problem with having main loop in one thread and invoking GLCanvas.display in it is that this is not the only way to initiate repaint and I am not sure what other conditions I need to cover (window gets focus, window is resized, another window moves so that this window is now visible, etc.). I want to make sure my rending does not start while I am updating the scene. Is N2 my only/best option?