wxRuby Documentation Home

# Wx::GLCanvas

GLCanvas is a class for displaying OpenGL graphics. There are
wrappers for OpenGL on Windows, and GTK+ and Motif.

To use this class, create a wxGLCanvas window, call GLCanvas#set_current
to direct normal OpenGL commands to the window, and then call GLCanvas#swap_buffers to
show the OpenGL buffer on the window.

To set up the attributes for the rendering context (number of bits for the depth buffer,
number of bits for the stencil buffer and so on) you should set up the correct values of
the attrib_list parameter. The values that should be set up and their meanings will be described below.

## Derived from

Window

EvtHandler

Object

## Window styles

There are no specific window styles for this class.

See also window styles overview.

## Constants

The generic GL implementation doesn’t support many of these options, such as stereo, auxiliary buffers,
alpha channel, and accum buffer. Other implementations may support them.

`WX::GL_RGBA` | Use true colour
`WX::GL_BUFFER_SIZE` | Bits for buffer if not WX_GL_RGBA
`WX::GL_LEVEL` | 0 for main buffer, >0 for overlay, <0 for underlay
`WX::GL_DOUBLEBUFFER` | Use doublebuffer
`WX::GL_STEREO` | Use stereoscopic display
`WX::GL_AUX_BUFFERS` | Number of auxiliary buffers (not all implementation support this option)
`WX::GL_MIN_RED` | Use red buffer with most bits (> MIN_RED bits)
`WX::GL_MIN_GREEN` | Use green buffer with most bits (> MIN_GREEN bits)
`WX::GL_MIN_BLUE` | Use blue buffer with most bits (> MIN_BLUE bits)
`WX::GL_MIN_ALPHA` | Use alpha buffer with most bits (> MIN_ALPHA bits)
`WX::GL_DEPTH_SIZE` | Bits for Z-buffer (0,16,32)
`WX::GL_STENCIL_SIZE` | Bits for stencil buffer
`WX::GL_MIN_ACCUM_RED` | Use red accum buffer with most bits (> MIN_ACCUM_RED bits)
`WX::GL_MIN_ACCUM_GREEN` | Use green buffer with most bits (> MIN_ACCUM_GREEN bits)
`WX::GL_MIN_ACCUM_BLUE` | Use blue buffer with most bits (> MIN_ACCUM_BLUE bits)
`WX::GL_MIN_ACCUM_ALPHA` | Use blue buffer with most bits (> MIN_ACCUM_ALPHA bits)

## Methods

- GLCanvas.new
- GLCanvas#set_current
- GLCanvas#set_colour
- GLCanvas#swap_buffers

### GLCanvas.new

GLCanvas.new(%(arg-type)Window% parent, Integer id = ID_ANY, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style=0, String name=“GLCanvas”, Integer attrib_list = 0, Palette palette = NULL_PALETTE)

The initializer implicitly creates an instance of GLContext.
Optional parameters may also be specified by keywords in any order as following :

canvas = Wx::GLCanvas.new(parent, :size => [600, 600])

- parent Pointer to a parent window.
- id Window identifier. If ID_ANY (-1), will automatically create an identifier.
- pos Window position. DEFAULT_POSITION is [-1, -1] which indicates that Widgets
  should generate a default position for the window.
- size Window size. DEFAULT_SIZE is [-1, -1] which indicates that Widgets should
  generate a default size for the window. If no suitable size can be found, the window will be sized to 20×20 pixels so that the window is visible but obviously not correctly sized.
- style Window style.
- name Window name.
- attrib_list Array of int. With this parameter you can set the device context attributes associated to this window.
  It should be set up with constants described in the table above.
  If a constant should be followed by a value, put it in the next array position.
  For example, the WX::GL_DEPTH_SIZE should be followed by the value that indicates the number of
  bits for the depth buffer, so:

attrib_list = [WX::GL_DEPTH_SIZE, 32] and so on.

- palette If the window has the palette, it should by pass this value.
  Note: palette and WX_GL_RGBA are mutually exclusive.

### GLCanvas#set_current

set_current()

A call to this method makes the implicit rendering context of this canvas current with this canvas, so that subsequent
OpenGL calls modify the OpenGL state of the implicit rendering context.

Note that this function may only be called after the window has been shown.

### GLCanvas#set_colour

set_colour(%(arg-type)char% colour)

Sets the current colour for this window, using the Widgets colour database to find a named colour.

### GLCanvas#swap_buffers

swap_buffers()

Displays the previous OpenGL commands on the window.

[This page automatically generated from the Textile source at 2023-06-09 00:45:33 +0000]