TextureCube¶
-
class
moderngl.
TextureCube
¶ 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 Texture3D object cannot be instantiated directly, it requires a context. Use
Context.texture_cube()
to create one.
Create¶
-
Context.
texture_cube
(size, components, data=None, alignment=1, dtype='f1') → TextureCube Create a
TextureCube
object.Parameters: - size (tuple) – The width, height and depth of the texture.
- components (int) – The number of components 1, 2, 3 or 4.
- data (bytes) – Content of the texture.
Keyword Arguments: - alignment (int) – The byte alignment 1, 2, 4 or 8.
- dtype (str) – Data type.
Returns: TextureCube
object
Methods¶
-
TextureCube.
read
(face, alignment=1) → bytes¶ Read a face from the cubemap texture.
Parameters: face (int) – The face to read. Keyword Arguments: alignment (int) – The byte alignment of the pixels.
-
TextureCube.
read_into
(buffer, face, alignment=1, write_offset=0)¶ Read a face from the cubemap texture.
Parameters: - buffer (bytearray) – The buffer that will receive the pixels.
- face (int) – The face to read.
Keyword Arguments: - alignment (int) – The byte alignment of the pixels.
- write_offset (int) – The write offset.
-
TextureCube.
write
(face, data, viewport=None, alignment=1)¶ Update the content of the texture.
Parameters: - face (int) – The face to update.
- data (bytes) – The pixel data.
- viewport (tuple) – The viewport.
Keyword Arguments: alignment (int) – The byte alignment of the pixels.
-
TextureCube.
use
(location=0)¶ Bind the cubemap texture.
Parameters: location (int) – The texture location. Same as the integer value that is used for sampler3D uniforms in the shaders. The value 0
will bind the texture to theGL_TEXTURE0
binding point.