net.java.games.jogl.impl

Class GLPbufferImpl

Implemented Interfaces:
ComponentEvents, GLDrawable, GLPbuffer

public class GLPbufferImpl
extends java.lang.Object
implements GLPbuffer

Platform-independent class exposing pbuffer functionality to applications. This class is not exposed in the public API as it would probably add no value; however it implements the GLDrawable interface so can be interacted with via its display() method.

Fields inherited from interface net.java.games.jogl.GLPbuffer

APPLE_FLOAT, ATI_FLOAT, NV_FLOAT

Constructor Summary

GLPbufferImpl(GLContext context)

Method Summary

void
addComponentListener(ComponentListener l)
void
addFocusListener(FocusListener l)
void
addGLEventListener(GLEventListener listener)
Adds a GLEventListener to this drawable.
void
addHierarchyBoundsListener(HierarchyBoundsListener l)
void
addHierarchyListener(HierarchyListener l)
void
addInputMethodListener(InputMethodListener l)
void
addKeyListener(KeyListener l)
void
addMouseListener(MouseListener l)
void
addMouseMotionListener(MouseMotionListener l)
void
addMouseWheelListener(MouseWheelListener l)
void
addPropertyChangeListener(PropertyChangeListener listener)
void
addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
void
bindTexture()
Binds this pbuffer to its internal texture target.
boolean
canCreateOffscreenDrawable()
Indicates whether this drawable is capable of fabricating a subordinate offscreen drawable for advanced rendering techniques which require offscreen hardware-accelerated surfaces.
GLPbuffer
createOffscreenDrawable(GLCapabilities capabilities, int initialWidth, int initialHeight)
Creates a subordinate offscreen drawable (pbuffer) for this drawable.
void
destroy()
Destroys the native resources associated with this pbuffer.
void
display()
Causes OpenGL rendering to be performed for this GLDrawable by calling GLEventListener.display(GLDrawable) for all registered GLEventListeners.
boolean
getAutoSwapBufferMode()
Indicates whether automatic buffer swapping is enabled for this drawable.
GLContext
getContext()
int
getFloatingPointMode()
Indicates which vendor's extension is being used to support floating point channels in this pbuffer if that capability was requested in the GLCapabilities during pbuffer creation.
GL
getGL()
Returns the GL pipeline object this GLDrawable uses.
GLU
getGLU()
Returns the GLU pipeline object this GLDrawable uses.
boolean
getNoAutoRedrawMode()
Returns whether automatic redraws are disabled for this drawable.
Thread
getRenderingThread()
Returns the rendering thread for this drawable, or null if none has been set.
Dimension
getSize()
Returns the size of this GLDrawable as a newly-created Dimension object.
Dimension
getSize(Dimension d)
Stores the size of this GLDrawable into the user-provided Dimension object, returning that object.
boolean
isInitialized()
Queries initialization status of this pBuffer.
void
releaseTexture()
Unbinds the pbuffer from its internal texture target.
void
removeComponentListener(ComponentListener l)
void
removeFocusListener(FocusListener l)
void
removeGLEventListener(GLEventListener listener)
Removes a GLEventListener from this drawable.
void
removeHierarchyBoundsListener(HierarchyBoundsListener l)
void
removeHierarchyListener(HierarchyListener l)
void
removeInputMethodListener(InputMethodListener l)
void
removeKeyListener(KeyListener l)
void
removeMouseListener(MouseListener l)
void
removeMouseMotionListener(MouseMotionListener l)
void
removeMouseWheelListener(MouseWheelListener l)
void
removePropertyChangeListener(PropertyChangeListener listener)
void
removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
void
setAutoSwapBufferMode(boolean onOrOff)
Enables or disables automatic buffer swapping for this drawable.
void
setGL(GL gl)
Sets the GL pipeline object this GLDrawable uses.
void
setGLU(GLU glu)
Sets the GLU pipeline object this GLDrawable uses.
void
setNoAutoRedrawMode(boolean noAutoRedraws)
Disables automatic redraws of this drawable if possible.
void
setRenderingThread(Thread currentThreadOrNull)
Changes this GLDrawable to allow OpenGL rendering only from the supplied thread, which must either be the current thread or null.
void
setSize(Dimension d)
Sets the size of this GLDrawable.
void
setSize(int width, int height)
Sets the size of this GLDrawable.
void
swapBuffers()
Swaps the front and back buffers of this drawable.

Constructor Details

GLPbufferImpl

public GLPbufferImpl(GLContext context)

Method Details

addComponentListener

public void addComponentListener(ComponentListener l)
Specified by:
addComponentListener in interface ComponentEvents

addFocusListener

public void addFocusListener(FocusListener l)
Specified by:
addFocusListener in interface ComponentEvents

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.
Specified by:
addGLEventListener in interface GLDrawable

