The Program is rendering the graphical elements of a Buffer with the corresponding shader and assigned Textures.
The shader code can be modified at runtime by formulas or also by glsl code-injection and custom uniforms.
It supports different modes for color blending, stencil masks or depth-buffer.

Constructor

new(buffer:BufferInterface)

Creates a new Program instance.

Parameters:

buffer

the Buffer what contains the graphical elements to render

Variables

read onlydisplays:Array<Display>

The Display instances in which the program is contained.

read onlybuffer:BufferInterface

Gets the used Buffer.

@:value(true)isVisible:Bool = true

Shows or hides the program during rendering.

@:value(true)colorEnabled:Bool = true

To enable or disable color rendering, e.g. disable to only render into the stencil-buffer by drawing a mask.

blendEnabled:Bool

To enable or disable the color/alpha blendmode.

@:value(false)blendSeparate:Bool = false

Use a separate blend-function for the alpha channel if the blendmode is enabled.

@:value(false)blendFuncSeparate:Bool = false

Separate blend-function for the alpha channel if blendSeparate is true.

blendSrc:BlendFactor

BlendFactor for the source colors if into blendmode.

blendDst:BlendFactor

BlendFactor for the destination colors if into blendmode.

blendSrcAlpha:BlendFactor

BlendFactor for the source alpha channel if into blendmode.

blendDstAlpha:BlendFactor

BlendFactor for the destination alpha channel if into blendmode.

blendFunc:BlendFunc

BlendFunc for the color channels if into blendmode.

blendFuncAlpha:BlendFunc

BlendFunc for the alpha channel if into blendmode.

@:value(0x7F7F7F7F)blendColor:Color = 0x7F7F7F7F

Constant Color to use if into blendmode.

zIndexEnabled:Bool

To enable or disable rendering into the depth-buffer.

@:value(Mask.OFF)mask:Mask = Mask.OFF

To use the stencil-buffer for masking or to draw into it to use it afterwards by another program.

@:value(false)clearMask:Bool = false

Clears the stencil-buffer.

@:value(true)autoUpdateTextures:Bool = true

Enable automatic shader generation for functioncalls what set, add or remove textures (also for snapToPixel, discardAtAlpha, shadercode-injection, formula and precision changes)

Methods

inlineshow():Void

Shows the program during rendering.

inlinehide():Void

Hides the program during rendering.

inlineisIn(display:Display):Bool

Returns true is this program is inside the RenderList of a Display instance.

Parameters:

display

Display instance

@:value({ addBefore : false })addToDisplay(display:Display, ?atProgram:Program, addBefore:Bool = false):Void

Adds this program to the RenderList of a Display instance. Can be also used to change the order (relative to another program) if it is already added.

Parameters:

display

Display instance

atProgram

(optional) to add or move before or after another program in the RenderList (by default at start or at end)

addBefore

(optional) if 'true' it's added before another program or at start of the Renderlist (by default it's added after atProgram or at end)

removeFromDisplay(display:Display):Void

Removes this program from the RenderList of a Display instance.

Parameters:

display

Display instance

@:value({ varDefaults : null, formula : "" })setColorFormula(formula:String = "", ?varDefaults:StringMap<Color>, ?autoUpdateTextures:Bool):Void

Set a formula to combine the colors of @texUnits together with the @color attributes of an element.

Parameters:

formula

a String what contains the color formula

varDefaults

defines the default colors by a Map with the texUnit identifiers as keys

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

@:value({ uniformFloats : null, uTimeUniformEnabled : false, glslCode : "" })injectIntoVertexShader(glslCode:String = "", uTimeUniformEnabled:Bool = false, ?uniformFloats:Array<UniformFloat>, ?autoUpdateTextures:Bool):Void

Inject custom glsl code into the vertexshader of a program.

Parameters:

glslCode

a String what contains the glsl code

uTimeUniformEnabled

if true you can use the global time uiform

uniformFloats

an Array of custom UniformFloats

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

@:value({ uniformFloats : null, uTimeUniformEnabled : false, glslCode : "" })injectIntoFragmentShader(glslCode:String = "", uTimeUniformEnabled:Bool = false, ?uniformFloats:Array<UniformFloat>, ?autoUpdateTextures:Bool):Void

Inject custom glsl code into the fragmentshader of a program.

