Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def read_into(self, buffer, *, alignment=1, write_offset=0) -> None:
'''
Read the content of the texture array into a buffer.
Args:
buffer (bytearray): The buffer that will receive the pixels.
Keyword Args:
alignment (int): The byte alignment of the pixels.
write_offset (int): The write offset.
'''
if type(buffer) is Buffer:
buffer = buffer.mglo
return self.mglo.read_into(buffer, alignment, write_offset)
def write(self, data, viewport=None, *, alignment=1) -> None:
'''
Update the content of the texture.
Args:
data (bytes): The pixel data.
viewport (tuple): The viewport.
Keyword Args:
alignment (int): The byte alignment of the pixels.
'''
if type(data) is Buffer:
data = data.mglo
self.mglo.write(data, viewport, alignment)
def write(self, face, data, viewport=None, *, alignment=1) -> None:
'''
Update the content of the texture.
Args:
face (int): The face to update.
data (bytes): The pixel data.
viewport (tuple): The viewport.
Keyword Args:
alignment (int): The byte alignment of the pixels.
'''
if type(data) is Buffer:
data = data.mglo
self.mglo.write(face, data, viewport, alignment)
def read_into(self, buffer, *, level=0, alignment=1, write_offset=0) -> None:
'''
Read the content of the texture into a buffer.
Args:
buffer (bytearray): The buffer that will receive the pixels.
Keyword Args:
level (int): The mipmap level.
alignment (int): The byte alignment of the pixels.
write_offset (int): The write offset.
'''
if type(buffer) is Buffer:
buffer = buffer.mglo
return self.mglo.read_into(buffer, level, alignment, write_offset)
Args:
data (bytes): Content of the new buffer.
Keyword Args:
reserve (int): The number of bytes to reserve.
dynamic (bool): Treat buffer as dynamic.
Returns:
:py:class:`Buffer` object
'''
if type(reserve) is str:
reserve = mgl.strsize(reserve)
res = Buffer.__new__(Buffer)
res.mglo, res._size, res._glo = self.mglo.buffer(data, reserve, dynamic)
res._dynamic = dynamic
res.ctx = self
res.extra = None
return res
def vertex_array(self, *args, **kwargs) -> 'VertexArray':
if len(args) > 2 and type(args[1]) is Buffer:
return self.simple_vertex_array(*args, **kwargs)
return self._vertex_array(*args, **kwargs)
'''
Read the content of the framebuffer into a buffer.
Args:
buffer (bytearray): The buffer that will receive the pixels.
viewport (tuple): The viewport.
components (int): The number of components to read.
Keyword Args:
attachment (int): The color attachment.
alignment (int): The byte alignment of the pixels.
dtype (str): Data type.
write_offset (int): The write offset.
'''
if type(buffer) is Buffer:
buffer = buffer.mglo
return self.mglo.read_into(buffer, viewport, components, attachment, alignment, dtype, write_offset)