This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
Полезные советы
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Программирование
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::Texture Class

Header: #include <UnigineTextures.h>

Interface for handling textures.

Textures are stored on GPU.

Unigine provides different filtering modes of texture samples:

  1. Point filtering
  2. Linear filtering
  3. Bilinear filtering
  4. Trilinear filtering
  5. Anisotropic filtering

They are ordered from the worst visual quality to the best, thus from the least expensive performance cost to the most.

Texture Class

Members


int is2DType ( ) #

Returns a value indicating if the texture is 2D texture.

Return value

1 if the texture is 2D; otherwise, 0.

int is3DType ( ) #

Returns a value indicating if the texture is 3D texture.

Return value

1 if the texture is 3D; otherwise, 0.

int isAnisotropy ( ) #

Checks texture anisotropy.

Return value

1 if the texture filter is anisotropy, otherwise, 0.

int isArrayType ( ) #

Returns a value indicating if the texture is Array texture.

Return value

1 if the texture type is an array; otherwise, 0.

int isBilinear ( ) #

Checks texture filter.

Return value

1 if the texture filter is bilinear or trilinear.

int isColorFormat ( ) #

Returns a value indicating if the texture is color texture.

Return value

1 if the texture is color texture; otherwise, 0.

int isCombinedFormat ( ) #

Returns a value indicating if the texture is stored in a combined format (RGB565, RGBA4, RGB5A1, R24B8, or RGB10A2).

Return value

1 if the texture is in combined format; otherwise, 0.

int isCompressedFormat ( ) #

Returns a value indicating if the texture is stored in a compressed format (DXT1, DXT3, DXT5, ATI1, ATI2, ZLC1 or ZLC2).

Return value

1 if the texture is in a compressed format; otherwise, 0.

int isCubeType ( ) #

Returns a value indicating if the texture is Cube texture.

Return value

true if the texture type is cube; otherwise, false.

bool isValid ( ) #

Returns a value indicating if the texture is valid (null-pointer check).

Return value

true if the texture is valid; otherwise, false.

void * getD3D11DepthStencilView ( ) #

Returns Direct3D11 depth stencil view.

void * getD3D11DepthStencilView ( int index ) #

Returns Direct3D11 depth stencil view.

Arguments

  • int index - Index.

void * getD3D11RenderTargetView ( int index ) #

Returns Direct3D11 render target view.

Arguments

  • int index - Index.

void * getD3D11RenderTargetView ( ) #

Returns Direct3D11 render target view.

void * getD3D11ShaderResourceView ( ) #

Returns Direct3D11 render target view.

void * getD3D11Texture ( ) #

Returns Direct3D11 texture.

void * getD3D11UnorderedAccessView ( int r32_typeless ) #

Returns Direct3D11 render target view.

Arguments

  • int r32_typeless

int getDepth ( int level = 0 ) #

Returns the depth for the given texture mipmap level.

Arguments

Return value

Texture mipmap level depth.

int isDepthFormat ( ) #

Returns a value indicating if the texture is depth texture.

Return value

1 if the texture is depth texture; otherwise, 0.

void setFlags ( int flags ) #

Sets texture flags.

Arguments

  • int flags - Texture flags.

int getFlags ( ) #

Returns texture flags.

Return value

Texture flags.

int isFloatFormat ( ) #

Returns a value indicating if the texture is stored in a float format (R32F, RG32F, RGB32F or RGBA32F).

Return value

1 if the texture is in float format; otherwise, 0.

int getFormat ( ) #

Gets the texture format.

Return value

Texture format.

const char * getFormatName ( ) #

Gets the texture format name.

Return value

Texture format name.

int getGLInternalFormat ( ) #

Returns OpenGL internal format.

Return value

OpenGL internal format.

int getGLPixelFormat ( ) #

Returns OpenGL pixel format.

Return value

OpenGL pixel format.

int getGLPixelType ( ) #

Returns OpenGL pixel type.

Return value

OpenGL pixel type.

int getGLTarget ( ) #

Returns OpenGL texture target.

Return value

OpenGL texture target.

int getGLTextureID ( ) #

Returns OpenGL texture identifier.

Return value

OpenGL texture identifier.

int isHalfFormat ( ) #

