TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

interface ITextureFactory in Tinman.Terrain.Rendering

Base interface for classes that create texture resources for rendering.

interface ITextureFactory base of TextureFactory

Remarks

The following figures gives an overview of the classes that are related to the ITextureFactory interface.

+-----------------+
| ITextureFactory |
+-----------------+
        |
        |
        V         +----------------+
     create <---- | TextureFormat  |  The binary texel format.
        |         +----------------+
        |                 |
        |                 | create
        |                 V
        |         +----------------+  encode  +-------------+
        |         |   TexelBuffer  |  <-----  | ColorBuffer |
        |         +----------------+          +-------------+
        |                 |                 Pixel buffer, filled
        |                 | copy            by application
        |                 V
        |         +----------------+
        +-------> | ITextureData2D |  Collects data for texture update
        |         +----------------+
        |                 |
        |                 | update
        |                 V
        |         +----------------+
        °-------> |   ITexture2D   |  Texture for GPU-based rendering
                  +----------------+

See also:

ColorBuffer
TextureFormat
TexelBuffer
ITexture2D

Attributes

AvailableVideoMemory

Returns the amount of available video memory.

property AvailableVideoMemory { get }
type int64
value [>=0] The amount of available video memory, in bytes.

Methods

CreateTexture2D

Creates a static ITexture2D object (i.e. CanSetTexels and CanCopyTexels return false).

[OwnerReturn]
method CreateTexture2D (TexelBuffer buffer, bool warn = true)
type ITexture2D
params buffer [not-null] The buffer that holds the texture content. The Srgb flag of this buffer defines the sRGB behaviour of the created texture (see IsSrgb).
  warn Emit a warning log message if the TextureFormat of the given buffer needs to be converted to a supported format? Defaults to true.
returns [not-null] The ITexture2D object.

Remarks:

The texel buffer size is validated (see ValidateTextureSize) before the texture is created, so the size of the returned ITexture2D object might be different to Width and/or Height.

The ValidateTextureFormat method will be called to find a supported texture format for the given texture contents (see Format), and the texture contents will be transcoded, if necessary.


Creates a dynamic ITexture2D object (i.e. CanSetTexels returns true).

[OwnerReturn]
method CreateTexture2D (int32 width, int32 height, TextureFormat format, int32 mipmaps = 1, bool data = false, bool srgb = true)
type ITexture2D
params width [>0] The texture width, in texels.
  height [>0] The texture height, in texels.
  format [not-null] The texture format (will be returned by Format).
  mipmaps [>=0] The number of mipmap levels (including the full-resolution level). If 0 the number of levels will be inferred from width and height. Defaults to 1.
  data Create a texture data object (i.e. CanCopyTexels returns true)? Defaults to false.
  srgb The sRGB behaviour of the created texture (see IsSrgb). Defaults to true.
returns [not-null] The ITexture2D object.

Remarks:

The given texture size is validated (see ValidateTextureSize) before the texture is created, so the size of the returned ITexture2D object might be different to width and/or height.

See also:

ValidateTextureSize
ValidateTextureFormat

Exceptions:

ValidateTextureFormat

Checks if this texture factory supports the given texture format. If not it returns a supported format that matches format as closely as possible.

[Pure]
method ValidateTextureFormat (TextureFormat format)
type TextureFormat
params format The texture format.
returns [not-null] The supported texture format to use.

ValidateTextureSize

Validates the given texture size by adjusting the width and height according to the texture size restrictions of this factory (e.g. must-be-square).

[Pure]
method ValidateTextureSize (int32 width, int32 height)
type Vec2I
params width The texture width.
  height The texture height.
returns The validated texture size.

Extensions

CreateTexture2D

Creates a static ITexture2D object (i.e. CanSetTexels returns false).

[OwnerReturn]
method CreateTexture2D (Path path)
type ITexture2D
params path [not-null] The path to a texture file (see ReadTexture).
returns [not-null] The ITexture2D object.

Remarks:

The Srgb flag of the loaded texel buffer (see ReadTexture) defines the sRGB behaviour of the created texture (see IsSrgb).


Creates a static ITexture2D object (i.e. CanSetTexels returns false).

[OwnerReturn]
method CreateTexture2D (int64 color = Colors.White, bool srgb = true)
type ITexture2D
params color The uniform color. Defaults to White.
  srgb The sRGB behaviour of the created texture (see IsSrgb). Defaults to true.
returns [not-null] The ITexture2D object.

Remarks:

The created texture has the A8R8G8B8 format.

ValidateTextureSize

Validates the given texture size by adjusting the width and height according to the texture size restrictions of this factory (e.g. must-be-square).

[Pure]
method ValidateTextureSize (int32 size)
type int32
params size The texture size (both width and height).
returns The validated texture size.

Validates the given texture size by adjusting the width and height according to the texture size restrictions of this factory (e.g. must-be-square).

[Pure]
method ValidateTextureSize (Vec2I size)
type Vec2I
params size The texture size.
returns The validated texture size.