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.
vispy.gloo.context.
FakeCanvas
Bases: object
object
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
Flush commands. Call this after setting to context to current.
GLContext
Bases: vispy.gloo.wrappers.BaseGlooFunctions
vispy.gloo.wrappers.BaseGlooFunctions
An object encapsulating data necessary for a OpenGL context
The requested configuration.
The shared context.
capabilities
The OpenGL capabilities
config
A dictionary describing the configuration of this GL context.
create_shared
For the app backends to create the GLShared object.
The name.
The reference.
flush_commands
Flush
The event.
get_viewport
glir
The glir queue for the context. This queue is for objects that can be shared accross canvases (if they share a contex).
set_viewport
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.
shared
Get the object that represents the namespace that can potentially be shared between multiple contexts.
GLShared
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_ref
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.
name
The name of the canvas backend that this shared namespace is associated with. Can be None.
parser
The GLIR parser (shared between contexts)
ref
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_canvas
Forget about the given canvas. Used by the canvas when closed.
get_current_canvas
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_default_config
Get the default OpenGL context configuration
Dictionary of config values.
set_current_canvas
Make a canvas active. Used primarily by the canvas itself.