|
| Renderable2DTextComponentInstance (EntityInstance &entity, Component &resource) |
|
virtual bool | init (utility::ErrorState &errorState) override |
|
void | draw (IRenderTarget &target) |
|
utility::ETextOrientation | getOrientation () const |
|
void | setOrientation (utility::ETextOrientation orientation) |
|
const glm::ivec2 & | getLocation () const |
|
void | setLocation (const glm::ivec2 &coordinates) |
|
glm::ivec2 | getTextPosition (float scale) |
|
virtual RenderableGlyph * | getRenderableGlyph (uint index, float scale, utility::ErrorState &error) const override |
|
virtual bool | isSupported (nap::CameraComponentInstance &camera) const override |
|
| RenderableTextComponentInstance (EntityInstance &entity, Component &resource) |
|
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) |
|
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 |
|
const std::vector< ResourcePtr< RenderTag > > & | getTags () const |
|
RenderMask | getMask () const |
|
bool | includesMask (RenderMask otherMask) |
|
int | getRank () const |
|
const RenderLayer * | getLayer () 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 |
|
virtual bool | init (utility::ErrorState &errorState) |
|
| Object () |
|
virtual | ~Object () |
|
virtual void | onDestroy () |
|
| Object (Object &)=delete |
|
Object & | operator= (const Object &)=delete |
|
| Object (Object &&)=delete |
|
Object & | operator= (Object &&)=delete |
|
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.
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:
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:
for (int i = 0; i < blobs.size(); i++)
{
glm::vec3 blob_pos = locs[i];
glm::vec2 text_pos = persp_camera.worldToScreen(blob_pos, mRenderWindow->getRectPixels());
text_comp.setLocation(text_pos);
text_comp.setLineIndex(i);
text_comp.draw(*mRenderWindow)
}