Returns a value indicating if the texture is stored in a half-float format (R16F, RG16F, RGB16F or RGBA16F).

Return value

1 if the texture is in half-float format; otherwise, 0.

int getHeight ( int level = 0 ) #

Returns the height for the specified texture mipmap level.

Arguments

Return value

Texture mipmap level height.

int setImage ( const Ptr<Image> & image ) #

Sets texture data using the data of the specified source image.

Arguments

  • const Ptr<Image> & image - Source image to be used for setting texture data.

Return value

1 if the data was set successfully; otherwise, 0.

int getImage ( const Ptr<Image> & image ) #

Gets texture data and puts it to the specified target image.

Arguments

  • const Ptr<Image> & image - Target image, to which the texture data is to be put.

Return value

1 if the data was received; otherwise, 0.

int setImage2D ( const Ptr<Image> & image, int offset_x, int offset_y, int texture_format = -1 ) #

Sets texture data using the data of the specified 2D or 2D array image.
Notice
The following conditions must be satisfied:
  • Both texture and image types must be either 2D or 2D_ARRAY.
  • Texture resolution must be greater or equal to the image resolution.
  • Image and texture mipmap counts must be equal (the same is for layer counts of 2D arrays).

Arguments

  • const Ptr<Image> & image - Source image to be used for setting texture data.
  • int offset_x - Offset along the X axis (in pixels) starting from which the data of the specified image is to be taken. The following condition must be satisfied: offset_x < texture_width - image_width.
  • int offset_y - Offset along the Y axis (in pixels) starting from which the data of the specified image is to be taken. The following condition must be satisfied: offset_y < texture_height - image_height.
  • int texture_format - Texture format identifier (see the FORMAT_* variables), or -1 - auto-detect.

Return value

1 if the data was set successfully; otherwise, 0.

int setImageLayer ( const Ptr<Image> & image, int layer, int texture_format = -1 ) #

Sets the data of the specified layer of the 2D texture array using the data of the specified 2D image.
Notice
The following conditions must be satisfied:
  • Texture and image must have the same resolution.
  • Image and texture mipmap counts must be equal (the same is for layer counts of 2D arrays).

Arguments

  • const Ptr<Image> & image - Source image to be used for setting the data of the 2D texture array layer.
  • int layer - Number of the 2D texture array layer, for which the data is to be set.
  • int texture_format - Texture format identifier (see the FORMAT_* variables), or -1 - auto-detect.

Return value

1 if the data was set successfully; otherwise, 0.

int getMultisample ( ) #

Returns the multisample count.

Return value

Multisample count.

int getNumChannels ( ) #

Returns the number of channels.

Return value

Number of channels.

int getNumFaces ( ) #

Returns a number of faces in the texture.

Return value

Number of faces.

int getNumLayers ( ) #

Returns a number of layers in the texture.

Return value

Number of layers.

int getNumMipmaps ( ) #

Returns the texture mipmap count.

Return value

Texture mipmap count.

int isRawFormat ( ) #

Returns a value indicating if the texture is uncompressed (stored in R8, RG8, RGB8, RGBA8, R16, RG16, RGB16, RGBA16, R16F, RG16F, RGB16F, RGBA16F, R32F, RG32F, RGB32F, RGBA32F, RGB565, RGBA4, RGB5A1, RGB10A2, R24B8, D16, D24, D24S8, D32F, or D32FS8 format).

Return value

1 if the texture is uncompressed; otherwise, 0.

int getType ( ) #

Gets the texture type.

Return value

Texture type.

const char * getTypeName ( ) #

Gets the texture type name.

Return value

Texture type name.

int isUCharFormat ( ) #

Returns a value indicating if the texture is stored in an unsigned char format (R8, RG8, RGB8, RGBA8, DXT1, DXT3, DXT5, ATI1 or ATI2).

Return value

1 if the texture is in unsigned char format; otherwise, 0.

int isUShortFormat ( ) #

Returns a value indicating if the texture is stored in an unsigned short format (R16, RG16, RGB16 or RGBA16).

Return value

1 if the texture is in unsigned short format; otherwise, 0.

int getWidth ( int level = 0 ) #

Returns the width for the specified texture mipmap level.

