Functionality to deal with GL Contexts in vispy. This module is defined in gloo, because gloo (and the layers that depend on it) need to be context aware. The vispy.app module “provides” a context, and therefore depends on this module. Although the GLContext class is aimed for use by vispy.app (for practical reasons), it should be possible to use GLContext without using vispy.app by overloading it in an appropriate manner.
An GLContext object acts as a placeholder on which different parts of vispy (or other systems) can keep track of information related to an OpenGL context.
- class vispy.gloo.context.FakeCanvas#
Fake canvas to allow using gloo without vispy.app
Instantiate this class to collect GLIR commands from gloo interactions. Call flush() in your draw event handler to execute the commands in the active contect.
Flush commands. Call this after setting to context to current.
- class vispy.gloo.context.GLContext(config=None, shared=None)#
An object encapsulating data necessary for a OpenGL context
- configdict | None
The requested configuration.
- sharedinstance of GLContext | None
The shared context.
- property capabilities#
The OpenGL capabilities
- property config#
A dictionary describing the configuration of this GL context.
For the app backends to create the GLShared object.
- eventinstance of Event
- property glir#
The glir queue for the context. This queue is for objects that can be shared accross canvases (if they share a contex).
Set the OpenGL viewport
This is a wrapper for gl.glViewport.
X and Y coordinates, plus width and height. Can be passed in as individual components, or as a single tuple with four values.
Get the object that represents the namespace that can potentially be shared between multiple contexts.
Representation of a “namespace” that can be shared between different contexts. App backends can associate themselves with this object via add_ref().
This object can be used to establish whether two contexts/canvases share objects, and can be used as a placeholder to store shared information, such as glyph atlasses.
Add a reference for the backend object that gives access to the low level context. Used in vispy.app.canvas.backends. The given name must match with that of previously added references.
The name of the canvas backend that this shared namespace is associated with. Can be None.
The GLIR parser (shared between contexts)
A reference (stored internally via a weakref) to an object that the backend system can use to obtain the low-level information of the “reference context”. In Vispy this will typically be the CanvasBackend object.
Forget about the given canvas. Used by the canvas when closed.
Get the currently active canvas
Returns None if there is no canvas available. A canvas is made active on initialization and before the draw event is emitted.
When a gloo object is created, it is associated with the currently active Canvas, or with the next Canvas to be created if there is no current Canvas. Use Canvas.set_current() to manually activate a canvas.
Get the default OpenGL context configuration
Dictionary of config values.
Make a canvas active. Used primarily by the canvas itself.