A Texture can be used inside of Programs 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 null to use slotX and slotY tiling by textureConfig

textureConfig

options by TextureConfig

Variables

read onlyglTexture:GLTexture

The OpenGL representation of the texture.

read onlytextureDataSlots:IntMap<TextureData>

Maps a slot number to the used TextureData.

read onlywidth:Int

The total horizontal texturesize in pixels.

read onlyheight:Int

The total vertical texturesize in pixels.

read onlyslots:Int

The total number of slots in which the texture can store texture data.

read onlyslotsX:Int

The horizontal number of slots into which the texture is divided.

read onlyslotsY:Int

The vertical number of slots into which the texture is divided.

read onlyslotWidth:Int

Horizontal slot size in pixels.

read onlyslotHeight:Int

Vertical slot size in pixels.

tilesX:Int

Horizontal tiling, the program needs "updateTextures()" if changing this while in use

tilesY:Int

Vertical tiling, the program needs "updateTextures()" if changing this while in use

@:value(false)mipmap:Bool = false

If the texture have to generate mipmaps for filtering.

@:value(false)smoothMipmap:Bool = false

Use smooth interpolation between the mipmap-levels for texture filtering.

@:value(false)smoothExpand:Bool = false

Use smooth filtering if the texture is displayed at a enlarged size.

@:value(false)smoothShrink:Bool = false

Use smooth filtering if the texture is displayed at a reduced size.

@:value(true)clearOnRenderInto:Bool = true

The texture will be cleared before a Display is rendering into it.

Methods

inlineusedByProgram(program:Program):Bool

Returns true if a Program instance is using this texture.

Parameters:

program

Program instance

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 null a new one will be created

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 null a new one will be created

@:value({ slot : 0 })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

@:value({ smoothMipmap : null })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.