javax.media.opengl
Interface GLAutoDrawable

All Superinterfaces:
ComponentEvents, GLDrawable
All Known Subinterfaces:
GLPbuffer
All Known Implementing Classes:
GLCanvas, GLJPanel

public interface GLAutoDrawable
extends GLDrawable, ComponentEvents

A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) for performing OpenGL rendering. A GLAutoDrawable automatically creates a primary rendering context which is associated with the GLAutoDrawable for the lifetime of the object. This context has the synchronized property enabled so that calls to makeCurrent will block if the context is current on another thread. This allows the internal GLContext for the GLAutoDrawable to be used both by the event based rendering mechanism as well by end users directly.


Method Summary
 void addGLEventListener(GLEventListener listener)
          Adds a GLEventListener to this drawable.
 void display()
          Causes OpenGL rendering to be performed for this GLAutoDrawable by calling display for all registered GLEventListeners.
 boolean getAutoSwapBufferMode()
          Indicates whether automatic buffer swapping is enabled for this drawable.
 GLContext getContext()
          Returns the context associated with this drawable.
 GL getGL()
          Returns the GL pipeline object this GLAutoDrawable uses.
 void removeGLEventListener(GLEventListener listener)
          Removes a GLEventListener from this drawable.
 void repaint()
          Schedules a repaint of the component at some point in the future.
 void setAutoSwapBufferMode(boolean onOrOff)
          Enables or disables automatic buffer swapping for this drawable.
 void setGL(GL gl)
          Sets the GL pipeline object this GLAutoDrawable uses.
 
Methods inherited from interface javax.media.opengl.GLDrawable
createContext, getHeight, getWidth, setRealized, setSize, swapBuffers
 
Methods inherited from interface javax.media.opengl.ComponentEvents
addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener
 

Method Detail

getContext

public GLContext getContext()
Returns the context associated with this drawable. The returned context will be synchronized.


addGLEventListener

public void addGLEventListener(GLEventListener listener)
Adds a GLEventListener to this drawable. If multiple listeners are added to a given drawable, they are notified of events in an arbitrary order.


removeGLEventListener

public void removeGLEventListener(GLEventListener listener)
Removes a GLEventListener from this drawable. Note that if this is done from within a particular drawable's GLEventListener handler (reshape, display, etc.) that it is not guaranteed that all other listeners will be evaluated properly during this update cycle.


display

public void display()
Causes OpenGL rendering to be performed for this GLAutoDrawable by calling display for all registered GLEventListeners. Called automatically by the window system toolkit upon receiving a repaint() request. this routine may be called manually for better control over the rendering process. It is legal to call another GLAutoDrawable's display method from within the display callback.


repaint

public void repaint()
Schedules a repaint of the component at some point in the future.


setAutoSwapBufferMode

public void setAutoSwapBufferMode(boolean onOrOff)
Enables or disables automatic buffer swapping for this drawable. By default this property is set to true; when true, after all GLEventListeners have been called for a display() event, the front and back buffers are swapped, displaying the results of the render. When disabled, the user is responsible for calling GLDrawable.swapBuffers() manually.


getAutoSwapBufferMode

public boolean getAutoSwapBufferMode()
Indicates whether automatic buffer swapping is enabled for this drawable. See setAutoSwapBufferMode(boolean).


getGL

public GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses. If this method is called outside of the GLEventListener's callback methods (init, display, etc.) it may return null. Users should not rely on the identity of the returned GL object; for example, users should not maintain a hash table with the GL object as the key. Additionally, the GL object should not be cached in client code, but should be re-fetched from the GLAutoDrawable at the beginning of each call to init, display, etc.


setGL

public void setGL(GL gl)
Sets the GL pipeline object this GLAutoDrawable uses. This should only be called from within the GLEventListener's callback methods, and usually only from within the init() method, in order to install a composable pipeline. See the JOGL demos for examples.



Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.