class GL.GLView(Component, ViewBase)

The GLView class of the GL submodule provides an area for displaying 3D graphics using OpenGL. It also provides model observation and input handling facilities via the ViewBase class.


GLView(config, share_group = None)
GLView(config_attr = value..., share_group = None)
Creates a GLView having the given characteristics. In the first form of the constructor, the characteristics are specified by a GLConfig instance. In the second form, attributes of the GLConfig class are specified as individual keyword arguments to the constructor.

If share_group is specified, it should be a ShareGroup instance, and the GLView is added to that group.

Abstract methods

Immediately after the view's OpenGL context is created, it is made the current context and this method is called. You may use this method to establish any desired initial OpenGL state.

You may use this method to establish the desired projection matrix. It is called after init_context() during creation of the GLView, and again whenever the size of the view changes. When called, the view's OpenGL context is the current context, and its viewport has been set to (0, 0, w, h) where (w, h) is the new size of the view. Also, the projection matrix has been selected as the current matrix and loaded with an identity matrix. In most cases, you will simply need to call either gluPesrpective() or gluOrtho() to set up the projection.
This method is called with the view's OpenGL context as the current context whenever the view needs to be redrawn. The modelview matrix has been selected and loaded with an identity matrix. On return, drawing will be flushed and buffers swapped as appropriate.
This is a lower-level method that is called when the size of the view changes, after setting the viewport but before doing anything else. The default implementation calls init_projection(). You will not usually need to override this method.


with_context(function, flush = True)
The function should be a callable object of no arguments. Calls function with the view's OpenGL context as the current context. If flush is true, then after calling the function, a buffer flush or swap is performed as appropriate.
Marks the whole view as needing to be redrawn.
Causes the whole view to be redrawn immediately, without waiting for a return to the event loop.