Top Description Fields Constructors Methods
com.jogamp.opengl

public Class GLAutoDrawableDelegate

extends GLAutoDrawableBase
implements GLAutoDrawable
Class Inheritance
All Implemented Interfaces
com.jogamp.opengl.GLAutoDrawable, com.jogamp.opengl.GLDrawable, com.jogamp.nativewindow.NativeSurfaceHolder
Known Direct Subclasses
jogamp.opengl.GLOffscreenAutoDrawableImpl
Imports
com.jogamp.nativewindow.AbstractGraphicsDevice, .NativeSurface, .WindowClosingProtocol, .WindowClosingProtocol.WindowClosingMode, com.jogamp.opengl.GLAutoDrawable, .GLContext, .GLDrawable, .GLDrawableFactory, .GLEventListener, .GLException, .GLSharedContextSetter, com.jogamp.common.util.locks.LockFactory, .RecursiveLock, jogamp.opengl.GLAutoDrawableBase, .GLContextImpl, .GLDrawableImpl

Fully functional 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:

and setup a 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.

Field Summary

Modifier and TypeField and Description
private final RecursiveLock
private Object
Inherited from jogamp.opengl.GLAutoDrawableBase:
additionalCtxCreationFlagscontextDEBUGdefaultDisplayActiondefaultInitActiondrawablefpsCounterglelsglStateKeeperListenerhelperownsDevicepreserveGLELSAtDestroysendDestroysendReshape

Constructor Summary

AccessConstructor and Description
public
GLAutoDrawableDelegate(final GLDrawable
a valid GLDrawable, may not be realized yet.
drawable
,
final GLContext
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().
context
,
final Object
optional UI element holding this instance, see getUpstreamWidget().
upstreamWidget
,
final boolean
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.
ownDevice
,
final RecursiveLock
optional custom RecursiveLock.
lock
)

The GLContext can be assigned later manually via setContext(ctx) or it will be created lazily at the 1st display() method call.

Method Summary

Modifier and TypeMethod and Description
public final void
destroy()

Implements com.jogamp.opengl.GLAutoDrawable.destroy.

Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
protected void
destroyImplInLock()

Overrides jogamp.opengl.GLAutoDrawableBase.destroyImplInLock.

Default implementation to destroys the drawable and context of this GLAutoDrawable:
  • issues the GLEventListener dispose call, if drawable and context are valid
  • destroys the GLContext, if valid
  • destroys the GLDrawable, if valid
public void
display()

Implements com.jogamp.opengl.GLAutoDrawable.display.

Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:

public final GLDrawableFactory
getFactory()

Implements com.jogamp.opengl.GLDrawable.getFactory.

Return the GLDrawableFactory being used to create this instance.
public final RecursiveLock
getUpstreamLock()

Implements com.jogamp.opengl.GLAutoDrawable.getUpstreamLock.

Returns the recursive lock object of the upstream widget to synchronize multithreaded access on top of NativeSurface#lockSurface().
public final Object
getUpstreamWidget()

Implements com.jogamp.opengl.GLAutoDrawable.getUpstreamWidget.

Method may return the upstream UI toolkit object holding this GLAutoDrawable instance, if exist.</td<></td<></td<></td<></td<>
public final void
setUpstreamWidget(final Object newUpstreamWidget)

Set the upstream UI toolkit object.

public final void
swapBuffers()

Implements com.jogamp.opengl.GLDrawable.swapBuffers.

Swaps the front and back buffers of this drawable.
public String
toString()

Overrides jogamp.opengl.GLAutoDrawableBase.toString.

Implements com.jogamp.opengl.GLDrawable.toString.

Returns a string representation of the object.
public final void
windowDestroyNotifyOp()

Implementation to handle destroy notifications from the windowing system.

public final void
windowRepaintOp()

Default implementation to handle repaint events from the windowing system

public final void
windowResizedOp(final int
  • new width in pixel units
  • new height in pixel units
newWidth
,
final int newHeight)

Handling resize events from the windowing system.

Inherited from jogamp.opengl.GLAutoDrawableBase:
addGLEventListeneraddGLEventListenerareAllGLEventListenerInitializedclearPreservedGLStatecreateContextdefaultDestroydefaultDisplaydefaultDisposeGLEventListenerdefaultSwapBuffersdefaultWindowDestroyNotifyOpdefaultWindowRepaintOpdefaultWindowResizedOpdestroyAvoidAwareOfLockingdisposeGLEventListenerflushGLRunnablesgetAnimatorgetAutoSwapBufferModegetChosenGLCapabilitiesgetContextgetContextCreationFlagsgetDelegatedDrawablegetExclusiveContextThreadgetFPSStartTimegetGLgetGLEventListenergetGLEventListenerCountgetGLEventListenerInitStategetGLProfilegetHandlegetLastFPSgetLastFPSPeriodgetLastFPSUpdateTimegetNativeSurfacegetPreservedGLStategetRequestedGLCapabilitiesgetSurfaceHeightgetSurfaceWidthgetThreadNamegetTotalFPSgetTotalFPSDurationgetTotalFPSFramesgetUpdateFPSFramesinvokeinvokeinvokeOnCurrentThreadinvokeOnNewThreadisGLOrientedisGLStatePreservationSupportedisRealizedisThreadGLCapablepreserveGLEventListenerStatepreserveGLStateAtDestroyremoveGLEventListenerresetFPSCounterrestoreGLEventListenerStatesetAnimatorsetAutoSwapBufferModesetContextsetContextCreationFlagssetExclusiveContextThreadsetGLsetGLEventListenerInitStatesetGLStateKeeperListenersetRealizedsetSharedAutoDrawablesetSharedContextsetUpdateFPSFrames

