Class GLAutoDrawableDelegate
- java.lang.Object
-
- jogamp.opengl.GLAutoDrawableBase
-
- com.jogamp.opengl.GLAutoDrawableDelegate
-
- All Implemented Interfaces:
NativeSurfaceHolder,FPSCounter,GLAutoDrawable,GLDrawable,GLSharedContextSetter,GLStateKeeper
public class GLAutoDrawableDelegate extends jogamp.opengl.GLAutoDrawableBase implements GLAutoDrawable
Fully functionalGLAutoDrawableimplementation utilizing already createdGLDrawableandGLContextinstances.Since no native windowing system events are being processed, it is recommended to handle at least the
window events:repaintusingwindowRepaintOp()resizeusing#windowResizedOp()
custom toolkit destructionissuingwindowDestroyNotifyOp().See example
TestGLAutoDrawableDelegateNEWT.OpenGL Context Sharing
To share aGLContextsee the following note in the documentation overview: context sharing as well asGLSharedContextSetter.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jogamp.opengl.GLStateKeeper
GLStateKeeper.Listener
-
-
Field Summary
-
Fields inherited from interface com.jogamp.opengl.FPSCounter
DEFAULT_FRAMES_PER_INTERVAL
-
Fields inherited from interface com.jogamp.opengl.GLAutoDrawable
SCREEN_CHANGE_ACTION_ENABLED
-
-
Constructor Summary
Constructors Constructor Description GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice, RecursiveLock lock)TheGLContextcan be assigned later manually viasetContext(ctx)or it will be created lazily at the 1stdisplay()method call.
LazyGLContextcreation will take a sharedGLContextinto account which has been setdirectlyorvia another GLAutoDrawable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.voiddisplay()Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order: Callingdisplay(..)for all registeredGLEventListeners.GLDrawableFactorygetFactory()Return theGLDrawableFactorybeing used to create this instance.RecursiveLockgetUpstreamLock()Returns the recursive lock object of theupstream widgetto synchronize multithreaded access on top ofNativeSurface.lockSurface().ObjectgetUpstreamWidget()Method may return the upstream UI toolkit object holding thisGLAutoDrawableinstance, if exist.voidsetUpstreamWidget(Object newUpstreamWidget)Set the upstream UI toolkit object.voidswapBuffers()Swaps the front and back buffers of this drawable.StringtoString()voidwindowDestroyNotifyOp()Implementation to handle destroy notifications from the windowing system.voidwindowRepaintOp()Default implementation to handle repaint events from the windowing systemvoidwindowResizedOp(int newWidth, int newHeight)Handling resize events from the windowing system.-
Methods inherited from class jogamp.opengl.GLAutoDrawableBase
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, invokeOnCurrentThread, invokeOnNewThread, isGLOriented, isGLStatePreservationSupported, isRealized, isThreadGLCapable, preserveGLStateAtDestroy, removeGLEventListener, resetFPSCounter, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState, setGLStateKeeperListener, setRealized, setSharedAutoDrawable, setSharedContext, setUpdateFPSFrames
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.jogamp.opengl.GLAutoDrawable
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
-
Methods inherited from interface com.jogamp.opengl.GLDrawable
getChosenGLCapabilities, getGLProfile, getHandle, getNativeSurface, getRequestedGLCapabilities, getSurfaceHeight, getSurfaceWidth, isGLOriented, isRealized, setRealized
-
-
-
-
Constructor Detail
-
GLAutoDrawableDelegate
public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice, RecursiveLock lock)
The
GLContextcan be assigned later manually viasetContext(ctx)or it will be created lazily at the 1stdisplay()method call.
LazyGLContextcreation will take a sharedGLContextinto account which has been setdirectlyorvia another GLAutoDrawable.- Parameters:
drawable- a validGLDrawable, may not berealizedyet.context- a validGLContext, may not have been made current (created) yet, may not be associated w/drawableyet, may benullfor lazy initialization at 1stdisplay().upstreamWidget- optional UI element holding this instance, seegetUpstreamWidget().ownDevice- passtrueifAbstractGraphicsDevice.close()shall be issued, otherwise passfalse. 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 customRecursiveLock.
-
-
Method Detail
-
windowRepaintOp
public final void windowRepaintOp()
Default implementation to handle repaint events from the windowing system
-
windowResizedOp
public final void windowResizedOp(int newWidth, int newHeight)Handling resize events from the windowing system.Implementation:
- resizes
the GLDrawable, if offscreen, - triggers a pending
reshape events, and - issues a
display()call, if no animator is present.
All required locks are being claimed.
- Parameters:
newWidth- new width in pixel unitsnewWidth- new height in pixel units
- resizes
-
windowDestroyNotifyOp
public final void windowDestroyNotifyOp()
Implementation to handle destroy notifications from the windowing system.If the
NativeSurfacedoes not implementWindowClosingProtocolorWindowClosingProtocol.WindowClosingMode.DISPOSE_ON_CLOSEis enabled (default), a thread safe destruction is being induced.
-
getUpstreamLock
public final RecursiveLock getUpstreamLock()
Description copied from interface:GLAutoDrawableReturns the recursive lock object of theupstream widgetto synchronize multithreaded access on top ofNativeSurface.lockSurface().- Specified by:
getUpstreamLockin interfaceGLAutoDrawable
-
getUpstreamWidget
public final Object getUpstreamWidget()
Description copied from interface:GLAutoDrawableMethod may return the upstream UI toolkit object holding thisGLAutoDrawableinstance, if exist.Currently known Java UI toolkits and it's known return types are:
However, the result may be other object types than the listed above due to new supported toolkits.Toolkit GLAutoDrawable Implementation ~ Return Type of getUpstreamWidget() NEWT GLWindowhas a WindowSWT GLCanvasis a CanvasAWT GLCanvasis a CanvasAWT GLJPanelis a JPanelThis method may also return
nullif no UI toolkit is being used, as common for offscreen rendering.- Specified by:
getUpstreamWidgetin interfaceGLAutoDrawable
-
setUpstreamWidget
public final void setUpstreamWidget(Object newUpstreamWidget)
Set the upstream UI toolkit object.- See Also:
getUpstreamWidget()
-
destroy
public final void 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 callingdispose(..)for all registeredGLEventListeners. 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().- Specified by:
destroyin interfaceGLAutoDrawable
-
display
public void display()
Description copied from interface:GLAutoDrawableCauses OpenGL rendering to be performed for this GLAutoDrawable in the following order:
- Calling
display(..)for all registeredGLEventListeners. - Executes all one-shot
GLRunnable, enqueued viaGLAutoDrawable.invoke(boolean, GLRunnable).
May be called periodically by a running
GLAnimatorControlimplementation,
which must register itself withGLAutoDrawable.setAnimator(com.jogamp.opengl.GLAnimatorControl).Called automatically by the window system toolkit upon receiving a repaint() request,
except anGLAnimatorControlimplementationGLAnimatorControl.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 registeredGLEventListeners before making the actualdisplay(..)calls, in case this has not been done yet.- Specified by:
displayin interfaceGLAutoDrawable- See Also:
GLAutoDrawable.setAnimator(com.jogamp.opengl.GLAnimatorControl)
- Calling
-
getFactory
public final GLDrawableFactory getFactory()
Description copied from interface:GLDrawableReturn theGLDrawableFactorybeing used to create this instance.- Specified by:
getFactoryin interfaceGLDrawable
-
swapBuffers
public final void swapBuffers() throws GLExceptionDescription copied from interface:GLDrawableSwaps the front and back buffers of this drawable. ForGLAutoDrawableimplementations, when automatic buffer swapping is enabled (as is the default), this method is called automatically and should not be called by the end user.- Specified by:
swapBuffersin interfaceGLDrawable- Throws:
GLException
-
toString
public String toString()
- Specified by:
toStringin interfaceGLDrawable- Overrides:
toStringin classjogamp.opengl.GLAutoDrawableBase
-
-