A Texture
can be used inside of Program
s to render image data.
It can store multiple TextureData
in slots that can be divided into tiles for texture atlases.
The precision (int/float) and amount of colorchannels can be defined by TextureFormat
. Mipmapping and filtering is supported.
Static methods
staticfromData(textureData:TextureData):Texture
Creates a new texture with one slot directly from a TextureData
instance.
Parameters:
textureData | TextureData instance |
---|
Constructor
new(slotWidth:Int, slotHeight:Int, ?slots:Int, ?textureConfig:TextureConfig)
Creates a new Texture
instance. Slot-tiling and texturesize is automatic calculated if you give the slots
parameter a number.
Parameters:
slotWidth | width of each slot in pixels |
---|---|
slotHeight | height of each slot in pixels |
slots | number of slots, leave it at |
textureConfig | options by |
Variables
Methods
inlineusedByProgram(program:Program):Bool
inlineusedByDisplay(display:Display):Bool
Returns true
if a Display
instance is using this texture to render into.
Parameters:
display | Display instance |
---|
readPixelsUInt8(x:Int, y:Int, w:Int, h:Int, ?data:UInt8Array):UInt8Array
Reads the data of a rectangular area from the texture inside an UInt8Array
. The TextureFormat
have to be of type integer.
Parameters:
x | left position of the area |
---|---|
y | top position of the area |
w | area width |
h | area height |
data | an UInt8Array to store the data, if it is |
readPixelsFloat32(x:Int, y:Int, w:Int, h:Int, ?data:Float32Array):Float32Array
Reads the data of a rectangular area from the texture inside a Float32Array
. The TextureFormat
have to be of type float.
Parameters:
x | left position of the area |
---|---|
y | top position of the area |
w | area width |
h | area height |
data | a Float32Array to store the data, if it is |
setData(textureData:TextureData, slot:Int = 0):Void
Specifies a TextureData
instance to use inside a texture slot.
Parameters:
textureData | TextureData instance |
---|---|
slot | slot number in wich the texturedata is to be used |
clearSlot(slot:Int):Void
Frees a texture slot from the linked TextureData
.
Parameters:
slot | slot number in wich the texturedata is used |
---|
setSmooth(smoothExpand:Bool, smoothShrink:Bool, ?smoothMipmap:Bool):Void
Changes the texture filtering at runtime.
Parameters:
smoothExpand | to enable smooth filtering if the texture is displayed at a enlarged size |
---|---|
smoothShrink | to enable smooth filtering if the texture is displayed at a reduced size |
smoothMipmap | to enable smooth interpolation between mipmap-levels (if the texture have mipmaps) |
dispose():Void
Removes the texture from all programs/display-framebuffers and frees texture-ram by OpenGL. It can not be used again.