Field Detail

lockback to summary
private final RecursiveLock lock
upstreamWidgetback to summary
private Object upstreamWidget

Constructor Detail

GLAutoDrawableDelegateback to summary
public GLAutoDrawableDelegate(final GLDrawable drawable, final GLContext context, final Object upstreamWidget, final boolean ownDevice, final 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.

Parameters
drawable:GLDrawable

a valid GLDrawable, may not be realized yet.

context:GLContext

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:Object

optional UI element holding this instance, see getUpstreamWidget().

ownDevice:boolean

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:RecursiveLock

optional custom RecursiveLock.

Method Detail

destroyback to summary
public final void destroy()

Implements com.jogamp.opengl.GLAutoDrawable.destroy.

Doc from com.jogamp.opengl.GLAutoDrawable.destroy.

Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext. If a window is attached to it's implementation, it shall be closed. Causes disposing of all OpenGL resources by calling dispose(..) for all registered GLEventListeners. Called automatically by the window system toolkit upon receiving a destroy notification. This routine may be called manually.

This implementation calls defaultDestroy().

User still needs to destroy the upstream window, which details are hidden from this aspect. This can be performed by overriding destroyImplInLock().

Annotations
@Override
destroyImplInLockback to summary
protected void destroyImplInLock()

Overrides jogamp.opengl.GLAutoDrawableBase.destroyImplInLock.

Doc from jogamp.opengl.GLAutoDrawableBase.destroyImplInLock.

Default implementation to destroys the drawable and context of this GLAutoDrawable:

  • issues the GLEventListener dispose call, if drawable and context are valid
  • destroys the GLContext, if valid
  • destroys the GLDrawable, if valid

Method assumes the lock is being hold.

Override it to extend it to destroy your resources, i.e. the actual window. In such case call super.destroyImplInLock first.

Annotations
@Override
displayback to summary
public void display()

Implements com.jogamp.opengl.GLAutoDrawable.display.

Doc from com.jogamp.opengl.GLAutoDrawable.display.

Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:

May be called periodically by a running com.jogamp.opengl.GLAnimatorControl implementation,
which must register itself with setAnimator(com.jogamp.opengl.GLAnimatorControl).

Called automatically by the window system toolkit upon receiving a repaint() request,
except an com.jogamp.opengl.GLAnimatorControl implementation com.jogamp.opengl.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 GLEventListeners before making the actual display(..) calls, in case this has not been done yet.

Annotations
@Override
getFactoryback to summary
public final GLDrawableFactory getFactory()

Implements com.jogamp.opengl.GLDrawable.getFactory.

Doc from com.jogamp.opengl.GLDrawable.getFactory.

Return the GLDrawableFactory being used to create this instance.

Annotations
@Override
getUpstreamLockback to summary
public final RecursiveLock getUpstreamLock()

Implements com.jogamp.opengl.GLAutoDrawable.getUpstreamLock.

Doc from com.jogamp.opengl.GLAutoDrawable.getUpstreamLock.

Returns the recursive lock object of the upstream widget to synchronize multithreaded access on top of NativeSurface#lockSurface().

See GLAutoDrawable Locking.

Annotations
@Override
getUpstreamWidgetback to summary
public final Object getUpstreamWidget()

Implements com.jogamp.opengl.GLAutoDrawable.getUpstreamWidget.

Doc from com.jogamp.opengl.GLAutoDrawable.getUpstreamWidget.

Method may return the upstream UI toolkit object holding this 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 com.jogamp.opengl.swt.GLCanvas is a org.eclipse.swt.widgets.Canvas
AWT com.jogamp.opengl.awt.GLCanvas is a java.awt.Canvas
AWT com.jogamp.opengl.awt.GLJPanel is a javax.swing.JPanel
However, the result may be other object types than the listed above due to new supported toolkits.

This method may also return null if no UI toolkit is being used, as common for offscreen rendering.

Annotations
@Override
setUpstreamWidgetback to summary
public final void setUpstreamWidget(final Object newUpstreamWidget)

Set the upstream UI toolkit object.

See Also
getUpstreamWidget()
swapBuffersback to summary
public final void swapBuffers() throws GLException

Implements com.jogamp.opengl.GLDrawable.swapBuffers.

Doc from com.jogamp.opengl.GLDrawable.swapBuffers.

Swaps the front and back buffers of this drawable. For 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.

Annotations
@Override
toStringback to summary
public String toString()

Overrides jogamp.opengl.GLAutoDrawableBase.toString.

Implements com.jogamp.opengl.GLDrawable.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
windowDestroyNotifyOpback to summary
public final void windowDestroyNotifyOp()

Implementation to handle destroy notifications from the windowing system.

If the NativeSurface does not implement WindowClosingProtocol or WindowClosingMode#DISPOSE_ON_CLOSE is enabled (default), a thread safe destruction is being induced.

windowRepaintOpback to summary
public final void windowRepaintOp()

Default implementation to handle repaint events from the windowing system

windowResizedOpback to summary
public final void windowResizedOp(final int newWidth, final int newHeight)

Handling resize events from the windowing system.

Implementation:

All required locks are being claimed.

Parameters
newWidth:int

  • new width in pixel units
  • new height in pixel units