Texture

clay.Resourceclay.graphics.Texture (Class) → RenderTexture

A high level texture object to make it easier to manage textures

Static Members

fromImage(image: clay.Image, ?premultiplyAlpha: Bool = false): Texture
Name Type Default
image clay.Image
premultiplyAlpha Bool false
Returns
Texture

Instance Members

index: Int

textureId: clay.TextureId

premultiplyAlpha: Bool

Is true if image has been processed to be stored as premultiplied alpha in GPU memory.


compressed: Bool

If true, the pixels buffer should store compressed image data that the GPU understands


The GPU texture format (RGBA, RGB...)


The GPU texture type (TEXTURE_2D)


The GPU data type (UNSIGNED_BYTE)


width: Int

When creating a texture manually, the width of this texture.


height: Int

When creating a texture manually, the height of this texture.


widthActual: Int

The width of the actual texture, needed when the texture may be padded to POT sizes


heightActual: Int

The height of the actual texture, needed when the texture may be padded to POT sizes


When creating a texture manually, the pixels for this texture. Properties width and height must be defined when providing pixels.


Set the minification filter type (default LINEAR)


Set the magnification filter type (default LINEAR)


Set the s (horizontal) clamp type (default CLAMP_TO_EDGE)


Set the t (vertical) clamp type (default CLAMP_TO_EDGE)


init(): Void

Initialize this texture. Must be called before using the actual texture. When calling init(), properties should be defined accordingly.


destroy(): Void

bind(?slot: Int = 0): Void

Bind this texture to its active texture slot, and it's texture id to the texture type. Calling this repeatedly is fine, as the state is tracked by Graphics.

Name Type Default
slot Int 0

Submit a pixels array to the texture id. Must match the type and format accordingly.

Name Type Default
pixels Null<clay.buffers.Uint8Array> (optional)

fetch(into: clay.buffers.Uint8Array, ?x: Int = 0, ?y: Int = 0, ?w: Int = -1, ?h: Int = -1): clay.buffers.Uint8Array

Fetch the pixels from the texture id, storing them in the provided array buffer view. Returns image pixels in RGBA format, as unsigned byte (0-255) values only. This means that the view must be w * h * 4 in length, minimum. By default, x and y are 0, 0, and the texture width and height are used (not widthActual / heightActual)

Name Type Default
into clay.buffers.Uint8Array
x Int 0
y Int 0
w Int -1
h Int -1
Returns
clay.buffers.Uint8Array

new(): Void

Private Members