Arguments

Return value

Texture mipmap level width.

void bindCompute ( int unit ) #

Binds compute texture.

Arguments

  • int unit - Texture unit.

void bindFragment ( int unit ) #

Binds fragment texture.

Arguments

  • int unit - Texture unit.

void bindVertex ( int unit ) #

Binds vertex texture.

Arguments

  • int unit - Texture unit.

void clear ( ) #

Clears texture.

int copy2D ( int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, int w = -1, int h = -1 ) #

Copies 2D texture.

Arguments

  • int x0 - The offset of the source texture along the X-axis.
  • int y0 - The offset of the source texture along the Y-axis.
  • int x1 - The offset of the destination texture along the X-axis.
  • int y1 - The offset of the destination texture along the Y-axis.
  • int w - The width of the destination texture.
  • int h - The height of the destination texture.

Return value

1 if the texture was copied; otherwise, 0.

int copyCube ( int face, int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, int w = -1, int h = -1 ) #

Copies Cube texture.

Arguments

  • int face - The face of the cube.
  • int x0 - The offset of the source texture along the X-axis.
  • int y0 - The offset of the source texture along the Y-axis.
  • int x1 - The offset of the destination texture along the X-axis.
  • int y1 - The offset of the destination texture along the Y-axis.
  • int w - The width of the destination texture.
  • int h - The height of the destination texture.

Return value

1 if the texture was copied; otherwise, 0.

Ptr<Texture> create ( ) #

Texture constructor.

Return value

Pointer to the created texture.

int create ( const Ptr<Image> & image, int flags = DEFAULT_FLAGS ) #

Texture constructor.

Arguments

  • const Ptr<Image> & image - Image pointer.
  • int flags - Texture flags.

Return value

1 if the texture was created successfully; otherwise, 0.

int create2D ( int width, int height, int format, int flags = DEFAULT_FLAGS ) #

Creates 2D texture.

Arguments

  • int width - Texture width.
  • int height - Texture height.
  • int format - Texture format.
  • int flags - Texture flags.

Return value

1 if the texture was created successfully; otherwise, 0.

int create2DArray ( int width, int height, int num_layers, int format, int flags = DEFAULT_FLAGS ) #

Creates 2D Array texture.

Arguments

  • int width - Texture width.
  • int height - Texture height.
  • int num_layers - Texture layers.
  • int format - Texture format.
  • int flags - Texture flags.

Return value

1 if the 2D array texture was created; otherwise, 0.

int create3D ( int width, int height, int depth, int format, int flags = DEFAULT_FLAGS ) #

Creates 3D texture.

Arguments

  • int width - Texture width.
  • int height - Texture height.
  • int depth - Texture depth.
  • int format - Texture format.
  • int flags - Texture flags.

Return value

1 if the 3D texture was created; otherwise, 0.

int createCube ( int width, int height, int format, int flags = DEFAULT_FLAGS ) #

Creates Cube texture.

Arguments

  • int width - Texture width.
  • int height - Texture height.
  • int format - Texture format.
  • int flags - Texture flags.

Return value

1 if the cubemap texture was created; otherwise, 0.

int createCubeArray ( int width, int height, int num_layers, int format, int flags = DEFAULT_FLAGS ) #

Creates Cube Array texture.

Arguments

  • int width - Texture width.
  • int height - Texture height.
  • int num_layers - Texture layers.
  • int format - Texture format.
  • int flags - Texture flags.

Return value

1 if the cubemap texture array was created; otherwise, 0.

int createMipmaps ( ) #

Creates mipmaps stack.

Return value

1 if the mipmaps stack was created; otherwise, 0.

void destroy ( ) #

Destroys texture.

int fromD3D11Texture2D ( void * ptr, int width, int height, int format, int internal_format, int flags ) #

Creates 2D texture from external D3D11Texture pointer.

Arguments

  • void * ptr - Pointer to the D3D11 texture.
  • int width - Texture width.
  • int height - Texture height.
  • int format - Texture format.
  • int internal_format - Internal texture format.
  • int flags - Texture flags.

Return value

1 if the 2D texture from D3D11 was created; otherwise, 0.

int fromD3D11Texture2D ( void * ptr, int width, int height, int format, int flags ) #

