vispy.gloo.wrappers.
GlooFunctions
Bases: vispy.gloo.wrappers.BaseGlooFunctions
vispy.gloo.wrappers.BaseGlooFunctions
glir
The GLIR queue corresponding to the current canvas
clear
Clear the screen buffers
This is a wrapper for gl.glClear.
Clear the color buffer bit. If not bool, set_clear_color will be used to set the color clear value.
set_clear_color
Clear the depth buffer bit. If float, set_clear_depth will be used to set the depth clear value.
set_clear_depth
Clear the stencil buffer bit. If int, set_clear_stencil will be used to set the stencil clear index.
set_clear_stencil
finish
Wait for GL commands to to finish
This creates a GLIR command for glFinish and then processes the GLIR commands. If the GLIR interpreter is remote (e.g. WebGL), this function will return before GL has finished processing the commands.
flush
Flush GL commands
This is a wrapper for glFlush(). This also flushes the GLIR command queue.
get_gl_configuration
Read the current gl configuration
This function uses constants that are not in the OpenGL ES 2.1 namespace, so only use this on desktop systems.
The currently active OpenGL configuration.
get_state_presets
The available GL state presets
The dictionary of presets usable with set_options.
set_options
read_pixels
Read pixels from the currently selected buffer.
Under most circumstances, this function reads from the front buffer. Unlike all other functions in vispy.gloo, this function directly executes an OpenGL command.
4-element list of x, y, w, h parameters. If None (default), the current GL viewport will be queried and used.
If True (default), the returned array has 4 elements (RGBA). If False, it has 3 (RGB). This only effects the color mode.
Type of buffer data to read. Can be one of ‘colors’, ‘depth’, or ‘stencil’. See returns for more information.
Can be ‘unsigned_byte’ or ‘float’. Note that this does not use casting, but instead determines how values are read from the current buffer. Can also be numpy dtypes np.uint8, np.ubyte, or np.float32.
np.uint8
np.ubyte
np.float32
3D array of pixels in np.uint8 or np.float32 format. The array shape is (h, w, 3) or (h, w, 4) for colors mode, with the top-left corner of the framebuffer at index [0, 0] in the returned array. If ‘mode’ is depth or stencil then the last dimension is 1.
set_blend_color
Set the blend color
Color to use. See vispy.color.Color for options.
set_blend_equation
Specify the equation for RGB and alpha blending
Mode for RGB.
Mode for Alpha. If None, mode_rgb is used.
mode_rgb
Notes
See set_blend_equation for valid modes.
set_blend_func
Specify pixel arithmetic for RGB and alpha
Source RGB factor.
Destination RGB factor.
Source alpha factor. If None, srgb is used.
srgb
Destination alpha factor. If None, drgb is used.
drgb
Set the screen clear color
This is a wrapper for gl.glClearColor.
Alpha to use.
Set the clear value for the depth buffer
This is a wrapper for gl.glClearDepth.
The depth to use.
Set the clear value for the stencil buffer
This is a wrapper for gl.glClearStencil.
The index to use when the stencil buffer is cleared.
set_color_mask
Toggle writing of frame buffer color components
Red toggle.
Green toggle.
Blue toggle.
Alpha toggle.
set_cull_face
Set front, back, or both faces to be culled
Culling mode. Can be “front”, “back”, or “front_and_back”.
set_depth_func
Specify the value used for depth buffer comparisons
The depth comparison function. Must be one of ‘never’, ‘less’, ‘equal’, ‘lequal’, ‘greater’, ‘gequal’, ‘notequal’, or ‘always’.
set_depth_mask
Toggle writing into the depth buffer
Whether depth writing should be enabled.
set_depth_range
Set depth values
Near clipping plane.
Far clipping plane.
set_front_face
Set which faces are front-facing
Can be ‘cw’ for clockwise or ‘ccw’ for counter-clockwise.
set_hint
Set OpenGL drawing hint
The target, e.g. ‘fog_hint’, ‘line_smooth_hint’, ‘point_smooth_hint’.
The mode to set (e.g., ‘fastest’, ‘nicest’, ‘dont_care’).
set_line_width
Set line width
The line width.
set_polygon_offset
Set the scale and units used to calculate depth values
Scale factor used to create a variable depth offset for each polygon.
Multiplied by an implementation-specific value to create a constant depth offset.
set_sample_coverage
Specify multisample coverage parameters
Sample coverage value (will be clamped between 0. and 1.).
Specify if the coverage masks should be inverted.
set_scissor
Define the scissor box
Left corner of the box.
Lower corner of the box.
The width of the box.
The height of the box.
set_state
Set OpenGL rendering state, optionally using a preset
Can be one of (‘opaque’, ‘translucent’, ‘additive’) to use use reasonable defaults for these typical use cases.
Other supplied keyword arguments will override any preset defaults. Options to be enabled or disabled should be supplied as booleans (e.g., 'depth_test=True', cull_face=False), non-boolean entries will be passed as arguments to set_* functions (e.g., blend_func=('src_alpha', 'one') will call set_blend_func).
'depth_test=True'
cull_face=False
set_*
blend_func=('src_alpha', 'one')
This serves three purposes:
Set GL state using reasonable presets.
Wrapping glEnable/glDisable functionality.
Convienence wrapping of other gloo.set_* functions.
gloo.set_*
For example, one could do the following:
>>> from vispy import gloo >>> gloo.set_state('translucent', depth_test=False, clear_color=(1, 1, 1, 1)) # noqa, doctest:+SKIP
This would take the preset defaults for ‘translucent’, turn depth testing off (which would normally be on for that preset), and additionally set the glClearColor parameter to be white.
Another example to showcase glEnable/glDisable wrapping:
>>> gloo.set_state(blend=True, depth_test=True, polygon_offset_fill=False) # noqa, doctest:+SKIP
This would be equivalent to calling
>>> from vispy.gloo import gl >>> gl.glDisable(gl.GL_BLEND) >>> gl.glEnable(gl.GL_DEPTH_TEST) >>> gl.glEnable(gl.GL_POLYGON_OFFSET_FILL)
Or here’s another example:
>>> gloo.set_state(clear_color=(0, 0, 0, 1), blend=True, blend_func=('src_alpha', 'one')) # noqa, doctest:+SKIP
Thus arbitrary GL state components can be set directly using set_state. Note that individual functions are exposed e.g., as set_clear_color, with some more informative docstrings about those particular functions.
set_stencil_func
Set front or back function and reference value
See set_stencil_func.
Reference value for the stencil test.
Mask that is ANDed with ref and stored stencil value.
Can be ‘front’, ‘back’, or ‘front_and_back’.
set_stencil_mask
Control the front or back writing of individual bits in the stencil
set_stencil_op
Set front or back stencil test actions
Action to take when the stencil fails. Must be one of ‘keep’, ‘zero’, ‘replace’, ‘incr’, ‘incr_wrap’, ‘decr’, ‘decr_wrap’, or ‘invert’.
Action to take when the stencil passes.
Action to take when both the stencil and depth tests pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled.
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.