Login  Register

Re: JOGL Questions - Guidance on creating Scene class

Posted by gouessej on Oct 29, 2015; 4:26pm
URL: https://forum.jogamp.org/JOGL-Questions-Guidance-on-creating-Scene-class-tp4035659p4035666.html

elect wrote
3) GLContext.getCurrent().getGL() should be fine. Anyway I always tend to grab the GL object from the display() in order to minimize any potential bug, since OpenGL is a state machine this makes easier to monitor/debug the order of the gl commands.
Storing the GL instance into a field or a non-local variable is a bad practice. I already explained why numerous times here. You might accidentally use an invalidated instance and it is really hard to detect. I advise you and others to use GLContext.getCurrent().getGL() as much as possible. You can store a GL instance in a local variable but you should avoid passing it to another method or storing it into a field.
Julien Gouesse | Personal blog | Website