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.
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.
- 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.
- 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.
- 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.
- destroy in interface GLPbuffer
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.
- 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.
- getGL in interface GLDrawable
getNoAutoRedrawMode
public boolean getNoAutoRedrawMode()
Returns whether automatic redraws are disabled for this
drawable. Defaults to false.
- getNoAutoRedrawMode in interface GLDrawable
getRenderingThread
public Thread getRenderingThread()
Returns the rendering thread for this drawable, or null if none
has been set.
- getRenderingThread in interface GLDrawable
getSize
public Dimension getSize()
Returns the size of this GLDrawable as a newly-created Dimension
object.
- 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.
- getSize in interface GLDrawable
isInitialized
public boolean isInitialized()
Queries initialization status of this pBuffer.
- isInitialized in interface GLPbuffer
releaseTexture
public void releaseTexture()
Unbinds the pbuffer from its internal texture target.
- releaseTexture in interface GLPbuffer
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.
- removeGLEventListener in interface GLDrawable
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.
- 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.
- setGL in interface GLDrawable
setGLU
public void setGLU(GLU glu)
Sets the
GLU
pipeline object this GLDrawable uses.
- 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.
- 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.
- setRenderingThread in interface GLDrawable
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.
- setSize in interface GLDrawable
setSize
public void setSize(int width,
int height)
Sets the size of this GLDrawable.
- 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.
- swapBuffers in interface GLDrawable