Creates 2D texture from external D3D11Texture pointer.

Arguments

  • void * ptr - Pointer to the D3D11 texture.
  • int width - Texture width.
  • int height - Texture height.
  • int format - Texture format.
  • int flags - Texture flags.

Return value

1 if the 2D texture from D3D11 was created; otherwise, 0.

int fromGLTexture2D ( unsigned int tex_id, int width, int height, int format, int flags ) #

Creates texture from external GL texture ID.

Arguments

  • unsigned int tex_id - External GL texture ID
  • int width - Texture width.
  • int height - Texture height.
  • int format - Texture format.
  • int flags - Texture flags.

Return value

1 if the 2D texture from external GL texture ID was created; otherwise, 0.

int fromGLTexture2D ( unsigned int tex_id, int width, int height, int format, int internal_format, int flags ) #

Creates texture from external GL texture ID

Arguments

  • unsigned int tex_id - External GL texture ID
  • int width - Texture width.
  • int height - Texture height.
  • int format - Texture format.
  • int internal_format - Internal texture format.
  • int flags - Texture flags.

Return value

1 if the 2D texture from external GL texture ID was created; otherwise, 0.

int load ( const char * name, int flags = DEFAULT_FLAGS ) #

Loads texture from file.

Arguments

  • const char * name - File name.
  • int flags - Texture flags.

Return value

1 if the texture was loaded; otherwise, 0.

void render2D ( float x0 = -1.0f, float y0 = -1.0f, float x1 = 1.0f, float y1 = 1.0f ) #

Renders 2D texture. This function creates 4 vertices (2 polygons) by using 2 X-coordinates and 2 Y-coordinates and sends it to be rendered.

Arguments

  • float x0 - The first X-coordinate.
  • float y0 - The first Y-coordinate.
  • float x1 - The second X-coordinate.
  • float y1 - The second Y-coordinate.

void render2DArray ( int layer, float x0 = -1.0f, float y0 = -1.0f, float x1 = 1.0f, float y1 = 1.0f ) #

Renders 2D Array texture. This function creates 4 vertices (2 polygons) of the texture layer by using 2 X-coordinates and 2 Y-coordinates and sends it to be rendered.

Arguments

  • int layer - The number of layer.
  • float x0 - The first X-coordinate.
  • float y0 - The first Y-coordinate.
  • float x1 - The second X-coordinate.
  • float y1 - The second Y-coordinate.

void render2DScreen ( float x0 = -1.0f, float y0 = -1.0f, float x1 = 1.0f, float y1 = 1.0f ) #

Renders 2D Screen texture. This function creates 3 vertices (1 polygon) and and sends texture to be rendered inside the polygon to avoid artifacts on the edge of 2 polygons if the anti-aliasing is used.

Arguments

  • float x0 - The first X-coordinate.
  • float y0 - The first Y-coordinate.
  • float x1 - The second X-coordinate.
  • float y1 - The second Y-coordinate.

void renderCube ( int face, float x0 = -1.0f, float y0 = -1.0f, float x1 = 1.0f, float y1 = 1.0f ) #

Renders Cube texture. This function creates 4 vertices (2 polygons) of the given face of the cube texture by using 2 X-coordinates and 2 Y-coordinates and sends it to be rendered.

Arguments

  • int face - The face of the cube.
  • float x0 - The first X-coordinate.
  • float y0 - The first Y-coordinate.
  • float x1 - The second X-coordinate.
  • float y1 - The second Y-coordinate.

void renderCubeArray ( int face, int layer, float x0 = -1.0f, float y0 = -1.0f, float x1 = 1.0f, float y1 = 1.0f ) #

Renders Cube Array texture. This function creates 4 vertices (2 polygons) of the given face of the cube texture layer by using 2 X-coordinates and 2 Y-coordinates and sends it to be rendered.

Arguments

  • int face - The face of the cube.
  • int layer - The layer number.
  • float x0 - The first X-coordinate.
  • float y0 - The first Y-coordinate.
  • float x1 - The second X-coordinate.
  • float y1 - The second Y-coordinate.

void unbindCompute ( int unit ) #

Unbinds compute texture.

Arguments

  • int unit - Texture unit.

