# vispy.gloo.texture module

class vispy.gloo.texture.BaseTexture(data=None, format=None, resizable=True, interpolation=None, wrapping=None, shape=None, internalformat=None, resizeable=None)

  Bases: `GLObject`

  A Texture is used to represent a topological set of scalar values.

  Parameters:
    data ndarray | tuple | None

      Texture data in the form of a numpy array (or something that can be turned into one). A tuple with the shape of the texture can also be given.

    format str | enum | None

      The format of the texture: ‘luminance’, ‘alpha’, ‘luminance_alpha’, ‘rgb’, or ‘rgba’. If not given the format is chosen automatically based on the number of channels. When the data has one channel, ‘luminance’ is assumed.

    resizable bool

      Indicates whether texture can be resized. Default True.

    interpolation str | None

      Interpolation mode, must be one of: ‘nearest’, ‘linear’. Default ‘nearest’.

    wrapping str | None

      Wrapping mode, must be one of: ‘repeat’, ‘clamp_to_edge’, ‘mirrored_repeat’. Default ‘clamp_to_edge’.

    shape tuple | None

      Optional. A tuple with the shape of the texture. If `data` is also a tuple, it will override the value of `shape`.

    internalformat str | None

      Internal format to use.

    resizeable None

      Deprecated version of resizable.

  property format

    The texture format (color channels).

  property internalformat

    The texture internalformat.

  property interpolation

    Texture interpolation for minification and magnification.

  resize(shape, format=None, internalformat=None)

    Set the texture size and format

    Parameters:
      shape tuple of integers

        New texture shape in zyx order. Optionally, an extra dimention may be specified to indicate the number of color channels.

      format str | enum | None

        The format of the texture: ‘luminance’, ‘alpha’, ‘luminance_alpha’, ‘rgb’, or ‘rgba’. If not given the format is chosen automatically based on the number of channels. When the data has one channel, ‘luminance’ is assumed.

      internalformat str | enum | None

        The internal (storage) format of the texture: ‘luminance’, ‘alpha’, ‘r8’, ‘r16’, ‘r16f’, ‘r32f’; ‘luminance_alpha’, ‘rg8’, ‘rg16’, ‘rg16f’, ‘rg32f’; ‘rgb’, ‘rgb8’, ‘rgb16’, ‘rgb16f’, ‘rgb32f’; ‘rgba’, ‘rgba8’, ‘rgba16’, ‘rgba16f’, ‘rgba32f’. If None, the internalformat is chosen automatically based on the number of channels. This is a hint which may be ignored by the OpenGL implementation.

  set_data(data, offset=None, copy=False)

    Set texture data

    Parameters:
      data ndarray

        Data to be uploaded

      offset: int | tuple of ints

        Offset in texture where to start copying data

      copy: bool

        Since the operation is deferred, data may change before data is actually uploaded to GPU memory. Asking explicitly for a copy will prevent this behavior.

    Notes

    This operation implicitly resizes the texture to the shape of the data if given offset is None.

  property shape

    Data shape (last dimension indicates number of color channels)

  property wrapping

    Texture wrapping mode

class vispy.gloo.texture.Texture1D(data=None, format=None, resizable=True, interpolation=None, wrapping=None, shape=None, internalformat=None, resizeable=None)

  Bases: `BaseTexture`

  One dimensional texture

  Parameters:
    data ndarray | tuple | None

      Texture data in the form of a numpy array (or something that can be turned into one). A tuple with the shape of the texture can also be given.

    format str | enum | None

      The format of the texture: ‘luminance’, ‘alpha’, ‘luminance_alpha’, ‘rgb’, or ‘rgba’. If not given the format is chosen automatically based on the number of channels. When the data has one channel, ‘luminance’ is assumed.

    resizable bool

      Indicates whether texture can be resized. Default True.

    interpolation str | None

      Interpolation mode, must be one of: ‘nearest’, ‘linear’. Default ‘nearest’.

    wrapping str | None

      Wrapping mode, must be one of: ‘repeat’, ‘clamp_to_edge’, ‘mirrored_repeat’. Default ‘clamp_to_edge’.

    shape tuple | None

      Optional. A tuple with the shape of the texture. If `data` is also a tuple, it will override the value of `shape`.

    internalformat str | None

      Internal format to use.

    resizeable None

      Deprecated version of resizable.

  property glsl_sample

    GLSL function that samples the texture.

  property glsl_sampler_type

    GLSL type of the sampler.

  property glsl_type

    GLSL declaration strings required for a variable to hold this data.

  property width

    Texture width

