org.eclipse.swt.opengl
Class GLCanvas

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.eclipse.swt.widgets.Canvas
                      extended by org.eclipse.swt.opengl.GLCanvas
All Implemented Interfaces:
Drawable

public class GLCanvas
extends Canvas

GLCanvas is a widget capable of displaying OpenGL content.

Since:
3.2
See Also:
GLData, OpenGL snippets, Sample code and further information

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
GLCanvas(Composite parent, int style, GLData data)
          Create a GLCanvas widget using the attributes described in the GLData object provided.
 
Method Summary
 GLData getGLData()
          Returns a GLData object describing the created context.
 boolean isCurrent()
          Returns a boolean indicating whether the receiver's OpenGL context is the current context.
 void setCurrent()
          Sets the OpenGL context associated with this GLCanvas to be the current GL context.
 void swapBuffers()
          Swaps the front and back color buffers.
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GLCanvas

public GLCanvas(Composite parent,
                int style,
                GLData data)
Create a GLCanvas widget using the attributes described in the GLData object provided.

Parameters:
parent - a composite widget
style - the bitwise OR'ing of widget styles
data - the requested attributes of the GLCanvas
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when the data is null
  • ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided
Method Detail

getGLData

public GLData getGLData()
Returns a GLData object describing the created context.

Returns:
GLData description of the OpenGL context attributes
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

isCurrent

public boolean isCurrent()
Returns a boolean indicating whether the receiver's OpenGL context is the current context.

Returns:
true if the receiver holds the current OpenGL context, false otherwise
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setCurrent

public void setCurrent()
Sets the OpenGL context associated with this GLCanvas to be the current GL context.

Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

swapBuffers

public void swapBuffers()
Swaps the front and back color buffers.

Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver