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

class Texture2D in Tinman.Terrain.Rendering

Abstract base class for ITexture2D implementations.

abstract class Texture2D extends Disposable
  implements ITexture2D

Public / Attributes

BitsPerTexel

The number of bits per texture pixel.

public property BitsPerTexel { get }
type int32
value [>0] The number of bits per pixel.
implements IBitsPerTexel.BitsPerTexel

CanCopyTexels

Is this a texture data object, to be used to update the content of another texture object?

public property CanCopyTexels { get }
type bool
value true if this is a texture data object.
false if this is a regular texture object.
implements ITexture2D.CanCopyTexels

Remarks:

Texture data objects cannot be used for rendering.

See also:

ITexture2D.CopyTexels

CanSetTexels

Can the content of this texture be updated?

public virtual property CanSetTexels { get }
type bool
value true if this texture is dynamic and its content can be updated.
false if this texture is static and its content cannot be updated.
implements ITexture2D.CanSetTexels

See also:

ITexture2D.SetTexels

Format

The texture format.

public property Format { get }
type TextureFormat
value [not-null] The texture format.
implements ITexture.Format

HasAlpha

Returns if texture pixels carry transparency data.

public property HasAlpha { get }
type bool
value true if texture pixels can be transparent, false if all texture pixels will always be fully opaque.
implements IBitsPerTexel.HasAlpha

Height

The texture height, in texels.

public property Height { get }
type int32
value The texture height, in texels.
implements ITexture2D.Height

IsSrgb

The sRGB behaviour of this texture.

public property IsSrgb { get }
type bool
value The sRGB behaviour flag.
implements ITexture.IsSrgb

Remarks:

When true, the GPU is supposed to do on-the-fly sRGB decompression for the texture object (e.g. in Direct3D 10+ by using DXGI_FORMAT_B8G8R8X8_UNORM_SRGB), so that the GPU shader receives linear color values. Depending on the underlying graphics API, it may be necessary to specify this sRGB behaviour in the shader effect source code (e.g. in a Direct3D 9 '.fx' file via SRGBTexture=true;, to enable the D3DSAMP_SRGBTEXTURE sampler state).

LifecycleState

Returns the lifecycle state of this object.

public virtual property LifecycleState { get }
type LifecycleState
value The lifecycle state.
inherited Disposable.LifecycleState

MemoryConsumption

Returns the estimated memory consumption of this object.

public property MemoryConsumption { get }
type int64
value [>=0] The estimated memory consumption, in bytes.
implements IMemoryConsumption.MemoryConsumption

Mipmaps

The number of mipmap levels.

public property Mipmaps { get }
type int32
value [>=0] The number of mipmap levels.
implements ITexture.Mipmaps

NativeHandle

Returns the raw handle value of the native resource that is contained in this object.

public abstract property NativeHandle { get }
type IntPtr
value The raw handle value.
implements INativeHandle.NativeHandle

Remarks:

The documentation of the implementing class will contain information on how to interpret the raw handle value.

Width

The texture width, in texels.

public property Width { get }
type int32
value The texture width, in texels.
implements ITexture2D.Width

Public / Methods

AcquireTry

Acquires a strong reference to this disposable object.

[OwnerReturn, ThreadSafe]
public method AcquireTry ()
type IDisposable
returns this if a new strong reference has been acquired, null if this object is already being disposed.
inherited Disposable.AcquireTry

Remarks:

The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.

This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.

CopyTexels

Copies a rectangular subset of texels from this texture data object to the given texture object.

public method CopyTexels (ITexture2D target, int32 sourceX, int32 sourceY, int32 targetX, int32 targetY, int32 width, int32 height)
params target [not-null] The target texture object.
  sourceX [0..Width-width] X-coordinate of top-left corner of source rectangle. Defaults to 0.
  sourceY [0..Height-height] Y-coordinate of top-left corner of source rectangle. Defaults to 0.
  targetX [0..target.Width-width] X-coordinate of top-left corner of target rectangle. Defaults to 0.
  targetY [0..target.Height-height] Y-coordinate of top-left corner of target rectangle. Defaults to 0.
  width [>=0] Width of rectangle, in texels. If 0 the maximum valid width will be used. Defaults to 0.
  height [>=0] Height of rectangle, in texels. If 0 the maximum valid height will be used. Defaults to 0.
