OpenPolygon  1.0.0
OpenPolygon is a Rendering Engine
textelement.h
1 /*
2  Copyright (C) 2014 - 2016 Mutzii
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
18 #ifndef TEXTELEMENT_H
19 #define TEXTELEMENT_H
20 
21 #include "index.h"
22 #include "display.h"
23 
24 #include "rendercomponent.h"
25 #include "fontmanager.h"
26 #include "shadermanager.h"
27 #include "meshmanager.h"
28 #include "positionmanager.h"
29 
30 #include "texturebufferobject.h"
31 #include "panelelement.h"
32 #include "embedded_resource.h"
33 
34 namespace Engine
35 {
36 
41  {
42  float spacebar_length;
43 
44  float box_size_x;
45  float box_size_y;
46 
47  float box_distance;
48  };
49 
57  class TextElement : public RenderElement
58  {
59  public:
60 
61  enum PanelOptions
62  {
63  PANEL_ACTIVE = 0x2,
64  PANEL_SIZE_AUTO = 0x4
65  };
66 
67 
68  explicit TextElement();
69  ~TextElement();
70 
75  void create( OpenPolygonDisplay * display );
76 
82  void draw( const DrawEvent & event );
83 
89  void setColour( const Vector4f & colour );
90 
96  void setPanelColour( const Vector4f & colour );
97  void setPanelSize( const Vector2f & size );
98  void setPanelOptions( uint panel_options );
99 
105  void setCaption( string draw_text );
106 
112  void setPosition( const Vector3f & position );
113 
120  void setSize( const Vector2f & size );
121 
122  protected:
123 
124  /* Draw Text Indirect */
125  void DrawTextIndirect( const DrawEvent & event );
126  void createIndirectData(void);
127 
128  /* Render Panel */
129  void DrawPanel( const DrawEvent & event );
130 
131  /* General functions */
132  Vector2f getScreenPixelVector(void);
133 
134  private:
135 
136  const int SPACE_BAR = 0x20;
137  int CHAR_SPACE_PX;
138  int SPACE_BAR_PX;
140  uint mMatrixBuffer;
141 
142  Vector2f mSize;
143  Vector3f mPos;
144  Vector4f mFontColour;
145  Vector4f mBackColour;
146  std::string mDrawText;
148  Element * mElement;
149  Mesh * mMesh;
150  Position * mPosition;
151  IShader * mShader;
152  Texture * mFontImages; //
153  //Texture * mTBO;
154 
155  //PanelElement
156  PanelElement * m_panel_element;
157  Position * m_panel_position;
158  Vector3f m_panel_scale;
159 
160 // //old
161 // Element * mPanelElement;
162 // Mesh * mPanelMesh;
163 // Position * mPanelPosition;
164 // IShader * mPanelShader;
165 // Vector3f mPanelScale;
166 
167  struct TextElementBuildData * mBuildData;
168 
169  FontManager * mFont;
170  RenderManager * mRender;
172  TextureBufferObject * mTBO;
173  TextureBufferObject * m_atlas_tbo;
174 
175  OpenPolygonDisplay * m_display;
176 
177  /* Panel Options */
178  bool m_panelelement_active;
179  bool m_panelelement_size_auto;
180 
181  FontAtlas m_atlas;
182  };
183 
184 }
185 
186 #endif // TEXTELEMENT_H
The Texture class.
Definition: texture.h:37
Definition: element.h:23
void setPosition(const Vector3f &position)
setPosition
Definition: TextElement.cpp:162
The IShader - abstract / interface class.
Definition: IShader.h:30
The TextElementBuildData struct.
Definition: textelement.h:40
void setPanelColour(const Vector4f &colour)
setPanelColour
Definition: TextElement.cpp:366
The DrawEvent - event class.
Definition: drawevent.h:31
The FontManager managed the Fonts.
Definition: fontmanager.h:64
The PanelElement - Panel Objective class.
Definition: panelelement.h:35
The RenderManager class.
Definition: rendermanager.h:42
The TextureBufferObject class.
Definition: texturebufferobject.h:35
void setCaption(string draw_text)
setCaption
Definition: TextElement.cpp:371
The Mesh class.
Definition: mesh.h:32
void setColour(const Vector4f &colour)
setColour
Definition: TextElement.cpp:361
The RenderElement - contained component Element - abstract class.
Definition: rendercomponent.h:103
The Element - base component class - for 2D Entitys.
Definition: element.h:28
The TextElement - Text Objective class.
Definition: textelement.h:57
Definition: fontmanager.h:45
The OpenPolygonDisplay - display abstract class.
Definition: display.h:55
void setSize(const Vector2f &size)
setSize
Definition: TextElement.cpp:351
void draw(const DrawEvent &event)
draw
Definition: TextElement.cpp:139
void create(OpenPolygonDisplay *display)
create
Definition: TextElement.cpp:56
The Position class.
Definition: position.h:29