1 /* 2 GWEN 3 Copyright (c) 2011 Facepunch Studios 4 See license in Gwen.h 5 */ 6 7 #ifndef GWEN_RENDERERS_OPENGL_DEBUGFONT_H 8 #define GWEN_RENDERERS_OPENGL_DEBUGFONT_H 9 10 #include "../ThirdPartyLibs/Gwen/Gwen.h" 11 #include "../ThirdPartyLibs/Gwen/Renderers/OpenGL.h" 12 13 void restoreOpenGLState(); 14 void saveOpenGLState(int screenWidth, int screenHeight); 15 16 namespace Gwen 17 { 18 namespace Renderer 19 { 20 class OpenGL_DebugFont : public Gwen::Renderer::Base 21 { 22 float m_retinaScale; 23 24 public: 25 struct Vertex 26 { 27 float x, y, z; 28 float u, v; 29 unsigned char r, g, b, a; 30 }; 31 32 static const int MaxVerts = 1024; 33 34 OpenGL_DebugFont(float retinaScale); 35 ~OpenGL_DebugFont(); 36 37 void RenderText(Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString& text); 38 Gwen::Point MeasureText(Gwen::Font* pFont, const Gwen::UnicodeString& text); 39 40 virtual void Begin(); 41 virtual void End(); 42 43 virtual void SetDrawColor(Gwen::Color color); 44 virtual void DrawFilledRect(Gwen::Rect rect); 45 void DrawTexturedRect(Gwen::Texture* pTexture, Gwen::Rect rect, float u1, float v1, float u2, float v2); 46 47 void StartClip(); 48 void EndClip(); 49 50 void Flush(); 51 void AddVert(int x, int y, float u = 0.0f, float v = 0.0f); 52 Resize(int width,int height)53 virtual void Resize(int width, int height) {} 54 55 protected: 56 Gwen::Texture* m_pFontTexture; 57 float m_fFontScale[2]; 58 float m_fLetterSpacing; 59 60 Gwen::Color m_Color; 61 int m_iVertNum; 62 Vertex m_Vertices[MaxVerts]; 63 }; 64 65 } // namespace Renderer 66 } // namespace Gwen 67 #endif 68