Package org.eclipse.swt.opengl

## Class GLCanvas

- java.lang.Object
- - org.eclipse.swt.widgets.Widget
  - - org.eclipse.swt.widgets.Control
    - - org.eclipse.swt.widgets.Scrollable
      - - org.eclipse.swt.widgets.Composite
        - - org.eclipse.swt.widgets.Canvas
          - - 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.Control

`handle`

### Constructor Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`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, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString`

### Methods inherited from class org.eclipse.swt.widgets.Scrollable

`computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar`

### Methods inherited from class org.eclipse.swt.widgets.Control

`addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update`

### Methods inherited from class org.eclipse.swt.widgets.Widget

`addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.swt.graphics.Drawable

`isAutoScalable`

### 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:
  `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