wxRuby Documentation Home

# Wx::GLContext

An instance of a GLContext represents the state of an OpenGL state machine and the connection between
OpenGL and the system.

The OpenGL state includes everything that can be set with the OpenGL API: colors, rendering variables,
display lists, texture objects, etc. Although it is possible to have multiple rendering contexts share
display lists in order to save resources, this method is hardly used today any more, because display
lists are only a tiny fraction of the overall state.

Therefore, one rendering context is usually used with or bound to multiple output windows in turn, so
that the application has access to the complete and identical state while rendering into each window.

Binding (making current) a rendering context with another instance of a GLCanvas however works only
if the other GLCanvas was created with the same attributes as the GLCanvas from which the GLContext
was initialized. (This applies to sharing display lists among contexts analogously.)

Note that some GLContext features are extremely platform-specific – it’s best to check what features your native platform provides.

## Derived from

Object

## See also

GLCanvas

## Methods

- GLContext.new
- GLContext#set_current

### GLContext.new

GLContext.new(%(arg-type)GLCanvas% win, GLContext other=nil)

- win The canvas that is used to initialize this context. This parameter is needed only temporarily,
  and the caller may do anything with it (e.g. destroy the window) after the constructor returned.
  It will be possible to bind (make current) this context to any other wxGLCanvas that has been created
  with equivalent attributes as win.
- other Context to share display lists with or nil (the default) for no sharing.

### GLContext#set_current

set_current(%(arg-type)GLCanvas% win)

Makes the OpenGL state that is represented by this rendering context current with the GLCanvas win.
Note that win can be a different GLCanvas window than the one that was passed to the constructor of this rendering context.
If rc is an object of type GLContext, the statements rc.set_current(win); and win.set_current(rc); are equivalent,
see GLCanvas#set_current.

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