implements ITexture2D.CopyTexels

Remarks:

The following parameters must be a multiple of the texture format block size (see BlockSize), to make sure the copy operation can be performed on whole texel blocks:
sourceX, sourceY, targetX, targetY, width, height.

Exceptions:

Dispose

Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.

[Dispose, OwnerThis, ThreadSafe]
public method Dispose ()
inherited Disposable.Dispose

Remarks:

The Dispose method silently returns if the object has already been disposed.

SetTexels

Copies a region of texels from the given buffer to this texture data object.

public method SetTexels (TexelBuffer source, int32 targetX, int32 targetY)
params source [not-null] The source buffer that holds the texel data.
  targetX [0..Width-source.Width] X-coordinate of top-left target texel. Defaults to 0.
  targetY [0..Height-source.Height] Y-coordinate of top-left target texel. Defaults to 0.
implements ITexture2D.SetTexels

Remarks:

If CanCopyTexels of this texture object returns false, a temporary texture data object is created, the SetTexels method is called on that texture object and finally CopyTexels is used to update this texture object. Otherwise, the content of this texture data object is updated directly.

Exceptions:

Protected / Attributes

canCopyTexels

Is this a texture data object, i.e. CopyTexels can be used?

protected readonly field canCopyTexels
type bool

format

The texture format.

protected field format
type TextureFormat

height

The texture height.

protected readonly field height
type int32

mipmaps

The number of mipmap levels.

protected readonly field mipmaps
type int32

width

The texture width.

protected readonly field width
type int32

Protected / Constructors

Texture2D

Creates a new instance of Texture2D.

protected constructor Texture2D (ITextureFactory factory, int32 width, int32 height, int32 mipmaps, TextureFormat format, bool srgb, bool canCopyTexels)
params factory The texture factory that is creating this texture or null if CanSetTexels returns false.
  width [>0] The texture width, in texels.
  height [>0] The texture height, in texels.
  mipmaps [>=0] The number of mipmap levels.If 0 the number of levels will be inferred from width and height.
  format [not-null] The texture format.
  srgb The sRGB behaviour
  canCopyTexels Is this a texture data object, i.e. CopyTexels can be used?

Protected / Methods

Buffer

Returns a raw byte buffer that wraps the given memory block.

protected method Buffer (IntPtr data, int32 capacity)
type ByteBuffer
params data Points to the first byte of the memory block.
  capacity The memory block size, in bytes.
returns [not-null] The raw byte buffer.

DisposeManaged

Disposes the managed resources held by a concrete subclass. This method will be called at most once per subclass.

protected override method DisposeManaged ()
overrides Disposable.DisposeManaged

Remarks:

This method will only be called when a disposable object is explicitly destroyed by user code calling the Dispose method. It will not be called when the object is collected as garbage by the system.

Overriding methods must call the DisposeManaged method of their base class. The base call should be the last statement.

The DisposeManaged method is called before the DisposeUnmanaged method.

DisposeUnmanaged

Disposes the unmanaged resources held by a concrete subclass. This method will be called exactly once per subclass.

protected virtual method DisposeUnmanaged ()
inherited Disposable.DisposeUnmanaged

Remarks:

Overriding methods must call the DisposeUnmanaged method of their base class. The base call should be the last statement.

The DisposeUnmanaged method is called after the DisposeManaged method.

DoCopyTexels

protected abstract method DoCopyTexels (int32 sourceX, int32 sourceY, ITexture2D target, int32 targetX, int32 targetY, int32 width, int32 height, int32 mipmaps)
params sourceX
  sourceY
  target
  targetX
  targetY
  width
  height
  mipmaps

DoSetTexels

protected abstract method DoSetTexels (TexelBuffer source, int32 targetX, int32 targetY)
params source
  targetX
  targetY