final class Texture
package openfl.display3D.textures
extends TextureBase › EventDispatcher
Available on all platforms
The Texture class represents a 2-dimensional texture uploaded to a rendering context.
Defines a 2D texture for use during rendering.
Texture cannot be instantiated directly. Create instances by using Context3D
createTexture()
method.
Methods
uploadCompressedTextureFromByteArray(data:ByteArray, byteArrayOffset:UInt, async:Bool = false):Void
Uploads a compressed texture in Adobe Texture Format (ATF) from a ByteArray
object. ATF file version 2 requires SWF version 21 or newer and ATF file version 3
requires SWF version 29 or newer. For ATF files created with png image without
alpha the format string given during Context3DObject createTexture
should be
"COMPRESSED"
and for ATF files created with png image with alpha the format
string given during Context3DObject createTexture
should be "COMPRESSED_ALPHA"
.
Parameters:
data | a byte array that contains a compressed texture including mipmaps. The ByteArray object must use the little endian format. |
---|---|
byteArrayOffset | the position in the byte array at which to start reading the texture data. |
async | If true, this function returns immediately. Any draw method which
attempts to use the texture will fail until the upload completes successfully.
Upon successful upload, this CubeTexture object dispatches |
Throws:
TypeError | Null Pointer Error: when |
---|---|
ArgumentError | Texture Decoding Failed: when the compression format of this object cannot be derived from the format of the compressed data in data or when the SWF version is incompatible with the ATF file version. |
ArgumentError | Texture Size Does Not Match: when the width and height of the decompressed texture do not equal the dimensions of this Texture object. |
ArgumentError | Miplevel Too Large: if the mip level of the decompressed texture is greater than that implied by the size of the texture. |
ArgumentError | Texture Format Mismatch: if the decoded ATF bytes don't contain a texture compatible with this texture's format. |
Error | 3768: The Stage3D API may not be used during background execution. |
RangeError | Bad Input Size: when there is integer overflow of
|
uploadFromBitmapData(source:BitmapData, miplevel:UInt = 0, generateMipmap:Bool = false):Void
Uploads a texture from a BitmapData object.
Parameters:
source | a bitmap. |
---|---|
miplevel | the mip level to be loaded, level zero being the top-level full-resolution image. |
Throws:
TypeError | Null Pointer Error: when |
---|---|
ArgumentError | Miplevel Too Large: if the specified mip level is greater than that implied by the larger of the Texture's dimensions. |
ArgumentError | Invalid BitmapData Error: if |
ArgumentError | Texture Format Mismatch: if the texture format is Context3DTextureFormat.COMPRESSED or Context3DTextureFormat.COMPRESSED_ALPHA and the code is executing on a mobile platform where runtime texture compression is not supported. |
Error | 3768: The Stage3D API may not be used during background execution. |
uploadFromByteArray(data:ByteArray, byteArrayOffset:UInt, miplevel:UInt = 0):Void
Uploads a texture from a ByteArray.
Parameters:
data | a byte array that is contains enough bytes in the textures internal format to fill the texture. rgba textures are read as bytes per texel component (1 or 4). float textures are read as floats per texel component (1 or 4). The ByteArray object must use the little endian format. |
---|---|
byteArrayOffset | the position in the byte array object at which to start reading the texture data. |
miplevel | the mip level to be loaded, level zero is the top-level, full-resolution image. |
Throws:
TypeError | Null Pointer Error: when |
---|---|
ArgumentError | Miplevel Too Large: if the specified mip level is greater than that implied by the larger of the Texture's dimensions. |
RangeError | Bad Input Size: if the number of bytes available from
|
ArgumentError | Texture Format Mismatch: if the texture format is Context3DTextureFormat.COMPRESSED or Context3DTextureFormat.COMPRESSED_ALPHA and the code is executing on a mobile platform where runtime texture compression is not supported. |
Error | 3768: The Stage3D API may not be used during background execution. |
uploadFromTypedArray(data:ArrayBufferView, miplevel:UInt = 0):Void
Uploads a texture from an ArrayBufferView.
Parameters:
data | a typed array that contains enough bytes in the textures internal format to fill the texture. rgba textures are read as bytes per texel component (1 or 4). float textures are read as floats per texel component (1 or 4). |
---|---|
miplevel | the mip level to be loaded, level zero is the top-level, full-resolution image. |