NAP
Public Attributes | List of all members
Renderable2DTextComponent Class Reference

#include <renderable2dtextcomponent.h>

Public Attributes

utility::ETextOrientation mOrientation = utility::ETextOrientation::Left
 Property: 'Orientation' text draw orientation. More...
 
glm::ivec2 mLocation = { 0,0 }
 Property: 'Location' text location in pixel coordinates. More...
 
EDepthMode mDepthMode = EDepthMode::NoReadWrite
 Property: 'DepthMode' how text is handled by z-buffer. More...
 
bool mIgnoreTransform = true
 Property: 'IgnoreTransform' if the transform is ignored when present. More...
 
bool mDPIAware = true
 Property: 'DPI Aware' if the text is scaled based on display DPI. High DPI rendering must be enabled for this flag to have any effect. More...
 
- Public Attributes inherited from RenderableTextComponent
ResourcePtr< FontmFont
 Property: 'Font' that represents the style of the text. More...
 
std::string mText
 Property: 'Text' to draw. More...
 
RGBColorFloat mColor = { 1.0f, 1.0f, 1.0f }
 Property: 'TextColor' the color of the text. More...
 
- Public Attributes inherited from RenderableComponent
bool mVisible = true
 Property: 'Visible' if this object is rendered to target by the render service. More...
 
ResourcePtr< RenderLayermLayer
 Property: 'Layer' the render layer assigned to this component. More...
 
std::vector< ResourcePtr< RenderTag > > mTags
 Property: 'Tags' List of tags specifying the category this render component belongs to. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Public Member Functions inherited from Component
virtual void getDependentComponents (std::vector< rtti::TypeInfo > &components) const
 
virtual const rtti::TypeInfo getInstanceType () const =0
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 
- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Allows you to render text at a specific location in screen space. Use this component when you want to render text at a specific location on screen or in a render-target. Use the Renderable3DTextComponent to draw text in 3D space with a perspective camera.

Call draw() in the render part of your application to render text to a specific location on screen or a render-target. It is also possible to render the text using RenderService::renderObjects(), this is similar to how meshes are rendered. In that case the x/y location of the camera influences the final location of the text.

When the parent entity has a transform component attached to it and 'IgnoreTransform' is set to false, the x/y Translate values are used as offset in pixel space. 2D text cannot be scaled or rotated, this ensures that every Glyph is rendered in it's native resolution. When rendering this component through the render interface of the render service it is advised to use an orthographic camera.

It is possible to cache multiple lines at once, where each line can be selected and drawn individually inside a render loop. This is useful when you want the same component to render multiple lines of text, removing the need to declare a component for each individual line. You cannot update or add a line of text when rendering a frame: inside the render loop. Only update or add new lines of text on update. You can however change the position and line of text to draw inside the render loop.

For example, on update:

// Set text for next draw operation
text_component.resize(blobs.size());
for (int i = 0; i < blobs.size(); i++)
{
text_component.setText(i, utility::stringFormat("Blob %d", i + 1), error);
}

And on render:

// Set text for next draw operation
for (int i = 0; i < blobs.size(); i++)
{
// Get blob location in screen space
glm::vec3 blob_pos = locs[i];
glm::vec2 text_pos = persp_camera.worldToScreen(blob_pos, mRenderWindow->getRectPixels());
// Set location, select line and draw
text_comp.setLocation(text_pos);
text_comp.setLineIndex(i);
text_comp.draw(*mRenderWindow)
}
Inheritance diagram for Renderable2DTextComponent:
[legend]
Collaboration diagram for Renderable2DTextComponent:
[legend]

Member Data Documentation

◆ mDepthMode

Property: 'DepthMode' how text is handled by z-buffer.

◆ mDPIAware

bool mDPIAware = true

Property: 'DPI Aware' if the text is scaled based on display DPI. High DPI rendering must be enabled for this flag to have any effect.

◆ mIgnoreTransform

bool mIgnoreTransform = true

Property: 'IgnoreTransform' if the transform is ignored when present.

◆ mLocation

glm::ivec2 mLocation = { 0,0 }

Property: 'Location' text location in pixel coordinates.

◆ mOrientation

Property: 'Orientation' text draw orientation.