class vispy.gloo.texture.Texture2D(data=None, format=None, resizable=True, interpolation=None, wrapping=None, shape=None, internalformat=None, resizeable=None)

  Bases: `BaseTexture`

  Two dimensional texture

  Parameters:
    data ndarray

      Texture data shaped as W, or a tuple with the shape for the texture (W).

    format str | enum | None

      The format of the texture: ‘luminance’, ‘alpha’, ‘luminance_alpha’, ‘rgb’, or ‘rgba’. If not given the format is chosen automatically based on the number of channels. When the data has one channel, ‘luminance’ is assumed.

    resizable bool

      Indicates whether texture can be resized. Default True.

    interpolation str

      Interpolation mode, must be one of: ‘nearest’, ‘linear’. Default ‘nearest’.

    wrapping str

      Wrapping mode, must be one of: ‘repeat’, ‘clamp_to_edge’, ‘mirrored_repeat’. Default ‘clamp_to_edge’.

    shape tuple

      Optional. A tuple with the shape HxW. If `data` is also a tuple, it will override the value of `shape`.

    internalformat str | None

      Internal format to use.

    resizeable None

      Deprecated version of resizable.

  property glsl_sample

    GLSL function that samples the texture.

  property glsl_sampler_type

    GLSL type of the sampler.

  property glsl_type

    GLSL declaration strings required for a variable to hold this data.

  property height

    Texture height

  property width

    Texture width

class vispy.gloo.texture.Texture3D(data=None, format=None, resizable=True, interpolation=None, wrapping=None, shape=None, internalformat=None, resizeable=None)

  Bases: `BaseTexture`

  Three dimensional texture

  Parameters:
    data ndarray | tuple | None

      Texture data in the form of a numpy array (or something that can be turned into one). A tuple with the shape of the texture can also be given.

    format str | enum | None

      The format of the texture: ‘luminance’, ‘alpha’, ‘luminance_alpha’, ‘rgb’, or ‘rgba’. If not given the format is chosen automatically based on the number of channels. When the data has one channel, ‘luminance’ is assumed.

    resizable bool

      Indicates whether texture can be resized. Default True.

    interpolation str | None

      Interpolation mode, must be one of: ‘nearest’, ‘linear’. Default ‘nearest’.

    wrapping str | None

      Wrapping mode, must be one of: ‘repeat’, ‘clamp_to_edge’, ‘mirrored_repeat’. Default ‘clamp_to_edge’.

    shape tuple | None

      Optional. A tuple with the shape of the texture. If `data` is also a tuple, it will override the value of `shape`.

    internalformat str | None

      Internal format to use.

    resizeable None

      Deprecated version of resizable.

  property depth

    Texture depth

  property glsl_sample

    GLSL function that samples the texture.

  property glsl_sampler_type

    GLSL type of the sampler.

  property glsl_type

    GLSL declaration strings required for a variable to hold this data.

  property height

    Texture height

  property width

    Texture width

class vispy.gloo.texture.TextureAtlas(shape=(1024, 1024), dtype=<class 'numpy.float32'>)

  Bases: `Texture2D`

  Group multiple small data regions into a larger texture.

  The algorithm is based on the article by Jukka Jylänki : “A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing”, February 27, 2010. More precisely, this is an implementation of the Skyline Bottom-Left algorithm based on C++ sources provided by Jukka Jylänki at: http://clb.demon.fi/files/RectangleBinPack/.

  Parameters:
    shape tuple of int

      Texture shape (optional).

    dtype numpy.dtype object

      Texture starting data type (default: float32)

  Notes

  This creates a 2D texture that holds 1D float32 data. An example of simple access:

      >>> atlas = TextureAtlas()
      >>> bounds = atlas.get_free_region(20, 30)
      >>> atlas.set_region(bounds, np.random.rand(20, 30).T)

  get_free_region(width, height)

    Get a free region of given size and allocate it

    Parameters:
      width int

        Width of region to allocate

      height int

        Height of region to allocate

    Returns:
      bounds tuple | None

        A newly allocated region as (x, y, w, h) or None (if failed).

