TextLabelRenderer
in package
Table of Contents
Properties
- $gl : GLState
- $loadedFonts : array<string, BitmapFontAtlas>
- The loaded bitmap fonts
- $loadedFontTextures : array<string, Texture>
- The loaded font textures
- $renderGroups : array<string, TextLabelRenderGroup>
- An array of render groups
- $shaderProgram : ShaderProgram
- The label rendering shader
Methods
- __construct() : mixed
- Constructor
- attachPass() : void
- Attaches a render pass to the pipeline
- createLabel() : TextLabel
- Creates a label
- destroyLabel() : void
- Destroys a label
- loadFont() : void
- Loads a bitmap font under the given handle.
- synchroniseWithEntites() : void
- Will update the internal label groups to match the current state of the entities.
- unloadFont() : void
- Unloads a bitmap font under the given handle.
- getDefaultFontHandle() : string
- Returns the default font handle, aka the first font that was loaded.
- rebuildRenderGroup() : void
- Rebuilds the render group
Properties
$gl
private
GLState
$gl
$loadedFonts
The loaded bitmap fonts
private
array<string, BitmapFontAtlas>
$loadedFonts
= []
$loadedFontTextures
The loaded font textures
private
array<string, Texture>
$loadedFontTextures
= []
$renderGroups
An array of render groups
private
array<string, TextLabelRenderGroup>
$renderGroups
= []
$shaderProgram
The label rendering shader
private
ShaderProgram
$shaderProgram
Methods
__construct()
Constructor
public
__construct(GLState $gl) : mixed
Parameters
- $gl : GLState
-
The current GL state.
attachPass()
Attaches a render pass to the pipeline
public
attachPass(RenderPipeline $pipeline, RenderTargetResource $renderTarget) : void
Parameters
- $pipeline : RenderPipeline
- $renderTarget : RenderTargetResource
createLabel()
Creates a label
public
createLabel(string $text[, string|null $fontHandle = null ][, string $renderGroup = 'default' ][, Transform|null $transform = null ][, bool $isStatic = false ]) : TextLabel
A label is bacically just a piece of text with a position, font and color. Keep a good look on the "renderGroup" every label is assigned to a render group. Labels with the same render group will be rendered together in one draw call. This means when you change only one label in a group, the entire group will be re-rendered and uploaded to the GPU.
Parameters
- $text : string
- $fontHandle : string|null = null
- $renderGroup : string = 'default'
- $transform : Transform|null = null
- $isStatic : bool = false
Return values
TextLabeldestroyLabel()
Destroys a label
public
destroyLabel(TextLabel $label) : void
Parameters
- $label : TextLabel
loadFont()
Loads a bitmap font under the given handle.
public
loadFont(string $handle, BitmapFontAtlas $fontAtlas) : void
The handle acts as a simple identifier for the font.
Parameters
- $handle : string
- $fontAtlas : BitmapFontAtlas
synchroniseWithEntites()
Will update the internal label groups to match the current state of the entities.
public
synchroniseWithEntites(EntitiesInterface $entities) : void
Parameters
- $entities : EntitiesInterface
unloadFont()
Unloads a bitmap font under the given handle.
public
unloadFont(string $handle) : void
Parameters
- $handle : string
getDefaultFontHandle()
Returns the default font handle, aka the first font that was loaded.
private
getDefaultFontHandle() : string
Return values
stringrebuildRenderGroup()
Rebuilds the render group
private
rebuildRenderGroup(TextLabelRenderGroup $renderGroup) : void
Parameters
- $renderGroup : TextLabelRenderGroup