Re: Unpredictable GL Frame Awt Key Handler or gluLookAt
Posted by
Sven Gothel on
Aug 23, 2012; 11:46am
URL: https://forum.jogamp.org/Unpredictable-GL-Frame-Awt-Key-Handler-or-gluLookAt-tp4025788p4025874.html
On 08/22/2012 08:02 PM, Vincent [via jogamp] wrote:
> I was thinking about making a glu object global, but apparently it needs to be
> passed a drawable object. How can I pass the created glu instance to from the
> init loop to the render loop. I tried making the glu instance global but it
> must be passed the drawable object.
>
>
> private void render(GLAutoDrawable drawable) {
> GL2 gl = drawable.getGL().getGL2();
> GLU glu = GLU.createGLU(gl);
>
besides using a global instance,
you could attach it to the GL context like
and handle it's whole lifecycle as follows:
static final String glu_key = "my_glu_object" ;
init(GLAutoDrawable drawable):
GL2 gl = drawable.getGL().getGL2();
GLU glu = GLU.createGLU(gl);
gl.getContext().attachObject(glu_key, glu);
display(GLAutoDrawable drawable):
GL2 gl = drawable.getGL().getGL2();
GLU glu = (GLU) gl.getContext().getAttachedObject(glu_key);
dispose(GLAutoDrawable drawable):
GL2 gl = drawable.getGL().getGL2();
GLU glu = (GLU) gl.getContext().detachObject(glu_key);
glu.destroy();
~Sven