Parameters:

glslCode

a String what contains the glsl code

uTimeUniformEnabled

if true you can use the global time uiform

uniformFloats

an Array of custom UniformFloats

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setFormula(name:String, newFormula:String, ?autoUpdateTextures:Bool):Void

Define formulas to change the calculation for element attributes at runtime

Parameters:

name

a String with the attribute identifier

newFormula

a String what contains the formula

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setFragmentFloatPrecision(?precision:String, ?autoUpdateTextures:Bool):Void

Set the float precision for the fragmentshader

Parameters:

precision

a String what can be "low", "medium" or "high"

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setFragmentIntPrecision(?precision:String, ?autoUpdateTextures:Bool):Void

Set the integer precision for the fragmentshader

Parameters:

precision

a String what can be "low", "medium" or "high"

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setFragmentSamplerPrecision(?precision:String, ?autoUpdateTextures:Bool):Void

Set the sampler2D precision for the fragmentshader

Parameters:

precision

a String what can be "low", "medium" or "high"

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setVertexFloatPrecision(?precision:String, ?autoUpdateTextures:Bool):Void

Set the float precision for the vertexShader

Parameters:

precision

a String what can be "low", "medium" or "high"

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setVertexIntPrecision(?precision:String, ?autoUpdateTextures:Bool):Void

Set the integer precision for the vertexShader

Parameters:

precision

a String what can be "low", "medium" or "high"

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setVertexSamplerPrecision(?precision:String, ?autoUpdateTextures:Bool):Void

Set the sampler2D precision for the vertexShader

Parameters:

precision

a String what can be "low", "medium" or "high"

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

snapToPixel(?pixelDivisor:Float, ?autoUpdateTextures:Bool):Void

Activate pixelsnapping

Parameters:

pixelDivisor

a Float multiplicator at which snapping is to take place, set it to null to disable pixelsnapping

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

discardAtAlpha(?atAlphaValue:Float, ?autoUpdateTextures:Bool):Void

From which alpha value the pixels are discarded.

Parameters:

atAlphaValue

a Float value for the alpha limit (0.0 to 1.0), set it to null to disable discarding

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setTexture(texture:Texture, ?identifier:String, ?autoUpdateTextures:Bool):Void

Assign a Texture instance to a texture-layer (by identifier).

Parameters:

texture

Texture instance

identifier

texture-layer identifier (optional) - without it, the first available or "default" is used

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

setMultiTexture(textureUnits:Array<Texture>, ?identifier:String, ?autoUpdateTextures:Bool):Void

Assign multiple Texture instances to a texture-layer (by identifier). Can switch between them by using an @texUnit("identifier") integer attribute inside the Element.

Parameters:

textureUnits

an Array of Texture instances

identifier

texture-layer identifier (optional) - without it, the first available or "default" is used

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

addTexture(texture:Texture, ?identifier:String, ?autoUpdateTextures:Bool):Void

Adds a Texture to a texture-layer (by identifier). Can switch between them by using an @texUnit("identifier") integer attribute inside the Element.

Parameters:

texture

Texture instance

identifier

texture-layer identifier (optional) - without it, the first available or "default" is used

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

removeTexture(texture:Texture, ?identifier:String, ?autoUpdateTextures:Bool):Void

Removes a Texture from a texture-layer (by identifier) or from all layers where it is used.

Parameters:

texture

Texture instance

identifier

texture-layer identifier (optional)

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

removeAllTexture(?identifier:String, ?autoUpdateTextures:Bool):Void

Removes all Textures of a texture-layer (by identifier) or removes all textures from all layers.

Parameters:

identifier

texture-layer identifier (optional)

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

@:value({ identifier : null })hasTexture(texture:Texture, ?identifier:String):Bool

Returns true if the program or a specific texture-layer contains a texture.

Parameters:

texture

Texture instance

identifier

texture-layer identifier, if set to null it searches into all texture-layers

autoUpdateTextures

set it to true (update) or false (no update), otherwise the .autoupdateTexture property is used

updateTextures():Void

Updates all texture changes and recompiles the shader.

setActiveTextureGlIndex(texture:Texture, index:Int):Void

To set the opengl index manually if using multiple textures.

Parameters:

texture

Texture instance

index

Integer value for the index (starts by 0)