|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Canvas
net.java.games.jogl.GLCanvas
A heavyweight AWT component which provides OpenGL rendering
support. This is the primary implementation of GLDrawable
;
GLJPanel
is provided for compatibility with Swing user
interfaces when adding a heavyweight doesn't work either because
of Z-ordering or LayoutManager problems. This class can not be
instantiated directly; use GLDrawableFactory
to construct
them.
Nested Class Summary |
Nested classes inherited from class java.awt.Canvas |
Canvas.AccessibleAWTCanvas |
Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
protected static boolean |
DEBUG
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Method Summary | |
void |
addGLEventListener(GLEventListener listener)
Adds a GLEventListener to this drawable. |
void |
addNotify()
Overridden from Canvas; used to indicate when it's safe to create an OpenGL context for the component. |
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 |
display()
Causes OpenGL rendering to be performed for this GLDrawable by calling GLEventListener.display(net.java.games.jogl.GLDrawable) for all registered
GLEventListener s. |
boolean |
getAutoSwapBufferMode()
Indicates whether automatic buffer swapping is enabled for this drawable. |
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. |
void |
paint(Graphics g)
Overridden from Canvas; calls display() . |
void |
removeGLEventListener(GLEventListener listener)
Removes a GLEventListener from this drawable. |
void |
removeNotify()
Overridden from Canvas; used to indicate that it's no longer safe to have an OpenGL context for the component. |
void |
reshape(int x,
int y,
int width,
int height)
Overridden from Canvas; causes GLDrawableHelper.reshape(net.java.games.jogl.GLDrawable, int, int, int, int)
to be called on all registered GLEventListener s. |
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 noAutoRedraw)
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 |
swapBuffers()
Swaps the front and back buffers of this drawable. |
void |
update(Graphics g)
Overridden from Canvas to prevent Java2D's clearing of the canvas from interfering with the OpenGL rendering. |
Methods inherited from class java.awt.Canvas |
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.java.games.jogl.GLDrawable |
getSize, getSize, setSize, setSize |
Field Detail |
protected static final boolean DEBUG
Method Detail |
public void display()
GLDrawable
GLEventListener.display(net.java.games.jogl.GLDrawable)
for all registered
GLEventListener
s. Called automatically by the window
system toolkit upon receiving a repaint() request. When used in
conjunction with GLDrawable.setRenderingThread(java.lang.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(net.java.games.jogl.GLDrawable)
.
display
in interface GLDrawable
public void paint(Graphics g)
display()
. Should not be
invoked by applications directly.
public void addNotify()
public void removeNotify()
public void reshape(int x, int y, int width, int height)
GLDrawableHelper.reshape(net.java.games.jogl.GLDrawable, int, int, int, int)
to be called on all registered GLEventListener
s. Called
automatically by the AWT; should not be invoked by applications
directly.
public void update(Graphics g)
public void addGLEventListener(GLEventListener listener)
GLDrawable
GLEventListener
to this drawable. If multiple
listeners are added to a given drawable, they are notified of
events in an arbitrary order.
addGLEventListener
in interface GLDrawable
public void removeGLEventListener(GLEventListener listener)
GLDrawable
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
public GL getGL()
GLDrawable
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
public void setGL(GL gl)
GLDrawable
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
public GLU getGLU()
GLDrawable
GLU
pipeline object this GLDrawable uses.
getGLU
in interface GLDrawable
public void setGLU(GLU glu)
GLDrawable
GLU
pipeline object this GLDrawable uses.
setGLU
in interface GLDrawable
public void setRenderingThread(Thread currentThreadOrNull) throws GLException
GLDrawable
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 nullpublic Thread getRenderingThread()
GLDrawable
getRenderingThread
in interface GLDrawable
public void setNoAutoRedrawMode(boolean noAutoRedraw)
GLDrawable
GLDrawable.setRenderingThread(java.lang.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
public boolean getNoAutoRedrawMode()
GLDrawable
getNoAutoRedrawMode
in interface GLDrawable
public void setAutoSwapBufferMode(boolean onOrOff)
GLDrawable
GLDrawable.swapBuffers()
manually.
setAutoSwapBufferMode
in interface GLDrawable
public boolean getAutoSwapBufferMode()
GLDrawable
GLDrawable.setAutoSwapBufferMode(boolean)
.
getAutoSwapBufferMode
in interface GLDrawable
public void swapBuffers()
GLDrawable
swapBuffers
in interface GLDrawable
public boolean canCreateOffscreenDrawable()
GLDrawable
canCreateOffscreenDrawable
in interface GLDrawable
public GLPbuffer createOffscreenDrawable(GLCapabilities capabilities, int initialWidth, int initialHeight)
GLDrawable
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |