fsleyes.gl.textures.texture2d¶
This module provides the Texture2D and DepthTexture
classes.
-
class
fsleyes.gl.textures.texture2d.DepthTexture(name)[source]¶ Bases:
fsleyes.gl.textures.texture.TextureThe
DepthTextureclass is a 2DGL_DEPTH_COMPONENT24texture which is used by theRenderTextureclass.A
DepthTextureis configured by setting itsTexture.shape()property to the desired width/height.-
property
dtype¶ Overrides
Texture.dtype().
-
property
textureType¶ Overrides
Texture.textureType().
-
property
baseFormat¶ Overrides
Texture.baseFormat().
-
property
internalFormat¶ Overrides
Texture.internalFormat().
-
property
data¶ Returns the data that has been passed to the
set()method.
-
doRefresh()[source]¶ Refreshes this
DepthTexturebased on the currentTexture.shape().
-
__module__= 'fsleyes.gl.textures.texture2d'¶
-
property
-
class
fsleyes.gl.textures.texture2d.Texture2D(name, **kwargs)[source]¶ Bases:
fsleyes.gl.textures.texture.TextureThe
Texture2Dclass represents a 2D texture. ATexture2Dinstance can be used in one of two ways:Setting the texture data via the
Texture.data()method, and then drawing it to a scene viadraw()ordrawOnBounds().Setting the texture size via
Texture.shape(), and then drawing to it by some other means (see e.g. theRenderTextureclass, a sub-class ofTexture2D).
-
__init__(name, **kwargs)[source]¶ Create a
Texture2Dinstance.- Parameters
name – Unique name for this
Texture2D.
-
doRefresh()[source]¶ Overrides
Texture.doRefresh(). Configures thisTexture2D. This includes setting up interpolation, and setting the texture size and data.
-
shapeData(data, oldShape=None)[source]¶ Overrides
Texture.shapeData().This method is used by
Texture2Dsub-classes which are used to store 3D image data (e.g. theImageTexture2Dclass). It shapes the data, ensuring that it is compatible with a 2D texture.- Parameters
data –
numpyarray containing the dataoldShape – Original data shape; if not provided, is taken from
data.
-
texCoordXform(origShape)[source]¶ Overrides
Texture.texCoordXform().Returns an affine matrix which encodes a rotation that maps the two major axes of the image voxel coordinate system to the first two axes of the texture coordinate system.
This method is used by sub-classes which are being used to store 3D image data, e.g. the
ImageTexture2DandSelectionTexture2Dclasses.If this texture does not have any data yet, this method will return
None.
-
doPatch(data, offset)[source]¶ Overrides
Texture.doPatch(). Updates part of the texture data.
-
draw(vertices=None, xform=None, textureUnit=None)[source]¶ Draw the contents of this
Texture2Dto a region specified by the given vertices. The texture is bound to texture unit 0.- Parameters
vertices – A
numpyarray of shape6 * 3specifying the region, made up of two triangles, to which thisTexture2Dshould be drawn. IfNone, it is assumed that the vertices and texture coordinates have already been configured (e.g. via a shader program).xform – A transformation to be applied to the vertices. Ignored if
vertices is None.textureUnit – Texture unit to bind to. Defaults to
gl.GL_TEXTURE0.
-
drawOnBounds(zpos, xmin, xmax, ymin, ymax, xax, yax, *args, **kwargs)[source]¶ Draws the contents of this
Texture2Dto a rectangle. This is a convenience method which creates a set of vertices, and passes them to thedraw()method.- Parameters
zpos – Position along the Z axis, in the display coordinate system.
xmin – Minimum X axis coordinate.
xmax – Maximum X axis coordinate.
ymin – Minimum Y axis coordinate.
ymax – Maximum Y axis coordinate.
xax – Display space axis which maps to the horizontal screen axis.
yax – Display space axis which maps to the vertical screen axis.
All other arguments are passed to the
draw()method.
-
classmethod
generateVertices(zpos, xmin, xmax, ymin, ymax, xax, yax, xform=None)[source]¶ Generates a set of vertices suitable for passing to the
Texture2D.draw()method, for drawing aTexture2Dto a 2D canvas.- Parameters
zpos – Position along the Z axis, in the display coordinate system.
xmin – Minimum X axis coordinate.
xmax – Maximum X axis coordinate.
ymin – Minimum Y axis coordinate.
ymax – Maximum Y axis coordinate.
xax – Display space axis which maps to the horizontal screen axis.
yax – Display space axis which maps to the vertical screen axis.
xform – Transformation matrix to appply to vertices.
-
classmethod
generateTextureCoords()[source]¶ Generates a set of texture coordinates for drawing a
Texture2D. This function is used by theTexture2D.draw()method.
-
_Texture2D__prepareCoords(vertices, xform=None)¶ Called by
draw(). Prepares vertices, texture coordinates and indices for drawing the texture.If
vertices is None, it is assumed that the caller has already assigned vertices and texture coordinates, either via a shader, or via vertex/texture coordinate pointers. In this case,- Returns
A tuple containing the vertices, texture coordinates, and indices, or
(None, None, indices)ifvertices is None
-
__module__= 'fsleyes.gl.textures.texture2d'¶