javax.media.opengl
Class GLAutoDrawableDelegate

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

public class GLAutoDrawableDelegate
extends jogamp.opengl.GLAutoDrawableBase

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

See example TestGLAutoDrawableDelegateNEWT.


Field Summary
static boolean 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)
           
 
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 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()
           
 
Methods inherited from class jogamp.opengl.GLAutoDrawableBase
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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.media.opengl.GLDrawable
toString
 

Field Detail

DEBUG

public static final boolean DEBUG
Constructor Detail

GLAutoDrawableDelegate

public GLAutoDrawableDelegate(GLDrawable drawable,
                              GLContext context,
                              Object upstreamWidget)
Parameters:
drawable -
context -
upstreamWidget - optional UI element holding this instance, see getUpstreamWidget().
Method Detail

windowRepaintOp

public final void windowRepaintOp()

windowResizedOp

public final void windowResizedOp()

windowDestroyNotifyOp

public final void windowDestroyNotifyOp()

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 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 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.

Returns:

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 GLAutoDrawableBase.destroyImplInLock().


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.

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.


setRealized

public final void setRealized(boolean realized)
Description copied from interface: GLDrawable
Indicates to on-screen GLDrawable implementations whether the underlying window has been created and can be drawn into. End users do not need to call this method; it is not necessary to call 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:


This is important since 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.


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.

Throws:
GLException


Copyright 2010 JogAmp Community.