NAP
renderable2dtextcomponent.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "renderabletextcomponent.h"
9 
10 // External Includes
11 #include <fontutils.h>
12 
13 namespace nap
14 {
15  // Forward Declares
16  class Renderable2DTextComponentInstance;
17  class RenderService;
18 
66  {
67  RTTI_ENABLE(RenderableTextComponent)
69 
70  public:
72  glm::ivec2 mLocation = { 0,0 };
74  bool mIgnoreTransform = true;
75  bool mDPIAware = true;
76  };
77 
78 
125  {
127  public:
129  RenderableTextComponentInstance(entity, resource) { }
130 
136  virtual bool init(utility::ErrorState& errorState) override;
137 
147  void draw(IRenderTarget& target);
148 
152  utility::ETextOrientation getOrientation() const { return mOrientation; }
153 
158  void setOrientation(utility::ETextOrientation orientation) { mOrientation = orientation; }
159 
166  const glm::ivec2& getLocation() const { return mLocation; }
167 
174  void setLocation(const glm::ivec2& coordinates) { mLocation = coordinates; }
175 
182  glm::ivec2 getTextPosition(float scale);
183 
191  virtual RenderableGlyph* getRenderableGlyph(uint index, float scale, utility::ErrorState& error) const override;
192 
197  virtual bool isSupported(nap::CameraComponentInstance& camera) const override;
198 
199  protected:
212  virtual void onDraw(IRenderTarget& renderTarget, VkCommandBuffer commandBuffer, const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix) override;
213 
214  private:
216 
221  void computeTextModelMatrix(glm::mat4x4& outMatrix);
222 
223  glm::ivec2 mLocation = { 0,0 };
224  RenderService* mService = nullptr;
225  bool mIgnoreTransform = true;
226  bool mDPIAware = true;
227  };
228 }
nap::RenderableTextComponentInstance
Definition: renderabletextcomponent.h:53
nap::uint
unsigned int uint
Definition: numeric.h:23
nap::Renderable2DTextComponentInstance::Renderable2DTextComponentInstance
Renderable2DTextComponentInstance(EntityInstance &entity, Component &resource)
Definition: renderable2dtextcomponent.h:128
nap::Renderable2DTextComponentInstance::setLocation
void setLocation(const glm::ivec2 &coordinates)
Definition: renderable2dtextcomponent.h:174
nap::IRenderTarget
Definition: irendertarget.h:21
nap::Renderable2DTextComponent
Definition: renderable2dtextcomponent.h:65
nap::EDepthMode::NoReadWrite
@ NoReadWrite
Neither read or write depth.
nap::CameraComponentInstance
Definition: cameracomponent.h:38
nap::Renderable2DTextComponentInstance::getLocation
const glm::ivec2 & getLocation() const
Definition: renderable2dtextcomponent.h:166
nap::EDepthMode
EDepthMode
Definition: materialcommon.h:40
nap::Renderable2DTextComponentInstance
Definition: renderable2dtextcomponent.h:124
nap::utility::ErrorState
Definition: errorstate.h:19
nap::RenderableTextComponent
Definition: renderabletextcomponent.h:32
nap::Renderable2DTextComponentInstance::getOrientation
utility::ETextOrientation getOrientation() const
Definition: renderable2dtextcomponent.h:152
nap::EntityInstance
Definition: entity.h:34
nap::Component
Definition: component.h:151
nap::utility::ETextOrientation
ETextOrientation
Definition: fontutils.h:15
nap::RenderableGlyph
Definition: renderableglyph.h:24
nap
Definition: templateapp.h:17
nap::utility::ETextOrientation::Left
@ Left
Draws text to the right of the horizontal coordinate.
nap::Renderable2DTextComponentInstance::setOrientation
void setOrientation(utility::ETextOrientation orientation)
Definition: renderable2dtextcomponent.h:158