DepthTexture¶
-
demosys.opengl.
DepthTexture
¶ A DepthTexture is a texture for storing depth information during rendering. They are attachments to
demosys.opengl.FBO
.
Create¶
-
classmethod
DepthTexture.
create
(size, data=None, samples=0, alignment=4) → DepthTexture¶ Creates a
DepthTexture
objectParameters: - size – (tuple) The width and height of the texture.
- data – (bytes) Content of the texture.
- samples – The number of samples. Value 0 means no multisample format.
- alignment – The byte alignment 1, 2, 4 or 8.
Returns: DepthTexture
object
Methods¶
-
DepthTexture.
use
(location=0)¶ Bind the texture to a channel/location.
Parameters: location – The texture location. (GL_TEXTURE0 + location)
-
DepthTexture.
draw
(near, far, pos=(0.0, 0.0), scale=(1.0, 1.0))¶ Draw depth buffer linearized. By default this will draw the texture as a full screen quad. A sampler will be used to ensure the right conditions to draw the depth buffer.
Parameters: - near – Near plane in projection
- far – Far plane in projection
- pos – (tuple) offset x, y
- scale – (tuple) scale x, y
-
DepthTexture.
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
-
DepthTexture.
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.
-
DepthTexture.
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.
-
DepthTexture.
release
()¶ Release/free the ModernGL object
Attributes¶
-
DepthTexture.
size
¶ The size of the texture
-
DepthTexture.
width
¶ int: Width of the texture
-
DepthTexture.
compare_func
¶ tuple: The compare function of the depth texture
-
DepthTexture.
height
¶ int: Height of the texture
-
DepthTexture.
dtype
¶ str: The data type of the texture
-
DepthTexture.
components
¶ int: The number of components in the texture
-
DepthTexture.
samples
¶ int: The number of samples of the texture
-
DepthTexture.
repeat_x
¶ bool: The repeat_x of the texture
-
DepthTexture.
repeat_y
¶ bool: The repeat_y of the texture
-
DepthTexture.
filter
¶ tuple: (min, mag) filtering of the texture
-
DepthTexture.
anisotropy
¶ float: Number of samples for anisotropic filtering. Any value greater than 1.0 counts as a use of anisotropic filtering
-
DepthTexture.
depth
¶ Is this a depth texture?
-
DepthTexture.
swizzle
¶ str: The swizzle of the texture
-
DepthTexture.
size
The size of the texture
-
DepthTexture.
ctx
¶ ModernGL context
-
DepthTexture.
glo
¶ int: The internal OpenGL object. This values is provided for debug purposes only.