To create a JOGL program, it is required to understand the following interfaces: -
- GLEventListener interface
- GLAutodrawable interface
JOGL GLEventListener Interface
GLEventListener interface is present in javax.media.opengl package. It provides an event based mechanism that performs OpenGL rendering. To inherit the functionality of graphics in a program, it is required to implement this interface.
These are the four important methods of GLEventListner interface. It is mandatory to override all these methods.
|void display(GLAutoDrawable drawable)
||It is called by GLAutoDrawable object to initiate OpenGL rendering by the client.
|void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
||It is called by GLAutoDrawable object when the display mode or device associate with it has changed.
|void init(GLAutoDrawable drawable)
||It is called by GLAutoDrawable object immediately after the OpenGL context is initialized.
|void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
||It is called by GLAutoDrawable object during the first repaint.
JOGL GLAutoDrawable Interface
GLEventListener interface is present in javax.media.opengl package. The purpose of this interface is to provide an event based mechanism (GLEventListener) to generate an image.
Following are the frequently used GLAutoDrawable methods: -
|void addGLEventListener(GLEventListener listener)
||It adds the object of GLEventListener to the end of drawable queue.
||It returns the context associated with drawable.
||It removes all the resources associated with GLAutoDrawable.
||It specifies whether The current thread is capable of performing OpenGL related work