public class GLAutoDrawableDelegate
extends jogamp.opengl.GLAutoDrawableBase
GLAutoDrawable
implementation
utilizing already created created GLDrawable
and GLContext
instances.
Since no native windowing system events are being processed, it is recommended to handle at least:
repaint
using GLAutoDrawableBase.defaultWindowRepaintOp()
resize
using GLAutoDrawableBase.defaultWindowResizedOp()
destroy-notify
using GLAutoDrawableBase.defaultWindowDestroyNotifyOp()
See example TestGLAutoDrawableDelegateNEWT
.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
SCREEN_CHANGE_ACTION_ENABLED
DEFAULT_FRAMES_PER_INTERVAL
Constructor and Description |
---|
GLAutoDrawableDelegate(GLDrawable drawable,
GLContext context,
Object upstreamWidget,
boolean ownDevice) |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroys all resources associated with this GLAutoDrawable,
inclusive the GLContext.
|
void |
display()
Causes OpenGL rendering to be performed for this GLAutoDrawable
in the following order:
Calling
display(..) for all
registered GLEventListener s. |
GLDrawableFactory |
getFactory()
Return the
GLDrawableFactory being used to create this instance. |
Object |
getUpstreamWidget()
Method may return the upstream UI toolkit object
holding this
GLAutoDrawable instance, if exist. |
void |
setRealized(boolean realized)
Indicates to on-screen GLDrawable implementations whether the
underlying window has been created and can be drawn into.
|
void |
swapBuffers()
Swaps the front and back buffers of this drawable.
|
void |
windowDestroyNotifyOp() |
void |
windowRepaintOp() |
void |
windowResizedOp() |
addGLEventListener, addGLEventListener, createContext, defaultSwapBuffers, getAnimator, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getContextCreationFlags, getDelegatedDrawable, getFPSStartTime, getGL, getGLProfile, getHandle, getHeight, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getNativeSurface, getSkipContextReleaseThread, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, getWidth, invoke, isRealized, removeGLEventListener, removeGLEventListener, resetFPSCounter, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setGL, setSkipContextReleaseThread, setUpdateFPSFrames
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toString
public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice)
drawable
- a valid GLDrawable
, may not be realized yet.context
- a valid GLContext
, may not be made current (created) yet.upstreamWidget
- optional UI element holding this instance, see getUpstreamWidget()
.ownDevice
- pass true
if AbstractGraphicsDevice.close()
shall be issued,
otherwise pass false
. Closing the device is required in case
the drawable is created w/ it's own new instance, e.g. offscreen drawables,
and no further lifecycle handling is applied.public final void windowRepaintOp()
public final void windowResizedOp()
public final void windowDestroyNotifyOp()
public final Object getUpstreamWidget()
GLAutoDrawable
GLAutoDrawable
instance, if exist.
Currently known Java UI toolkits and it's known return types are:
Toolkit | GLAutoDrawable Implementation | ~ | Return Type of getUpstreamWidget() |
NEWT | GLWindow | has a | Window |
SWT | GLCanvas | is a | Canvas |
AWT | GLCanvas | is a | Canvas |
AWT | GLJPanel | is a | JPanel |
This method may also return null
if no UI toolkit is being used,
as common for offscreen rendering.
public final void destroy()
dispose(..)
for all
registered GLEventListener
s. Called automatically by the
window system toolkit upon receiving a destroy notification. This
routine may be called manually.
This implementation calls GLAutoDrawableBase.defaultDestroy()
.
User still needs to destroy the upstream window, which details are hidden from this aspect.
This can be performed by overriding GLAutoDrawableBase.destroyImplInLock()
.
public void display()
GLAutoDrawable
Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:
display(..)
for all
registered GLEventListener
s. GLRunnable
,
enqueued via GLAutoDrawable.invoke(boolean, GLRunnable)
.
May be called periodically by a running GLAnimatorControl
implementation,
which must register itself with GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl)
.
Called automatically by the window system toolkit upon receiving a repaint() request,
except an GLAnimatorControl
implementation GLAnimatorControl.isAnimating()
.
This routine may also 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.
In case of a new generated OpenGL context,
the implementation shall call init(..)
for all
registered GLEventListener
s before making the
actual display(..)
calls,
in case this has not been done yet.
public final GLDrawableFactory getFactory()
GLDrawable
GLDrawableFactory
being used to create this instance.public final void setRealized(boolean realized)
GLDrawable
setRealized
on a GLCanvas, a GLJPanel, or a
GLPbuffer, as these perform the appropriate calls on their
underlying GLDrawables internally.
Developers implementing new OpenGL components for various window
toolkits need to call this method against GLDrawables obtained
from the GLDrawableFactory via the GLDrawableFactory.getGLDrawable()
method. It must typically be
called with an argument of true
when the component
associated with the GLDrawable is realized and with an argument
of false
just before the component is unrealized.
For the AWT, this means calling setRealized(true)
in
the addNotify
method and with an argument of
false
in the removeNotify
method.
GLDrawable
implementations should handle multiple
cycles of setRealized(true)
/
setRealized(false)
calls. Most, if not all, Java
window toolkits have a persistent object associated with a given
component, regardless of whether that component is currently
realized. The GLDrawable
object associated with a
particular component is intended to be similarly persistent. A
GLDrawable
is intended to be created for a given
component when it is constructed and live as long as that
component. setRealized
allows the
GLDrawable
to re-initialize and destroy any
associated resources as the component becomes realized and
unrealized, respectively.
With an argument of true
,
the minimum implementation shall call
NativeSurface's lockSurface()
and if successfull:
GLCapabilities
, which are associated with
the attached NativeSurface
's AbstractGraphicsConfiguration
.NativeSurface's unlockSurface()
.NativeSurface's lockSurface()
ensures resolving the window/surface handles, and the drawable's GLCapabilities
might have changed.
Calling this method has no other effects. For example, if
removeNotify
is called on a Canvas implementation
for which a GLDrawable has been created, it is also necessary to
destroy all OpenGL contexts associated with that GLDrawable. This
is not done automatically by the implementation.
public final void swapBuffers() throws GLException
GLDrawable
GLAutoDrawable
implementations, when automatic buffer swapping
is enabled (as is the default), this method is called
automatically and should not be called by the end user.GLException
Copyright 2010 JogAmp Community.