#include <renderabletextcomponent.h>
Public Member Functions | |
RenderableTextComponentInstance (EntityInstance &entity, Component &resource) | |
virtual bool | init (utility::ErrorState &errorState) override |
const FontInstance & | getFont () const |
bool | setText (const std::string &text, utility::ErrorState &error) |
void | setColor (const glm::vec3 &color) |
bool | setText (int lineIndex, const std::string &text, utility::ErrorState &error) |
bool | addLine (const std::string &text, utility::ErrorState &error) |
void | setLineIndex (int index) |
const std::string & | getText () |
const std::string & | getText (int index) |
void | resize (int lines) |
int | getCount () const |
void | clear () |
const math::Rect & | getBoundingBox () const |
const math::Rect & | getBoundingBox (int index) |
virtual RenderableGlyph * | getRenderableGlyph (uint index, float scale, utility::ErrorState &error) const =0 |
const MaterialInstance & | getMaterialInstance () const |
MaterialInstance & | getMaterialInstance () |
float | getDPIScale () const |
![]() | |
RenderableComponentInstance (EntityInstance &entity, Component &resource) | |
void | draw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix) |
void | setVisible (bool visible) |
bool | isVisible () const |
virtual bool | isSupported (nap::CameraComponentInstance &camera) const |
![]() | |
ComponentInstance (EntityInstance &entity, Component &resource) | |
virtual void | update (double deltaTime) |
nap::EntityInstance * | getEntityInstance () const |
nap::Component * | getComponent () const |
template<typename T > | |
T * | getComponent () const |
![]() | |
Object () | |
virtual | ~Object () |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Protected Member Functions | |
void | draw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix, const glm::mat4 &modelMatrix) |
bool | hasTransform () const |
const nap::TransformComponentInstance * | getTransform () const |
virtual bool | setup (float scale, utility::ErrorState &errorState) |
![]() | |
virtual void | onDraw (IRenderTarget &renderTarget, VkCommandBuffer commandBuffer, const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix)=0 |
Protected Attributes | |
FontInstance * | mFont = nullptr |
Pointer to the font, set on initialization. More... | |
RenderService * | mRenderService = nullptr |
Pointer to the Renderer. More... | |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Draws text into the currently active render target. This is the runtime version of the RenderableTextComponent resource. Use the Renderable2DTextComponent to render text in screen space and the Renderable3DTextComopnent to render text in 3D space.
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.
RenderableTextComponentInstance | ( | EntityInstance & | entity, |
Component & | resource | ||
) |
bool addLine | ( | const std::string & | text, |
utility::ErrorState & | error | ||
) |
Adds a new line of text to the end of the cache. Only allowed on app update, not render. Current selection will point to he newly added line after this call.
text | the line of text to add |
error | list of unsupported characters |
void clear | ( | ) |
Clears the entire line cache.
|
protected |
Draws the text into to active render target using the provided matrices. Call this in derived classes based on extracted matrices.
renderTarget | bound render target |
commandBuffer | active command buffer |
viewMatrix | the camera world space location |
projectionMatrix | the camera projection matrix |
modelMatrix | the location of the text in the world |
const math::Rect& getBoundingBox | ( | ) | const |
Returns the bounding box of the current line selection in pixels.
const math::Rect& getBoundingBox | ( | int | index | ) |
index | the line index to get the bounding box for. |
int getCount | ( | ) | const |
Returns the total number of available lines to update or draw.
float getDPIScale | ( | ) | const |
Returns the font dpi scaling factor
const FontInstance& getFont | ( | ) | const |
MaterialInstance& getMaterialInstance | ( | ) |
const MaterialInstance& getMaterialInstance | ( | ) | const |
|
pure virtual |
Needs to be implemented by derived classes. Creates a Glyph that can be rendered using the given index and scaling factor.
index | the index to create the render-able glyph for. |
scale | the render-able glyph scaling factor. |
error | contains the error if the glyph representation could not be created. |
Implemented in Renderable2DTextComponentInstance, and Renderable3DTextComponentInstance.
const std::string& getText | ( | ) |
Returns the text associated with the current line index selection.
const std::string& getText | ( | int | index | ) |
Returns the text associated with the given line index.
index | the line index. |
|
protected |
|
protected |
|
overridevirtual |
Initialize this component
errorState | contains information if operation fails |
Reimplemented from RenderableComponentInstance.
Reimplemented in Renderable2DTextComponentInstance, and Renderable3DTextComponentInstance.
void resize | ( | int | lines | ) |
Resizes the cache to the given number of lines. Lines can be drawn / updated individually.
lines | new number of lines the cache can hold. |
void setColor | ( | const glm::vec3 & | color | ) |
Updates text color
color | new text color |
void setLineIndex | ( | int | index | ) |
bool setText | ( | const std::string & | text, |
utility::ErrorState & | error | ||
) |
Set the text to draw at the current line index. Call setLineIndex() before this call to ensure the right index is updated. Only set or change text on app update, not render.
text | the new line of text to draw. |
error | list of unsupported characters |
bool setText | ( | int | lineIndex, |
const std::string & | text, | ||
utility::ErrorState & | error | ||
) |
Set the text to draw at the given line index. Only set or change text on app update, not render.
lineIndex | the line index |
text | the new line of text |
error | list of unsupported characters |
|
protectedvirtual |
Loads the shader and initializes this component, call this in a derived class on initialization.
scale | the font scaling factor |
errorState | holds the error message when initialization fails |
|
protected |
Pointer to the font, set on initialization.
|
protected |
Pointer to the Renderer.