Texture stores 2D-texture data. See Introduction To Textures in Direct3D 11.
Parameters: |
|
---|
Creates a new Texture.
Note
This function does not report certain errors unless Direct3D debug runtime is used.
Performs a hardware copy. Both textures must be very similar (size, format and flags) for this to work. If the source texture is multisampled use resolve().
Parameters: |
|
---|
Note
This function does not report certain errors unless Direct3D debug runtime is used.
Performs a hardware copy to a region. Only the first mipmap level will be copied so it is usually neccesarily to use filter() on the destination texture.
Parameters: |
|
---|
Filters the first mipmap level to lower levels. If you have modified the texture this is often required to apply changes to other mipmap levels.
Returns Texture’s description as a named tuple. size is a normal tuple of four elements: (width, height, arraysize, mipmapcount).
Returns a format string describing one pixel. Compatible with the struct-module. Note that some formats (DXGI_FORMAT_R10G10B10A2_UINT, DXGI_FORMAT_D24_UNORM_S8_UINT etc.) cannot be represented 100% accurately so they are treated as a bunch on bytes.
Returns the size of one pixel in bytes.
Parameters: |
|
---|
Maps the Texture for CPU-access. Some Texture types can’t be mapped or can be mapped only for reading or writing.
Note
This function does not report certain errors unless Direct3D debug runtime is used.
Resolves (copies) a multisampled source texture into a normal texture.
Parameters: |
|
---|
Saves the texture to a file. Only IFF_DDS image format is capable of supporting all texture formats. All .dds-files can also include an extra DDS_HEADER_DXT10-header which is a relatively new feature and not supported by all image readers.
Returns the width and height of a texture.
Unmaps a mapped texture.
Texture supports 2D-slicing to read or write data in byte form. All formats are not supported. Slicing methods do not support negative parameters. All operations use only the first mipmap level.
Slices the given area and returns a 1D-bytearray (Python >= 2.6) or a list (Python < 2.6) in a row-major order (C-style). Because returned values are in a 1D-form as bytes it is often easier to use this data through special adapter classes. d3d11x.Accessor is one example.
Slice assign.
This example creates a grid pattern by zeroing the red channel:
class Black:
def __getitem__(self, index):
return 0
t = Texture(...) #Assume some RGB(A)-compatible format
with Mapper(t, MAP_WRITE):
t[::3, ::3] = Black()
t.filter(FILTER_LINEAR)
Next example “brightens” a 75x50-sized area at (x=100, y=200, x2=175, y2=250). This also modifies alpha values which is not usually wanted.
t = Texture(...) #Assume some RGB(A)-compatible format
with Mapper(t, MAP_READ_WRITE):
t[100:175, 200:250] = [min(int(x * 1.5), 255) for x in t[100:175, 200:250]]
t.filter(FILTER_LINEAR)
This example retrieves one horizontal line (row) and one vertical line (column).
row = t[::, 55:56]
column = t[23:24, ::]
Warning
Care should be used when using buffer protocol as it is the responsibility of the programmer to ensure that the memory stays mapped as long as neccesarily and that it was mapped for correct access (read/write). Also the buffer protocol has no concept of a write-only buffer.
Texture supports Python’s buffer protocol. For example it is possible to directly manipulate textures’s mapped memory using memoryview or any other similar object.