Packagestarling.utils
Classpublic class RenderUtil
InheritanceRenderUtil Inheritance Object

A utility class containing methods related to Stage3D and rendering in general.



Public Methods
 MethodDefined By
  
clear(rgb:uint = 0, alpha:Number = 0.0):void
[static] Clears the render context with a certain color and alpha value.
RenderUtil
  
createAGALTexOperation(resultReg:String, uvReg:String, sampler:int, texture:Texture, convertToPmaIfRequired:Boolean = true, tempReg:String = ft0):String
[static] Creates an AGAL source string with a tex operation, including an options list with the appropriate format flag.
RenderUtil
  
getTextureLookupFlags(format:String, mipMapping:Boolean, repeat:Boolean = false, smoothing:String = bilinear):String
[static] Returns the flags that are required for AGAL texture lookup, including the '<' and '>' delimiters.
RenderUtil
  
[static] Returns a bit field uniquely describing texture format and premultiplied alpha, so that each required AGAL variant will get its unique ID.
RenderUtil
  
requestContext3D(stage3D:Stage3D, renderMode:String, profile:*):void
[static] Requests a context3D object from the given Stage3D object.
RenderUtil
  
setSamplerStateAt(sampler:int, mipMapping:Boolean, smoothing:String = bilinear, repeat:Boolean = false):void
[static] Calls setSamplerStateAt at the current context, converting the given parameters to their low level counterparts.
RenderUtil
Method Detail
clear()method
public static function clear(rgb:uint = 0, alpha:Number = 0.0):void

Clears the render context with a certain color and alpha value.

Parameters

rgb:uint (default = 0)
 
alpha:Number (default = 0.0)

createAGALTexOperation()method 
public static function createAGALTexOperation(resultReg:String, uvReg:String, sampler:int, texture:Texture, convertToPmaIfRequired:Boolean = true, tempReg:String = ft0):String

Creates an AGAL source string with a tex operation, including an options list with the appropriate format flag.

Note that values for repeat/clamp, filter and mip-filter are not included in the options list, since it's preferred to set those values at runtime via setSamplerStateAt.

Starling expects every color to have its alpha value premultiplied into the RGB channels. Thus, if this method encounters a non-PMA texture, it will (per default) convert the color in the result register to PMA mode, resulting in an additional mul-operation.

Parameters

resultReg:String — the register to write the result into.
 
uvReg:String — the register containing the texture coordinates.
 
sampler:int — the texture sampler to use.
 
texture:Texture — the texture that's active in the given texture sampler.
 
convertToPmaIfRequired:Boolean (default = true) — indicates if a non-PMA color should be converted to PMA.
 
tempReg:String (default = ft0) — if 'resultReg' is the output register and PMA conversion is done, a temporary register is needed.

Returns
String — the AGAL source code, line break(s) included.
getTextureLookupFlags()method 
public static function getTextureLookupFlags(format:String, mipMapping:Boolean, repeat:Boolean = false, smoothing:String = bilinear):String

Returns the flags that are required for AGAL texture lookup, including the '<' and '>' delimiters.

Parameters

format:String
 
mipMapping:Boolean
 
repeat:Boolean (default = false)
 
smoothing:String (default = bilinear)

Returns
String
getTextureVariantBits()method 
public static function getTextureVariantBits(texture:Texture):uint

Returns a bit field uniquely describing texture format and premultiplied alpha, so that each required AGAL variant will get its unique ID. This method is most useful when overriding the programVariantName method of custom effects.

Parameters

texture:Texture

Returns
uint — a bit field using the 3 least significant bits.
requestContext3D()method 
public static function requestContext3D(stage3D:Stage3D, renderMode:String, profile:*):void

Requests a context3D object from the given Stage3D object.

Parameters

stage3D:Stage3D — The stage3D object the context needs to be requested from.
 
renderMode:String — The 'Context3DRenderMode' to use when requesting the context.
 
profile:* — If you know exactly which 'Context3DProfile' you want to use, simply pass a String with that profile.

If you are unsure which profiles are supported on the current device, you can also pass an Array of profiles; they will be tried one after the other (starting at index 0), until a working profile is found. If none of the given profiles is supported, the Stage3D object will dispatch an ERROR event.

You can also pass the String 'auto' to use the best available profile automatically. This will try all known Stage3D profiles, beginning with the most powerful.

setSamplerStateAt()method 
public static function setSamplerStateAt(sampler:int, mipMapping:Boolean, smoothing:String = bilinear, repeat:Boolean = false):void

Calls setSamplerStateAt at the current context, converting the given parameters to their low level counterparts.

Parameters

sampler:int
 
mipMapping:Boolean
 
smoothing:String (default = bilinear)
 
repeat:Boolean (default = false)