void unbindFragment ( int unit ) #

Unbinds fragment texture.

Arguments

  • int unit - Texture unit.

void unbindVertex ( int unit ) #

Unbinds vertex texture.

Arguments

  • int unit - Texture unit.

int formatImageToTexture ( int image_format, int flags ) #

Returns the texture format corresponding to the specified image format.

Arguments

  • int image_format - Image format identifier (see the FORMAT_* variables) or 0 if the specified texture format is unknown.
  • int flags - Unsigned format flag. 1 to interpret integer image format as unsigned, 0 - as signed.

Return value

Texture format identifier (see the FORMAT_* variables) or 0 if the specified image format is unknown.

int formatTextureToImage ( int texture_format ) #

Returns the image format corresponding to the specified texture format.

Arguments

  • int texture_format - Texture format identifier (see the FORMAT_* variables).

Return value

Image format identifier (see the FORMAT_* variables) or 0 if the specified texture format is unknown.

int typeTextureToImage ( int texture_type ) #

Returns the image type corresponding to the specified texture type.

Arguments

  • int texture_type - Texture type identifier (see the TEXTURE_* variables).

Return value

Image type identifier (see the IMAGE_* variables) or 0 if the specified texture type is unknown.

int getImageFormat ( ) #

Returns the image format corresponding to the current texture format.

Return value

Image format identifier (see the FORMAT_* variables) or 0 if the specified texture format is unknown.

void clearBuffer ( ) #

Clears all levels of the texture image (fills all its elements with 0-values).

void swap ( const Ptr<Texture> & texture ) #

Swaps the data of the current texture with the source texture.

Arguments

  • const Ptr<Texture> & texture - Source texture.

int copy ( const Ptr<Texture> & src ) #

Copies the data of the source texture to the texture.

Arguments

  • const Ptr<Texture> & src - Source texture.

Return value

1 if the data of the source texture is copied successfully; otherwise, 0.

void setDebugName ( const char * name ) #

Sets a friendly name for GPU debugging (RenderDoc, NVIDIA Nsight). It can be used to help you determine if the corresponding object interface pointer caused the leak. Memory leaks are reported by the debug software layer by outputting a list of object interface pointers along with their friendly names.

Arguments

  • const char * name - Friendly debug name to be set.

const char * getDebugName ( ) #

Returns the currently used friendly name for GPU debugging (RenderDoc, NVIDIA Nsight). It can be used to help you determine if the corresponding object interface pointer caused the leak. Memory leaks are reported by the debug software layer by outputting a list of object interface pointers along with their friendly names.

Return value

Friendly debug name.

size_t getVideoMemoryUsage ( int width, int height, int format, int num_mipmaps, int flags, int num_faces, int num_layers, int depth ) #

Returns the amount of memory occupied by a texture with the specified parameters.

Arguments

  • int width - Texture width, in pixels.
  • int height - Texture height, in pixels.
  • int format - Texture format.
  • int num_mipmaps - Number of mipmaps in the texture.
  • int flags - Texture flags.
  • int num_faces - Number of faces in the texture.
  • int num_layers - Number of layers in the texture.
  • int depth - Texture depth.

Return value

Texture size, in bytes.

bool copyRegion ( const Ptr<Texture> & src, const Math::ivec3 & src_coords, int src_level, const Math::ivec3 & dest_coords, int dest_level, int width, int height, int depth ) #

Copies the specified region from the source texture.

Arguments

  • const Ptr<Texture> & src - Source texture from which the data is to be copied.
  • const Math::ivec3 & src_coords - Coordinates in the source texture starting from which the region's data is to be taken.
  • int src_level - Source texture mipmap level number in the range from 0 to the total number of mipmaps.
  • const Math::ivec3 & dest_coords - Coordinates in the texture starting from which the data from the source texture is to be pasted.
  • int dest_level - Target mipmap level number in the range from 0 to the total number of mipmaps.
  • int width - Width of the region to be copied, in pixels.
  • int height - Height of the region to be copied, in pixels.
  • int depth - Depth of the region to be copied, in pixels.

Return value

true if the specified region was successfully copied from the source to the destination; otherwise, false.
Last update: 31.07.2020
Build: ()