GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GlGwenRenderer.hpp
Go to the documentation of this file.
1 #ifndef RADIX_GWEN_RENDERER_HPP
2 #define RADIX_GWEN_RENDERER_HPP
3 
4 #include <memory>
5 #include <vector>
6 
7 #include <epoxy/gl.h>
8 
9 #include <Gwen/Gwen.h>
10 #include <Gwen/BaseRender.h>
11 
12 namespace radix {
13 
14 class VBO;
15 
16 class GlGwenRenderer : public Gwen::Renderer::Base {
17 public:
18  struct Vertex {
19  float x, y;
20  float u, v;
21  unsigned char r, g, b, a;
22  };
23 
26 
27  void Init() final override;
28 
29  void Begin() final override;
30  void End() final override;
31 
32  void SetDrawColor(Gwen::Color color) final override;
33  void DrawFilledRect(Gwen::Rect rect) final override;
34 
35  void StartClip() final override;
36  void EndClip() final override;
37 
38  void DrawTexturedRect(Gwen::Texture *tex, Gwen::Rect rect, float u1 = 0.0f,
39  float v1 = 0.0f, float u2 = 1.0f, float v2 = 1.0f) final override;
40  void LoadTexture(Gwen::Texture *tex) final override;
41  void FreeTexture(Gwen::Texture *tex) final override;
42  Gwen::Color PixelColour(Gwen::Texture *tex, unsigned int x, unsigned int y,
43  const Gwen::Color &col_default) final override;
44 
45  void RenderText(Gwen::Font *font, Gwen::Point pos, const Gwen::UnicodeString &text) final override;
46  Gwen::Point MeasureText(Gwen::Font *font, const Gwen::UnicodeString &text) final override;
47 
48 protected:
49 
50  static const int MaxVerts = 1024;
51 
52  void flush();
53  void addVert(int x, int y, float u = 0.0f, float v = 0.0f);
54  void loadDebugFont();
55 
56  GLuint vao;
57  std::unique_ptr<VBO> vbo;
58 
59  std::unique_ptr<Gwen::Texture> fontTex;
60  float fontScale[2];
62  std::vector<char> fontSpacing;
63 
64  Gwen::Color color;
65  int vertNum;
66  Vertex vertices[MaxVerts];
67 };
68 
69 } /* namespace radix */
70 
71 #endif /* RADIX_GWEN_RENDERER_HPP */
Gwen::Color PixelColour(Gwen::Texture *tex, unsigned int x, unsigned int y, const Gwen::Color &col_default) finaloverride
Definition: GlGwenRenderer.cpp:242
void DrawTexturedRect(Gwen::Texture *tex, Gwen::Rect rect, float u1=0.0f, float v1=0.0f, float u2=1.0f, float v2=1.0f) finaloverride
Definition: GlGwenRenderer.cpp:172
Definition: Font.hpp:11
static const int MaxVerts
Definition: GlGwenRenderer.hpp:50
Definition: GameController.hpp:7
void SetDrawColor(Gwen::Color color) finaloverride
Definition: GlGwenRenderer.cpp:144
GlGwenRenderer()
Definition: GlGwenRenderer.cpp:20
float v
Definition: GlGwenRenderer.hpp:20
Gwen::Color color
Definition: GlGwenRenderer.hpp:64
Definition: VBO.hpp:9
void Begin() finaloverride
Definition: GlGwenRenderer.cpp:51
float y
Definition: GlGwenRenderer.hpp:19
Definition: Uncollider.hpp:10
void StartClip() finaloverride
Definition: GlGwenRenderer.cpp:148
unsigned char r
Definition: GlGwenRenderer.hpp:21
void addVert(int x, int y, float u=0.0f, float v=0.0f)
Definition: GlGwenRenderer.cpp:105
Definition: GlGwenRenderer.hpp:18
void Init() finaloverride
Definition: GlGwenRenderer.cpp:46
Definition: Texture.hpp:6
GLuint vao
Definition: GlGwenRenderer.hpp:56
unsigned char b
Definition: GlGwenRenderer.hpp:21
float x
Definition: GlGwenRenderer.hpp:19
void loadDebugFont()
Definition: GlGwenRenderer.cpp:270
void RenderText(Gwen::Font *font, Gwen::Point pos, const Gwen::UnicodeString &text) finaloverride
Definition: GlGwenRenderer.cpp:287
float fontLetterSpacing
Definition: GlGwenRenderer.hpp:61
float fontScale[2]
Definition: GlGwenRenderer.hpp:60
void flush()
Definition: GlGwenRenderer.cpp:64
std::unique_ptr< VBO > vbo
Definition: GlGwenRenderer.hpp:57
~GlGwenRenderer()
Definition: GlGwenRenderer.cpp:42
Gwen::Point MeasureText(Gwen::Font *font, const Gwen::UnicodeString &text) finaloverride
Definition: GlGwenRenderer.cpp:323
unsigned char a
Definition: GlGwenRenderer.hpp:21
Definition: GlGwenRenderer.hpp:16
int vertNum
Definition: GlGwenRenderer.hpp:65
Vertex vertices[MaxVerts]
Definition: GlGwenRenderer.hpp:66
void FreeTexture(Gwen::Texture *tex) finaloverride
Definition: GlGwenRenderer.cpp:230
unsigned char g
Definition: GlGwenRenderer.hpp:21
void End() finaloverride
Definition: GlGwenRenderer.cpp:60
float u
Definition: GlGwenRenderer.hpp:20
std::vector< char > fontSpacing
Definition: GlGwenRenderer.hpp:62
void DrawFilledRect(Gwen::Rect rect) finaloverride
Definition: GlGwenRenderer.cpp:121
void EndClip() finaloverride
Definition: GlGwenRenderer.cpp:167
std::unique_ptr< Gwen::Texture > fontTex
Definition: GlGwenRenderer.hpp:59
void LoadTexture(Gwen::Texture *tex) finaloverride
Definition: GlGwenRenderer.cpp:203