Texture
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
format: clay.TextureFormat
The GPU texture format (RGBA, RGB...)
type: clay.TextureType
The GPU texture type (TEXTURE_2D)
dataType: clay.TextureDataType
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
pixels: Null<clay.buffers.Uint8Array>
When creating a texture manually, the pixels for this texture.
Properties width
and height
must be defined when providing pixels.
filterMin: clay.TextureFilter
Set the minification filter type (default LINEAR)
filterMag: clay.TextureFilter
Set the magnification filter type (default LINEAR)
wrapS: clay.TextureWrap
Set the s (horizontal) clamp type (default CLAMP_TO_EDGE)
wrapT: clay.TextureWrap
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 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(?pixels: Null<clay.buffers.Uint8Array>): Void
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