Textures¶
-
Context.
texture
(size, components, data=None, samples=0, floats=False) → Texture Create a
Texture
.Parameters: - size (tuple) – Width, height.
- components (int) – The number of components 1, 2, 3 or 4.
- alignment (int) – The byte alignment 1, 2, 4 or 8.
- data (bytes) – Content of the image.
Keyword Arguments: floats (bool) – Use floating point precision.
Returns: texture
Return type:
-
Context.
depth_texture
(size, data=None, samples=0) → Texture Create a
Texture
.Parameters: - size (tuple) – Width, height.
- alignment (int) – The byte alignment 1, 2, 4 or 8.
- data (bytes) – Content of the image.
Returns: depth texture
Return type:
-
class
Texture
¶ A Texture is an OpenGL object that contains one or more images that all have the same image format. A texture can be used in two ways. It can be the source of a texture access from a Shader, or it can be used as a render target.
A Texture object cannot be instantiated directly, it requires a context. Use
Context.texture()
orContext.depth_texture()
to create one.-
read
(viewport=None, alignment=1) → bytes¶ Read the content of the texture.
-
read_into
(buffer, viewport=None, alignment=1)¶ Read the content of the texture.
-
write
(data, viewport=None)¶ Update the content of the texture.
-
use
(location=0)¶ Bind the texture.
Parameters: location (int) – The texture location. Same as the integer value that is used for sampler2D uniforms in the shaders. The value 0
will bind the texture to theGL_TEXTURE0
binding point.
-
width
¶ int – The width of the texture.
-
height
¶ int – The height of the texture.
-
size
¶ tuple – The size of the texture.
-
samples
¶ int – The number of samples of the texture.
-
components
¶ int – The number of components of the texture.
-
depth
¶ bool – Is the texture a depth texture?
-