Top Description Inners Fields Constructors Methods
com.jogamp.opengl.swt

public Class GLCanvas

extends Canvas
implements GLAutoDrawable, GLSharedContextSetter
Class Inheritance
All Implemented Interfaces
com.jogamp.opengl.GLSharedContextSetter, com.jogamp.opengl.GLAutoDrawable, com.jogamp.opengl.GLDrawable, com.jogamp.nativewindow.NativeSurfaceHolder
Imports
java.util.List, com.jogamp.nativewindow.AbstractGraphicsConfiguration, .AbstractGraphicsDevice, .AbstractGraphicsScreen, .GraphicsConfigurationFactory, .NativeSurface, .NativeWindowException, .ProxySurface, .UpstreamSurfaceHook, .VisualIDHolder, .VisualIDHolder.VIDType, com.jogamp.opengl.GL, .GLAnimatorControl, .GLAutoDrawable, .GLCapabilities, .GLCapabilitiesChooser, .GLCapabilitiesImmutable, .GLContext, .GLDrawable, .GLDrawableFactory, .GLEventListener, .GLException, .GLProfile, .GLRunnable, .GLSharedContextSetter, .Threading, .JoglVersion, jogamp.nativewindow.x11.X11Util, jogamp.opengl.Debug, .GLContextImpl, .GLDrawableHelper, .GLDrawableImpl, org.eclipse.swt.SWT, org.eclipse.swt.graphics.Rectangle, org.eclipse.swt.layout.FillLayout, org.eclipse.swt.widgets.Canvas, .Composite, .Display, .Event, .Listener, .Shell, com.jogamp.common.GlueGenVersion, com.jogamp.common.os.Platform, com.jogamp.common.util.VersionUtil, com.jogamp.common.util.locks.LockFactory, .RecursiveLock, com.jogamp.nativewindow.swt.SWTAccessor, com.jogamp.nativewindow.x11.X11GraphicsDevice

Native SWT Canvas implementing GLAutoDrawable

Implementation allows use of custom GLCapabilities.

OpenGL Context Sharing
To share a GLContext see the following note in the documentation overview: context sharing as well as GLSharedContextSetter.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private int
private final GLCapabilitiesChooser
private final GLCapabilitiesImmutable
private volatile Rectangle
private volatile GLContextImpl
private static final boolean
private final Runnable
private final Runnable
private volatile GLDrawableImpl
private volatile long
private final GLDrawableHelper
private final Runnable
private final Runnable
private boolean
private final RecursiveLock
private final Runnable
private final AbstractGraphicsScreen
private volatile boolean
private final Runnable
private final UpstreamSurfaceHook
private final boolean
private volatile long

Constructor Summary

AccessConstructor and Description
public
GLCanvas(final Composite
Required (non-null) parent Composite.
parent
,
final int
Optional SWT style bit-field. The SWT#NO_BACKGROUND bit is set before passing this up to the Canvas constructor, so OpenGL handles the background.
style
,
final GLCapabilitiesImmutable
Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the graphics device determined by the parent Composite are used. Note that the GLCapabilities that are actually used may differ based on the capabilities of the graphics device.
capsReqUser
,
final GLCapabilitiesChooser
Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the requested GLCapabilities, and the available capabilities of the graphics device.
capsChooser
)

Creates a new SWT GLCanvas.

Method Summary

Modifier and TypeMethod and Description
public void
addGLEventListener(final GLEventListener
The GLEventListener object to be inserted
listener
)

Implements com.jogamp.opengl.GLAutoDrawable.addGLEventListener.

Adds the given listener to the end of this drawable queue.
public void
addGLEventListener(final int
Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().
idx
,
final GLEventListener
The GLEventListener object to be inserted
listener
)

Implements com.jogamp.opengl.GLAutoDrawable.addGLEventListener.

Adds the given listener at the given index of this drawable queue.
public boolean
areAllGLEventListenerInitialized()

Implements com.jogamp.opengl.GLAutoDrawable.areAllGLEventListenerInitialized.

Returns true if all added GLEventListener are initialized, otherwise false.
public static GLCanvas

Returns:

a new instance
create
(final Composite
Required (non-null) parent Composite.
parent
,
final int
Optional SWT style bit-field. The SWT#NO_BACKGROUND bit is set before passing this up to the Canvas constructor, so OpenGL handles the background.
style
,
final GLCapabilitiesImmutable
Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the graphics device determined by the parent Composite are used. Note that the GLCapabilities that are actually used may differ based on the capabilities of the graphics device.
caps
,
final GLCapabilitiesChooser
Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the requested GLCapabilities, and the available capabilities of the graphics device.
chooser
)

Creates an instance using GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser) on the SWT thread.

public GLContext
createContext(final GLContext shareWith)

