public class GLAutoDrawableDelegate extends jogamp.opengl.GLAutoDrawableBase implements GLAutoDrawable
GLAutoDrawable
implementation
utilizing already created GLDrawable
and GLContext
instances.
Since no native windowing system events are being processed, it is recommended
to handle at least the window events
:
repaint
using windowRepaintOp()
resize
using #windowResizedOp()
custom toolkit destruction
issuing windowDestroyNotifyOp()
.
See example TestGLAutoDrawableDelegateNEWT
.
OpenGL Context Sharing
To share a GLContext
see the following note in the documentation overview:
context sharing
as well as GLSharedContextSetter
.
GLStateKeeper.Listener
SCREEN_CHANGE_ACTION_ENABLED
DEFAULT_FRAMES_PER_INTERVAL
Constructor and Description |
---|
GLAutoDrawableDelegate(GLDrawable drawable,
GLContext context,
Object upstreamWidget,
boolean ownDevice,
RecursiveLock lock)
The
GLContext can be assigned later manually via setContext(ctx)
or it will be created lazily at the 1st display() method call.Lazy GLContext creation will take a shared GLContext into account
which has been set directly
or via another GLAutoDrawable . |
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. |
RecursiveLock |
getUpstreamLock()
Returns the recursive lock object of the
upstream widget
to synchronize multithreaded access on top of NativeSurface.lockSurface() . |
Object |
getUpstreamWidget()
Method may return the upstream UI toolkit object
holding this
GLAutoDrawable instance, if exist. |
void |
setUpstreamWidget(Object newUpstreamWidget)
Set the upstream UI toolkit object.
|
void |
swapBuffers()
Swaps the front and back buffers of this drawable.
|
String |
toString() |
void |
windowDestroyNotifyOp()
Implementation to handle destroy notifications from the windowing system.
|
void |
windowRepaintOp()
Default implementation to handle repaint events from the windowing system
|
void |
windowResizedOp(int newWidth,
int newHeight)
Handling resize events from the windowing system.
|
addGLEventListener, addGLEventListener, areAllGLEventListenerInitialized, clearPreservedGLState, createContext, defaultSwapBuffers, disposeGLEventListener, flushGLRunnables, getAnimator, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getFPSStartTime, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, getGLProfile, getHandle, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getNativeSurface, getPreservedGLState, getRequestedGLCapabilities, getSurfaceHeight, getSurfaceWidth, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, invoke, invoke, isGLOriented, isGLStatePreservationSupported, isRealized, isThreadGLCapable, preserveGLStateAtDestroy, removeGLEventListener, resetFPSCounter, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState, setGLStateKeeperListener, setRealized, setSharedAutoDrawable, setSharedContext, setUpdateFPSFrames
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
addGLEventListener, addGLEventListener, areAllGLEventListenerInitialized, createContext, disposeGLEventListener, flushGLRunnables, getAnimator, getAutoSwapBufferMode, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, invoke, invoke, isThreadGLCapable, removeGLEventListener, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState
getChosenGLCapabilities, getGLProfile, getHandle, getNativeSurface, getRequestedGLCapabilities, getSurfaceHeight, getSurfaceWidth, isGLOriented, isRealized, setRealized
public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice, RecursiveLock lock)
The GLContext
can be assigned later manually via setContext(ctx)
or it will be created lazily at the 1st display()
method call.
Lazy GLContext
creation will take a shared GLContext
into account
which has been set directly
or via another GLAutoDrawable
.
drawable
- a valid GLDrawable
, may not be realized
yet.context
- a valid GLContext
,
may not have been made current (created) yet,
may not be associated w/ drawable yet,
may be null
for lazy initialization at 1st display()
.
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.lock
- optional custom RecursiveLock
.public final void windowRepaintOp()
public final void windowResizedOp(int newWidth, int newHeight)
Implementation:
the GLDrawable
, if offscreen,reshape events
, anddisplay()
call, if no animator is present.All required locks are being claimed.
newWidth
- new width in pixel unitsnewWidth
- new height in pixel unitspublic final void windowDestroyNotifyOp()
If the NativeSurface
does not implement WindowClosingProtocol
or WindowClosingProtocol.WindowClosingMode.DISPOSE_ON_CLOSE
is enabled (default),
a thread safe destruction is being induced.
public final RecursiveLock getUpstreamLock()
GLAutoDrawable
upstream widget
to synchronize multithreaded access on top of NativeSurface.lockSurface()
.
getUpstreamLock
in interface GLAutoDrawable
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 | com.jogamp.newt.opengl.GLWindow | has a | com.jogamp.newt.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.
getUpstreamWidget
in interface GLAutoDrawable
public final void setUpstreamWidget(Object newUpstreamWidget)
getUpstreamWidget()
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 destroyImplInLock()
.
destroy
in interface GLAutoDrawable
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(com.jogamp.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.
display
in interface GLAutoDrawable
GLAutoDrawable.setAnimator(com.jogamp.opengl.GLAnimatorControl)
public final GLDrawableFactory getFactory()
GLDrawable
GLDrawableFactory
being used to create this instance.getFactory
in interface GLDrawable
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.swapBuffers
in interface GLDrawable
GLException
public String toString()
toString
in interface GLDrawable
toString
in class jogamp.opengl.GLAutoDrawableBase
Copyright 2010 JogAmp Community.