com.jogamp.opengl
Class GLAutoDrawableDelegate

java.lang.Object
  extended by jogamp.opengl.GLAutoDrawableBase
      extended by com.jogamp.opengl.GLAutoDrawableDelegate
All Implemented Interfaces:
GLStateKeeper, FPSCounter, GLAutoDrawable, GLDrawable

public class GLAutoDrawableDelegate
extends jogamp.opengl.GLAutoDrawableBase
implements GLAutoDrawable

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.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jogamp.opengl.GLStateKeeper
GLStateKeeper.Listener
 
Field Summary
 
Fields inherited from class jogamp.opengl.GLAutoDrawableBase
DEBUG
 
Fields inherited from interface javax.media.opengl.GLAutoDrawable
SCREEN_CHANGE_ACTION_ENABLED
 
Fields inherited from interface javax.media.opengl.FPSCounter
DEFAULT_FRAMES_PER_INTERVAL
 
Constructor Summary
GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice, com.jogamp.common.util.locks.RecursiveLock lock)
           
 
Method Summary
 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 GLEventListeners.
 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 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)
          Implementation to handle resize events from the windowing system.
 
Methods inherited from class jogamp.opengl.GLAutoDrawableBase
addGLEventListener, addGLEventListener, clearPreservedGLState, createContext, defaultSwapBuffers, disposeGLEventListener, getAnimator, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getFPSStartTime, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, getGLProfile, getHandle, getHeight, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getNativeSurface, getPreservedGLState, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, getWidth, invoke, invoke, isGLOriented, isGLStatePreservationSupported, isRealized, preserveGLStateAtDestroy, removeGLEventListener, resetFPSCounter, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState, setGLStateKeeperListener, setRealized, setUpdateFPSFrames
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.media.opengl.GLAutoDrawable
addGLEventListener, addGLEventListener, createContext, disposeGLEventListener, getAnimator, getAutoSwapBufferMode, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, invoke, invoke, removeGLEventListener, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState
 
Methods inherited from interface javax.media.opengl.GLDrawable
getChosenGLCapabilities, getGLProfile, getHandle, getHeight, getNativeSurface, getWidth, isGLOriented, isRealized, setRealized
 

Constructor Detail

GLAutoDrawableDelegate

public GLAutoDrawableDelegate(GLDrawable drawable,
                              GLContext context,
                              Object upstreamWidget,
                              boolean ownDevice,
                              com.jogamp.common.util.locks.RecursiveLock lock)
Parameters:
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
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.
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)
Implementation to handle resize events from the windowing system. All required locks are being claimed.


windowDestroyNotifyOp

public final void windowDestroyNotifyOp()
Implementation to handle destroy notifications from the windowing system.

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


getUpstreamWidget

public final Object getUpstreamWidget()
Description copied from interface: GLAutoDrawable
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 GLWindow has a Window
SWT GLCanvas is a Canvas
AWT GLCanvas is a Canvas
AWT GLJPanel is a 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.

Specified by:
getUpstreamWidget in interface GLAutoDrawable
Returns:

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 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 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:
destroy in interface GLAutoDrawable

display

public void display()
Description copied from interface: GLAutoDrawable

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

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 GLEventListeners before making the actual display(..) calls, in case this has not been done yet.

Specified by:
display in interface GLAutoDrawable
See Also:
GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl)

getFactory

public final GLDrawableFactory getFactory()
Description copied from interface: GLDrawable
Return the GLDrawableFactory being used to create this instance.

Specified by:
getFactory in interface GLDrawable

swapBuffers

public final void swapBuffers()
                       throws GLException
Description copied from interface: GLDrawable
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.

Specified by:
swapBuffers in interface GLDrawable
Throws:
GLException

toString

public String toString()
Specified by:
toString in interface GLDrawable
Overrides:
toString in class jogamp.opengl.GLAutoDrawableBase


Copyright 2010 JogAmp Community.