class vispy.gloo.texture.TextureCube(data=None, format=None, resizable=True, interpolation=None, wrapping=None, shape=None, internalformat=None, resizeable=None)

  Bases: `BaseTexture`

  Texture Cube

  Parameters:
    data ndarray | tuple | None

      Texture data in the form of a numpy array (or something that can be turned into one). A tuple with the shape of the texture can also be given.

    format str | enum | None

      The format of the texture: ‘luminance’, ‘alpha’, ‘luminance_alpha’, ‘rgb’, or ‘rgba’. If not given the format is chosen automatically based on the number of channels. When the data has one channel, ‘luminance’ is assumed.

    resizable bool

      Indicates whether texture can be resized. Default True.

    interpolation str | None

      Interpolation mode, must be one of: ‘nearest’, ‘linear’. Default ‘nearest’.

    wrapping str | None

      Wrapping mode, must be one of: ‘repeat’, ‘clamp_to_edge’, ‘mirrored_repeat’. Default ‘clamp_to_edge’.

    shape tuple | None

      Optional. A tuple with the shape of the texture. If `data` is also a tuple, it will override the value of `shape`.

    internalformat str | None

      Internal format to use.

    resizeable None

      Deprecated version of resizable.

  property depth

    Texture depth

  property glsl_sample

    GLSL function that samples the texture.

  property glsl_sampler_type

    GLSL type of the sampler.

  property glsl_type

    GLSL declaration strings required for a variable to hold this data.

  property height

    Texture height

  property width

    Texture width

class vispy.gloo.texture.TextureEmulated3D(data=None, format=None, resizable=True, interpolation=None, wrapping=None, shape=None, internalformat=None, resizeable=None)

  Bases: `Texture2D`

  Two dimensional texture that is emulating a three dimensional texture

  Parameters:
    data ndarray | tuple | None

      Texture data in the form of a numpy array (or something that can be turned into one). A tuple with the shape of the texture can also be given.

    format str | enum | None

      The format of the texture: ‘luminance’, ‘alpha’, ‘luminance_alpha’, ‘rgb’, or ‘rgba’. If not given the format is chosen automatically based on the number of channels. When the data has one channel, ‘luminance’ is assumed.

    resizable bool

      Indicates whether texture can be resized. Default True.

    interpolation str | None

      Interpolation mode, must be one of: ‘nearest’, ‘linear’. Default ‘nearest’.

    wrapping str | None

      Wrapping mode, must be one of: ‘repeat’, ‘clamp_to_edge’, ‘mirrored_repeat’. Default ‘clamp_to_edge’.

    shape tuple | None

      Optional. A tuple with the shape of the texture. If `data` is also a tuple, it will override the value of `shape`.

    internalformat str | None

      Internal format to use.

    resizeable None

      Deprecated version of resizable.

  property depth

    Texture depth

  property glsl_sample

    GLSL function that samples the texture.

  property height

    Texture height

  resize(shape, format=None, internalformat=None)

    Set the texture size and format

    Parameters:
      shape tuple of integers

        New texture shape in zyx order. Optionally, an extra dimention may be specified to indicate the number of color channels.

      format str | enum | None

        The format of the texture: ‘luminance’, ‘alpha’, ‘luminance_alpha’, ‘rgb’, or ‘rgba’. If not given the format is chosen automatically based on the number of channels. When the data has one channel, ‘luminance’ is assumed.

      internalformat str | enum | None

        The internal (storage) format of the texture: ‘luminance’, ‘alpha’, ‘r8’, ‘r16’, ‘r16f’, ‘r32f’; ‘luminance_alpha’, ‘rg8’, ‘rg16’, ‘rg16f’, ‘rg32f’; ‘rgb’, ‘rgb8’, ‘rgb16’, ‘rgb16f’, ‘rgb32f’; ‘rgba’, ‘rgba8’, ‘rgba16’, ‘rgba16f’, ‘rgba32f’. If None, the internalformat is chosen automatically based on the number of channels. This is a hint which may be ignored by the OpenGL implementation.

  set_data(data, offset=None, copy=False)

    Set texture data

    Parameters:
      data ndarray

        Data to be uploaded

      offset: int | tuple of ints

        Offset in texture where to start copying data

      copy: bool

        Since the operation is deferred, data may change before data is actually uploaded to GPU memory. Asking explicitly for a copy will prevent this behavior.

    Notes

    This operation implicitely resizes the texture to the shape of the data if given offset is None.

  property shape

    Data shape (last dimension indicates number of color channels)

  property width

    Texture width

vispy.gloo.texture.convert_dtype_and_clip(data, dtype, copy=False)

  cast dtype to a new one, but first clip data to the new dtype’s limits if needed

vispy.gloo.texture.downcast_to_32bit_if_needed(data, copy=False, dtype=None)

  Downcast to 32bit dtype if necessary.

vispy.gloo.texture.get_dtype_limits(dtype)

previous

vispy.gloo.program module

next

vispy.gloo.util module