Texture

class Texture(nativeHandle: NativePointer)

Texture represents a GPU texture resource.

The Texture class supports:

  • 2D textures

  • 3D textures

  • Cube maps

  • Mip mapping

Creation and destruction

========================

A Texture object is created using the Texture.Builder and destroyed by calling Engine.destroy(texture).

val engine = Engine.create()!!

val texture = Texture.Builder()
.width(64)
.height(64)
.build(engine)

engine.destroy(texture)

Constructors

Link copied to clipboard
constructor(nativeHandle: NativePointer)

Types

Link copied to clipboard
class Builder

Builder for creating Texture instances.

Link copied to clipboard
object Companion
Link copied to clipboard

Cubemap face identifiers.

Link copied to clipboard

Pixel color format (how data is laid out in the client buffer for setImage()).

Link copied to clipboard

Internal texel format (how texels are stored in memory).

Link copied to clipboard
class PixelBufferDescriptor(val storage: ByteArray, val sizeInBytes: Int, val format: Texture.Format, val type: Texture.Type, val alignment: Int = 1, val left: Int = 0, val top: Int = 0, val stride: Int = 0, val callback: () -> Unit? = null)

Describes pixel buffer data for uploading to a texture via setImage().

Link copied to clipboard

Sampler type for texture sampling.

Link copied to clipboard

Texture channel swizzle (maps channels to output RGBA).

Link copied to clipboard

Pixel data type (size and signedness of color components in the client buffer for setImage()).

Link copied to clipboard
object Usage

Texture usage flags affecting memory layout and capabilities.

Properties

Link copied to clipboard

Return this texture InternalFormat as set by Builder.format().

Link copied to clipboard
val levels: Int

Returns the maximum number of levels this texture can have.

Link copied to clipboard

The native object, for interop with code calling the Fila* C API directly. Read-only: this wrapper owns it.

Link copied to clipboard

Return this texture Sampler as set by Builder.sampler().

Functions

Link copied to clipboard
fun generateMipmaps(engine: Engine)

Generates all mipmap levels automatically.

Link copied to clipboard
fun getDepth(level: Int = 0): Int

Returns the depth of a 3D texture level.

Link copied to clipboard
fun getHeight(level: Int = 0): Int

Returns the height of a 2D or 3D texture level.

Link copied to clipboard
fun getWidth(level: Int = 0): Int

Returns the width of a 2D or 3D texture level.

Link copied to clipboard

Returns whether this texture's creation is complete: always true unless the Builder was asynchronous.

Link copied to clipboard
fun setExternalStream(engine: Engine, stream: Stream)

Associates an external stream with this texture. Typically the external stream is OS-specific and can be a video or camera stream.

Link copied to clipboard
fun setImage(engine: Engine, level: Int, descriptor: Texture.PixelBufferDescriptor)

Updates a 2D texture level with image data from a buffer.

fun setImage(engine: Engine, level: Int, xoffset: Int, yoffset: Int, width: Int, height: Int, descriptor: Texture.PixelBufferDescriptor)

Updates a rectangular sub-region of a 2D texture level.

fun setImage(engine: Engine, level: Int, xoffset: Int, yoffset: Int, zoffset: Int, width: Int, height: Int, depth: Int, descriptor: Texture.PixelBufferDescriptor)

Updates a sub-region of a 3D texture or 2D texture array. Cubemaps are treated like a 2D array of six layers.

Link copied to clipboard
fun setImageAsync(engine: Engine, level: Int, descriptor: Texture.PixelBufferDescriptor, callback: (Texture, AsyncCallStatus) -> Unit? = null): Int

setImage, asynchronously: returns an ID for Engine.cancelAsyncCall, and callback runs once on the main thread with how it ended. Needs Engine.isAsynchronousModeEnabled.

fun setImageAsync(engine: Engine, level: Int, xoffset: Int, yoffset: Int, width: Int, height: Int, descriptor: Texture.PixelBufferDescriptor, callback: (Texture, AsyncCallStatus) -> Unit? = null): Int
fun setImageAsync(engine: Engine, level: Int, xoffset: Int, yoffset: Int, zoffset: Int, width: Int, height: Int, depth: Int, descriptor: Texture.PixelBufferDescriptor, callback: (Texture, AsyncCallStatus) -> Unit? = null): Int

setImage, asynchronously; see the level-only setImageAsync.