TextureArray¶
-
demosys.opengl.
TextureArray
¶ A TextureArray is a texture where each mipmap level contains an array of images of the same size. Array textures may have Mipmaps, but each mipmap in the texture has the same number of levels.
The image data size must exactly match (width, height * layers)
Create¶
-
classmethod
TextureArray.
create
(size, components=4, data=None, alignment=1, dtype='f1', mipmap=False) → TextureArray¶ Parameters: - size – (x, y, layers) size and layers of the texture
- components – The number of components 1, 2, 3 or 4
- data – (bytes) Content of the texture
- alignment – The byte alignment 1, 2, 4 or 8
- dtype – (str) The data type
- mipmap – (bool) Generate mipmaps
Returns: TextureArray
object
Methods¶
-
TextureArray.
use
(location=0)¶ Bind the texture to a channel/location.
Parameters: location – The texture location. (GL_TEXTURE0 + location)
-
TextureArray.
build_mipmaps
(base=0, max_level=1000)¶ Build mipmaps for this texture
Parameters: - base – Level to build from
- max_level – Max levels
-
TextureArray.
set_image
(image, flip=True)¶ Set pixel data using a image file with PIL/Pillow. The image size must exactly match (width, height * layers)
Parameters: - image – The PIL/Pillow image object
- flip – Flip the image top to bottom
-
TextureArray.
read
(level:int=0, alignment:int=1) → bytes¶ Read the content of the texture into a buffer.
Parameters: - level – The mipmap level.
- alignment – The byte alignment of the pixels.
Returns: bytes
-
TextureArray.
read_into
(buffer:bytearray, level:int=0, alignment:int=1, write_offset:int=0)¶ Read the content of the texture into a buffer.
Parameters: - buffer – (bytearray) The buffer that will receive the pixels.
- level – (int) The mipmap level.
- alignment – (int) The byte alignment of the pixels.
- write_offset – (int) The write offset.
-
TextureArray.
write
(data:bytes, viewport=None, level:int=0, alignment:int=1)¶ Update the content of the texture.
Parameters: - data – (bytes) – The pixel data.
- viewport – (tuple) – The viewport.
- level – (int) – The mipmap level.
- alignment – (int) – The byte alignment of the pixels.
-
TextureArray.
release
()¶ Release/free the ModernGL object
Attributes¶
-
TextureArray.
size
¶ The size of the texture
-
TextureArray.
width
¶ int: Width of the texture
-
TextureArray.
height
¶ int: Height of the texture
-
TextureArray.
dtype
¶ str: The data type of the texture
-
TextureArray.
samples
¶ int: The number of samples of the texture
-
TextureArray.
components
¶ int: The number of components in the texture
-
TextureArray.
repeat_x
¶ bool: The repeat_x of the texture
-
TextureArray.
repeat_y
¶ bool: The repeat_y of the texture
-
TextureArray.
filter
¶ tuple: (min, mag) filtering of the texture
-
TextureArray.
anisotropy
¶ float: Number of samples for anisotropic filtering. Any value greater than 1.0 counts as a use of anisotropic filtering
-
TextureArray.
depth
¶ Is this a depth texture?
-
TextureArray.
swizzle
¶ str: The swizzle of the texture
-
TextureArray.
size
The size of the texture
-
TextureArray.
ctx
¶ ModernGL context
-
TextureArray.
glo
¶ int: The internal OpenGL object. This values is provided for debug purposes only.