addHierarchyBoundsListener

public void addHierarchyBoundsListener(HierarchyBoundsListener l)
Specified by:
addHierarchyBoundsListener in interface ComponentEvents

addHierarchyListener

public void addHierarchyListener(HierarchyListener l)
Specified by:
addHierarchyListener in interface ComponentEvents

addInputMethodListener

public void addInputMethodListener(InputMethodListener l)
Specified by:
addInputMethodListener in interface ComponentEvents

addKeyListener

public void addKeyListener(KeyListener l)
Specified by:
addKeyListener in interface ComponentEvents

addMouseListener

public void addMouseListener(MouseListener l)
Specified by:
addMouseListener in interface ComponentEvents

addMouseMotionListener

public void addMouseMotionListener(MouseMotionListener l)
Specified by:
addMouseMotionListener in interface ComponentEvents

addMouseWheelListener

public void addMouseWheelListener(MouseWheelListener l)
Specified by:
addMouseWheelListener in interface ComponentEvents

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface ComponentEvents

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface ComponentEvents

bindTexture

public void bindTexture()
Binds this pbuffer to its internal texture target. Only valid to call if offscreen render-to-texture has been specified in the GLCapabilities for this GLPbuffer. If the render-to-texture-rectangle capability has also been specified, this will use e.g. wglBindTexImageARB as its implementation and cause the texture to be bound to e.g. the GL_TEXTURE_RECTANGLE_NV state; otherwise, during the display() phase the pixels will have been copied into an internal texture target and this will cause that to be bound to the GL_TEXTURE_2D state.
Specified by:
bindTexture in interface GLPbuffer

canCreateOffscreenDrawable

public boolean canCreateOffscreenDrawable()
Indicates whether this drawable is capable of fabricating a subordinate offscreen drawable for advanced rendering techniques which require offscreen hardware-accelerated surfaces. Note that this method is only guaranteed to return a correct result once your GLEventListener's init() method has been called.
Specified by:
canCreateOffscreenDrawable in interface GLDrawable

createOffscreenDrawable

public GLPbuffer createOffscreenDrawable(GLCapabilities capabilities,
                                         int initialWidth,
                                         int initialHeight)
Creates a subordinate offscreen drawable (pbuffer) for this drawable. This routine should only be called if GLDrawable.canCreateOffscreenDrawable() returns true. The passed capabilities are matched according to the platform-dependent pbuffer format selection algorithm, which currently can not be overridden.
Specified by:
createOffscreenDrawable in interface GLDrawable

destroy

public void destroy()
Destroys the native resources associated with this pbuffer. It is not valid to call display() or any other routines on this pbuffer after it has been destroyed.
Specified by:
destroy in interface GLPbuffer

display

public void display()
Causes OpenGL rendering to be performed for this GLDrawable by calling GLEventListener.display(GLDrawable) for all registered GLEventListeners. Called automatically by the window system toolkit upon receiving a repaint() request. When used in conjunction with GLDrawable.setRenderingThread(Thread), this routine may be called manually by the application's main loop for higher performance and better control over the rendering process. It is legal to call another GLDrawable's display method from within GLEventListener.display(GLDrawable).
Specified by:
display in interface GLDrawable

getAutoSwapBufferMode

public boolean getAutoSwapBufferMode()
Specified by:
getAutoSwapBufferMode in interface GLDrawable

getContext

public GLContext getContext()

getFloatingPointMode

public int getFloatingPointMode()
Indicates which vendor's extension is being used to support floating point channels in this pbuffer if that capability was requested in the GLCapabilities during pbuffer creation. Returns one of NV_FLOAT, ATI_FLOAT or APPLE_FLOAT, or throws GLException if floating-point channels were not requested for this pbuffer. This function may only be called once the init method for this pbuffer's GLEventListener has been called.
Specified by:
getFloatingPointMode in interface GLPbuffer

getGL

public GL getGL()
Returns the GL pipeline object this GLDrawable 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 GLDrawable at the beginning of each call to init, display, etc.
Specified by:
getGL in interface GLDrawable

getGLU

public GLU getGLU()
Returns the GLU pipeline object this GLDrawable uses.
Specified by:
getGLU in interface GLDrawable

getNoAutoRedrawMode

public boolean getNoAutoRedrawMode()
Returns whether automatic redraws are disabled for this drawable. Defaults to false.
Specified by:
getNoAutoRedrawMode in interface GLDrawable

getRenderingThread

public Thread getRenderingThread()
Returns the rendering thread for this drawable, or null if none has been set.
Specified by:
getRenderingThread in interface GLDrawable

getSize

public Dimension getSize()
Returns the size of this GLDrawable as a newly-created Dimension object.
Specified by:
getSize in interface GLDrawable

getSize

