fsleyes.gl.textures.texture2d
¶
This module provides the Texture2D
and DepthTexture
classes.
-
class
fsleyes.gl.textures.texture2d.
DepthTexture
(name)¶ Bases:
fsleyes.gl.textures.texture.Texture
The
DepthTexture
class is a 2DGL_DEPTH_COMPONENT24
texture which is used by theRenderTexture
class.A
DepthTexture
is configured by setting itsTexture.shape()
property to the desired width/height.-
__init__
(name)¶ Create a
DepthTexture
- Parameters
name – Unique name for this texture
-
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
()¶ Refreshes this
DepthTexture
based on the currentTexture.shape()
.
-
__module__
= 'fsleyes.gl.textures.texture2d'¶
-
-
class
fsleyes.gl.textures.texture2d.
Texture2D
(name, **kwargs)¶ Bases:
fsleyes.gl.textures.texture.Texture
The
Texture2D
class represents a 2D texture. ATexture2D
instance 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. theRenderTexture
class, a sub-class ofTexture2D
).
-
__init__
(name, **kwargs)¶ Create a
Texture2D
instance.- Parameters
name – Unique name for this
Texture2D
.
-
doRefresh
()¶ Overrides
Texture.doRefresh()
. Configures thisTexture2D
. This includes setting up interpolation, and setting the texture size and data.
-
draw
(vertices=None, xform=None, textureUnit=None)¶ Draw the contents of this
Texture2D
to a region specified by the given vertices. The texture is bound to texture unit 0.- Parameters
vertices – A
numpy
array of shape6 * 3
specifying the region, made up of two triangles, to which thisTexture2D
should 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)¶ Draws the contents of this
Texture2D
to 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)¶ Generates a set of vertices suitable for passing to the
Texture2D.draw()
method, for drawing aTexture2D
to 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
()¶ 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'¶
-
getBitmap
()¶ Returns the data stored in this
Texture2D
as anumpy.uint8
array of shape(height, width, 4)
.