Textogl  1.1.2
OpenGL Text renderer
static_text.hpp
Go to the documentation of this file.
1 
4 // Copyright 2022 Matthew Chandler
5 
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 
24 #ifndef STATIC_TEXT_HPP
25 #define STATIC_TEXT_HPP
26 
27 #include "font.hpp"
28 
30 
32 namespace textogl
33 {
35 
43  {
44  public:
49  // to rebuild in that case.
52  const std::string & utf8_input
53  );
54 
56 
58 
60  void set_font_sys(Font_sys & font);
61 
63 
65  void set_text(const std::string & utf8_input);
66 
68  void render_text(const Color & color,
69  const Vec2<float> & win_size,
70  const Vec2<float> & pos,
71  const int align_flags = 0
72  );
73 
75  void render_text_rotate(const Color & color,
76  const Vec2<float> & win_size,
77  const Vec2<float> & pos,
78  const float rotation,
79  const int align_flags = 0
80  );
81 
83  void render_text_mat(const Color & color,
87  const Mat4<float> & model_view_projection
88  );
89 
90  private:
91  struct Impl;
92  std::unique_ptr<Impl, void (*)(Impl *)> pimpl;
93  };
94 }
95 
96 #endif // STATIC_TEXT_HPP
Container for font and text rendering.
Definition: font.hpp:60
Object for text which does not change often.
Definition: static_text.hpp:43
Static_text(Font_sys &font, const std::string &utf8_input)
void render_text_mat(const Color &color, const Mat4< float > &model_view_projection)
Render the previously set text, using a model view projection matrix.
void render_text_rotate(const Color &color, const Vec2< float > &win_size, const Vec2< float > &pos, const float rotation, const int align_flags=0)
Render the previously set text, with rotation.
void set_text(const std::string &utf8_input)
Recreate text object with new string.
void set_font_sys(Font_sys &font)
Recreate text object with new Font_sys.
void render_text(const Color &color, const Vec2< float > &win_size, const Vec2< float > &pos, const int align_flags=0)
Render the previously set text.
Font loading and text display.
OpenGL Font rendering types.
Definition: font.hpp:35
Vec4< float > Color
Color vector
Definition: types.hpp:191
typename detail::Mat4_t< T >::type Mat4
4D Matrix
Definition: types.hpp:186
typename detail::Vec2_t< T >::type Vec2
2D Vector
Definition: types.hpp:176