This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and 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
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

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 worst visual quality to the best thus from 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 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

1 if the texture type is cube; otherwise, 0.

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()

Returns the texture depth.

Return value

Texture 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()

Returns the texture height.

Return value

Texture height.

int setImage(const Ptr<Image> & image)

Sets texture data.

Arguments

  • const Ptr<Image> & image - Image pointer.

Return value

1 if the data was set; otherwise, 0.

int getImage(const Ptr<Image> & image)

Gets texture data.

Arguments

  • const Ptr<Image> & image - Image pointer.

Return value

1 if the data was received; 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, D16, D24, D24S8, D32F ir 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()

Returns the texture width.

Return value

Texture 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 ANISOTROPY_1

Description

Anisotropic Filtering.

int ANISOTROPY_16

Description

16x Anisotropic Filtering.

int ANISOTROPY_2

Description

2x Anisotropic Filtering.

int ANISOTROPY_4

Description

4x Anisotropic Filtering.

int ANISOTROPY_8

Description

8x Anisotropic Filtering.

int DEFAULT_FLAGS

Description

A flag that sets default flags (linear filtering).

int FILTER_BILINEAR

Description

Bilinear filtering.

int FILTER_LINEAR

Description

Linear filtering.

int FILTER_POINT

Description

Point filtering.

int FILTER_TRILINEAR

Description

Trilinear filtering.

int FORMAT_ATI1

Description

ATI1 texture format (compressed texture).

int FORMAT_ATI2

Description

ATI2 texture format (compressed texture).

int FORMAT_D16

Description

D16 texture format (depth texture).

int FORMAT_D24

Description

D24 texture format (depth texture).

int FORMAT_D24S8

Description

D24S8 texture format (depth texture).

int FORMAT_D32F

Description

D32F texture format (depth texture).

int FORMAT_D32FS8

Description

D32F texture format (depth texture).

int FORMAT_DXT1

Description

D32FS8 texture format (compressed texture).

int FORMAT_DXT3

Description

DXT3 texture format (compressed texture).

int FORMAT_DXT5

Description

DXT5 texture format (compressed texture).

int FORMAT_INTEGER

Description

Integer format flag.

int FORMAT_R16

Description

R16 texture format (16-bits per channel normalized format).

int FORMAT_R16F

Description

R16F texture format (16-bits per channel float format).

int FORMAT_R16U

Description

R16U texture format (16-bits per channel integer format).

int FORMAT_R32F

Description

R32F texture format (32-bits per channel float format).

int FORMAT_R32U

Description

R32U texture format (32-bits per channel integer format).

int FORMAT_R8

Description

R8 texture format (8-bits per channel normalized format).

int FORMAT_RG11B10F

Description

RG11B10F texture format (combined format).

int FORMAT_RG16

Description

RG16 texture format (16-bits per channel normalized format).

int FORMAT_RG16F

Description

RG16F texture format (16-bits per channel float format).

int FORMAT_RG16U

Description

RG16U texture format (16-bits per channel integer format).

int FORMAT_RG32F

Description

RG32F texture format (32-bits per channel float format).

int FORMAT_RG32U

Description

RG32U texture format (32-bits per channel integer format).

int FORMAT_RG8

Description

RG8 texture format (8-bits per channel normalized format).

int FORMAT_RGB10A2

Description

RGB10A2 texture format (combined format).

int FORMAT_RGB16

Description

RGB16 texture format (16-bits per channel normalized format).

int FORMAT_RGB16F

Description

RGB16F texture format (16-bits per channel float format).

int FORMAT_RGB16U

Description

RGB16U texture format (16-bits per channel integer format).

int FORMAT_RGB32F

Description

RGB32F texture format (32-bits per channel float format).

int FORMAT_RGB32U

Description

RGB32U texture format (32-bits per channel integer format).

int FORMAT_RGB565

Description

RGB565 texture format (combined format).

int FORMAT_RGB5A1

Description

RGB5A1 texture format (combined format).

int FORMAT_RGB8

Description

RGB8 texture format (8-bits per channel normalized format).

int FORMAT_RGBA16

Description

RGBA16 texture format (16-bits per channel normalized format).

int FORMAT_RGBA16F

Description

RGBA16F texture format (16-bits per channel float format).

int FORMAT_RGBA16U

Description

RGBA16U texture format (16-bits per channel integer format).

int FORMAT_RGBA32F

Description

RGBA32F texture format (32-bits per channel float format).

int FORMAT_RGBA32U

Description

RGBA32U texture format (32-bits per channel integer format).

int FORMAT_RGBA4

Description

RGBA4 texture format (combined format).

int FORMAT_RGBA8

Description

RGBA8 texture format (8-bits per channel normalized format).

int FORMAT_SIGNED

Description

Signed format flag.

int FORMAT_SRGB

Description

SRGB format flag.

int MULTISAMPLE_16

Description

16x multisample texture.

int MULTISAMPLE_2

Description

2x multisample texture.

int MULTISAMPLE_4

Description

4x multisample texture.

int MULTISAMPLE_8

Description

8x multisample texture.

int SHADOW_COMPARE

Description

Shadow texture flag (Use corresponding INIT_TEXTURE_SHADOW() and TEXTURE_SHADOW() UUSL functions).

int TEXTURE_2D

Description

2D texture.

int TEXTURE_2D_ARRAY

Description

2D texture array.

int TEXTURE_3D

Description

3D texture array.

int TEXTURE_CUBE

Description

Cubemap texture.

int TEXTURE_CUBE_ARRAY

Description

Cubemap texture array.

int TYPE_2D_ARRAY

Description

2D texture array type.

int TYPE_CUBE_ARRAY

Description

Cubemap texture array type.

int USAGE_DYNAMIC

Description

Dynamic texture flag.

int USAGE_IMMUTABLE

Description

Immutable texture flag.

int USAGE_READWRITE

Description

RW texture flag.

int USAGE_RENDER

Description

Buffer render texture (RT) flag.

int USAGE_STAGING

Description

Staging texture flag.

int WRAP_BORDER

Description

Wrapping to border color flag.

int WRAP_BORDER_W

Description

Wrapping to border color flag.

int WRAP_BORDER_X

Description

Wrapping to border color along X axis flag.

int WRAP_BORDER_Y

Description

Wrapping to border color along Y axis flag.

int WRAP_BORDER_Z

Description

Wrapping to border color along Z axis flag.

int WRAP_CLAMP

Description

Wrapping to clamped color flag.

int WRAP_CLAMP_X

Description

Wrapping to clamped color along X axis flag.

int WRAP_CLAMP_Y

Description

Wrapping to clamped color along Y axis flag.

int WRAP_CLAMP_Z

Description

Wrapping to clamped color along Z axis flag.
Last update: 2017-07-03
Build: ()