Implements com.jogamp.opengl.GLAutoDrawable.createContext.

Creates a new context for drawing to this drawable that will optionally share buffer objects, textures and other server-side OpenGL objects with the specified GLContext.
private boolean
createContextImpl(final GLDrawable drawable)

private final void
public void
destroy()

Implements com.jogamp.opengl.GLAutoDrawable.destroy.

Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
public void
display()

Implements com.jogamp.opengl.GLAutoDrawable.display.

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

private final void
public void
dispose()

Overrides org.eclipse.swt.widgets.Widget.dispose.

Disposes of the operating system resources associated with the receiver and all its descendants.
public GLEventListener
disposeGLEventListener(final GLEventListener
The GLEventListener object to be disposed and removed if remove is true
listener
,
final boolean
pass true to have the listener removed from this drawable queue, otherwise pass false
remove
)

Implements com.jogamp.opengl.GLAutoDrawable.disposeGLEventListener.

Disposes the given listener via dispose(..) if it has been initialized and added to this queue.
public void
flushGLRunnables()

Implements com.jogamp.opengl.GLAutoDrawable.flushGLRunnables.

Flushes all enqueued GLRunnable of this GLAutoDrawable including notifying waiting executor.
public GLAnimatorControl
public boolean
getAutoSwapBufferMode()

Implements com.jogamp.opengl.GLAutoDrawable.getAutoSwapBufferMode.

Indicates whether automatic buffer swapping is enabled for this drawable.
public GLCapabilitiesImmutable
getChosenGLCapabilities()

Implements com.jogamp.opengl.GLDrawable.getChosenGLCapabilities.

Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
public GLContext
getContext()

Implements com.jogamp.opengl.GLAutoDrawable.getContext.

Returns the context associated with this drawable.
public int
public final GLDrawable
getDelegatedDrawable()

Implements com.jogamp.opengl.GLAutoDrawable.getDelegatedDrawable.

If the implementation uses delegation, return the delegated GLDrawable instance, otherwise return this instance.
public final Thread
public GLDrawableFactory
getFactory()

Implements com.jogamp.opengl.GLDrawable.getFactory.

Return the GLDrawableFactory being used to create this instance.
public GL
getGL()

Implements com.jogamp.opengl.GLAutoDrawable.getGL.

Returns the GL pipeline object this GLAutoDrawable uses.
public GLEventListener
getGLEventListener(final int
Position of the listener to be returned. Should be within (0 <= index && index < size()). An index value of -1 is interpreted as last listener, size()-1.
index
)

Implements com.jogamp.opengl.GLAutoDrawable.getGLEventListener.

Returns the GLEventListener at the given index of this drawable queue.
public int
public boolean
getGLEventListenerInitState(final GLEventListener
the GLEventListener object to query it's initialized state.
listener
)

Implements com.jogamp.opengl.GLAutoDrawable.getGLEventListenerInitState.

Retrieves whether the given listener is initialized or not.
public GLProfile
getGLProfile()

Implements com.jogamp.opengl.GLDrawable.getGLProfile.

Fetches the GLProfile for this drawable.
public long
getHandle()

Implements com.jogamp.opengl.GLDrawable.getHandle.

Returns the GL drawable handle, guaranteed to be valid after realization and while it's surface is being locked.
public NativeSurface
public GLCapabilitiesImmutable
getRequestedGLCapabilities()

Implements com.jogamp.opengl.GLDrawable.getRequestedGLCapabilities.

Fetches the GLCapabilitiesImmutable corresponding to the user requested OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
public int
getSurfaceHeight()

Implements com.jogamp.opengl.GLDrawable.getSurfaceHeight.

Returns the height of this GLDrawable's surface client area in pixel units.
public int
getSurfaceWidth()

Implements com.jogamp.opengl.GLDrawable.getSurfaceWidth.

Returns the width of this GLDrawable's surface client area in pixel units.
private static String
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 boolean
invoke(final boolean
if true block until execution of glRunnable is finished, otherwise return immediately w/o waiting
wait
,
final GLRunnable
the GLRunnable to execute within display()
runnable
)

Implements com.jogamp.opengl.GLAutoDrawable.invoke.

Enqueues a one-shot GLRunnable, which will be executed within the next display() call after all registered GLEventListeners display(GLAutoDrawable) methods have been called.
public boolean
invoke(final boolean
if true block until execution of the last glRunnable is finished, otherwise return immediately w/o waiting
wait
,
final List<GLRunnable>
the GLRunnables to execute within display()
runnables
)

Implements com.jogamp.opengl.GLAutoDrawable.invoke.

Extends invoke(boolean, GLRunnable) functionality allowing to inject a list of GLRunnables.
private final boolean
public boolean
isGLOriented()