public Dimension getSize(Dimension d)
Stores the size of this GLDrawable into the user-provided Dimension object, returning that object. If the provided Dimension is null a new one will be allocated and returned.
Specified by:
getSize in interface GLDrawable

isInitialized

public boolean isInitialized()
Queries initialization status of this pBuffer.
Specified by:
isInitialized in interface GLPbuffer
Returns:
true if initialized

releaseTexture

public void releaseTexture()
Unbinds the pbuffer from its internal texture target.
Specified by:
releaseTexture in interface GLPbuffer

removeComponentListener

public void removeComponentListener(ComponentListener l)
Specified by:
removeComponentListener in interface ComponentEvents

removeFocusListener

public void removeFocusListener(FocusListener l)
Specified by:
removeFocusListener in interface ComponentEvents

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.
Specified by:
removeGLEventListener in interface GLDrawable

removeHierarchyBoundsListener

public void removeHierarchyBoundsListener(HierarchyBoundsListener l)
Specified by:
removeHierarchyBoundsListener in interface ComponentEvents

removeHierarchyListener

public void removeHierarchyListener(HierarchyListener l)
Specified by:
removeHierarchyListener in interface ComponentEvents

removeInputMethodListener

public void removeInputMethodListener(InputMethodListener l)
Specified by:
removeInputMethodListener in interface ComponentEvents

removeKeyListener

public void removeKeyListener(KeyListener l)
Specified by:
removeKeyListener in interface ComponentEvents

removeMouseListener

public void removeMouseListener(MouseListener l)
Specified by:
removeMouseListener in interface ComponentEvents

removeMouseMotionListener

public void removeMouseMotionListener(MouseMotionListener l)
Specified by:
removeMouseMotionListener in interface ComponentEvents

removeMouseWheelListener

public void removeMouseWheelListener(MouseWheelListener l)
Specified by:
removeMouseWheelListener in interface ComponentEvents

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface ComponentEvents

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface ComponentEvents

setAutoSwapBufferMode

public void setAutoSwapBufferMode(boolean onOrOff)
Specified by:
setAutoSwapBufferMode in interface GLDrawable

setGL

public void setGL(GL gl)
Sets the GL pipeline object this GLDrawable 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.
Specified by:
setGL in interface GLDrawable

setGLU

public void setGLU(GLU glu)
Sets the GLU pipeline object this GLDrawable uses.
Specified by:
setGLU in interface GLDrawable

setNoAutoRedrawMode

public void setNoAutoRedrawMode(boolean noAutoRedraws)
Disables automatic redraws of this drawable if possible. This is provided as an overriding mechanism for applications which perform animation on the drawable and for which the (currently advisory) GLDrawable.setRenderingThread(Thread) does not provide strict enough guarantees. Its sole purpose is to avoid deadlocks that are unfortunately all too easy to run into when both animating a drawable from a given thread as well as having updates performed by the AWT event thread (repaints, etc.). When it is enabled, repaint requests driven by the AWT will not result in the OpenGL event listeners' display methods being called from the AWT thread, unless (as with GLJPanel) this is the only mechanism by which repaints are done. The necessity of this API may be rethought in a future release. Defaults to false.
Specified by:
setNoAutoRedrawMode in interface GLDrawable

setRenderingThread

public void setRenderingThread(Thread currentThreadOrNull)
            throws GLException
Changes this GLDrawable to allow OpenGL rendering only from the supplied thread, which must either be the current thread or null. Attempts by other threads to perform OpenGL operations like rendering or resizing the window will be ignored as long as the thread is set. Setting up the rendering thread is not required but enables the system to perform additional optimizations, in particular when the application requires control over the rendering loop. Before exiting, setRenderingThread(null) must be called or other threads will be unable to perform OpenGL rendering to this drawable. Throws GLException if the rendering thread for this drawable has been set and attempts are made to set or clear the rendering thread from another thread, or if the passed thread is not equal to the current thread or null. Also throws GLException if the current thread attempts to call setRenderingThread on more than one drawable.

NOTE: Currently this routine is only advisory, which means that on some platforms the underlying optimizations are disabled and setting the rendering thread has no effect. Applications should not rely on setRenderingThread to prevent rendering from other threads.

Specified by:
setRenderingThread in interface GLDrawable
Throws:
GLException - if the rendering thread for this drawable has been set by another thread or if the passed thread is not equal to the current thread or null

setSize

public void setSize(Dimension d)
Sets the size of this GLDrawable.
Specified by:
setSize in interface GLDrawable

setSize

public void setSize(int width,
                    int height)
Sets the size of this GLDrawable.
Specified by:
setSize in interface GLDrawable

swapBuffers

public void swapBuffers()
Swaps the front and back buffers of this drawable. When automatic buffer swapping is enabled (as is the default), it is not necessary to call this method and doing so may have undefined results.
Specified by:
swapBuffers in interface GLDrawable