Implements com.jogamp.opengl.GLDrawable.isGLOriented.

Returns true if the drawable is rendered in OpenGL's coordinate system, origin at bottom left.
public boolean
isRealized()

Implements com.jogamp.opengl.GLDrawable.isRealized.

Returns true if this drawable is realized, otherwise true.
public final boolean
isThreadGLCapable()

Implements com.jogamp.opengl.GLAutoDrawable.isThreadGLCapable.

Indicates whether the current thread is capable of performing OpenGL-related work.
private final boolean
public static void
main(final String[] args)

public GLEventListener
removeGLEventListener(final GLEventListener
The GLEventListener object to be removed
listener
)

Implements com.jogamp.opengl.GLAutoDrawable.removeGLEventListener.

Removes the given listener from this drawable queue.
private void
runInGLThread(final Runnable action)

Runs the specified action in an SWT compatible thread, which is:

  • Mac OSX
    • Current thread
private void
runOnEDTIfAvail(final boolean wait, final Runnable action)

public void
setAnimator(final GLAnimatorControl
null reference indicates no animator is using this GLAutoDrawable,
a valid reference indicates an animator is using this GLAutoDrawable.
arg0
)

Implements com.jogamp.opengl.GLAutoDrawable.setAnimator.

Registers the usage of an animator, an com.jogamp.opengl.GLAnimatorControl implementation.
public void
setAutoSwapBufferMode(final boolean arg0)

Implements com.jogamp.opengl.GLAutoDrawable.setAutoSwapBufferMode.

Enables or disables automatic buffer swapping for this drawable.
public GLContext
setContext(final GLContext
the new context, maybe null for dis-association.
newCtx
,
final boolean
if true, destroy the previous context if exists
destroyPrevCtx
)

Implements com.jogamp.opengl.GLAutoDrawable.setContext.

Associate the new context, newtCtx, to this auto-drawable.
public void
setContextCreationFlags(final int
Additional context creation flags.
arg0
)

Implements com.jogamp.opengl.GLAutoDrawable.setContextCreationFlags.

public final Thread
setExclusiveContextThread(final Thread
the exclusive thread to claim the context, or null for default operation.
t
)

Implements com.jogamp.opengl.GLAutoDrawable.setExclusiveContextThread.

Dedicates this instance's GLContext to the given thread.
public GL
setGL(final GL arg0)

Implements com.jogamp.opengl.GLAutoDrawable.setGL.

Sets the GL pipeline object this GLAutoDrawable uses.
public void
setGLEventListenerInitState(final GLEventListener
the GLEventListener object to perform a state change.
listener
,
final boolean
if true, mark the listener initialized, otherwise uninitialized.
initialized
)

Implements com.jogamp.opengl.GLAutoDrawable.setGLEventListenerInitState.

Sets the given listener's initialized state.
public void
setRealized(final boolean arg0)

Implements com.jogamp.opengl.GLDrawable.setRealized.

Indicates to GLDrawable implementations whether the underlying surface has been created and can be drawn into.
public final void
setSharedAutoDrawable(final GLAutoDrawable
The GLAutoDrawable, which OpenGL context shall be shared by this GLAutoDrawable's GLContext.
sharedAutoDrawable
)

Implements com.jogamp.opengl.GLSharedContextSetter.setSharedAutoDrawable.

Specifies an GLAutoDrawable, which OpenGL context shall be shared by this GLAutoDrawable's GLContext.
public final void
setSharedContext(final GLContext
The OpenGL context to be shared by this GLAutoDrawable's GLContext.
sharedContext
)

Implements com.jogamp.opengl.GLSharedContextSetter.setSharedContext.

Specifies an OpenGL context, which shall be shared by this GLAutoDrawable's GLContext.
public void
swapBuffers()

Implements com.jogamp.opengl.GLDrawable.swapBuffers.

Swaps the front and back buffers of this drawable.
private static String
toHexString(final int v)

private static String
toHexString(final long v)

public String
toString()

Overrides org.eclipse.swt.widgets.Composite.toString.

Implements com.jogamp.opengl.GLDrawable.toString.

Returns a string containing a concise, human-readable description of the receiver.
public void
update()

Overrides org.eclipse.swt.widgets.Control.update.

Forces all outstanding paint requests for the widget to be processed before this method returns.
protected final void
private final boolean
validateDrawableAndContextPostCheck()

assumes drawable == null (implying !drawable.isRealized()) || context == null !

protected final boolean
validateDrawableAndContextWithCheck()

assumes drawable == null (implying !drawable.isRealized()) !

Inherited from org.eclipse.swt.widgets.Canvas:
drawBackgroundgetCaretgetIMEscrollsetCaretsetFontsetIME