Pyrogenesis  trunk
GUIRenderer.h
Go to the documentation of this file.
1 /* Copyright (C) 2015 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. 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 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_GUIRENDERER
19 #define INCLUDED_GUIRENDERER
20 
22 #include "graphics/Texture.h"
23 #include "lib/res/handle.h"
24 #include "ps/CStr.h"
25 #include "ps/Shapes.h"
26 
27 #include <vector>
28 
29 struct SGUIImageEffects;
30 struct SGUIImage;
31 
32 namespace GUIRenderer
33 {
34  class IGLState
35  {
36  public:
37  virtual ~IGLState() {};
38  virtual void Set(const CTexturePtr& tex) = 0;
39  virtual void Unset() = 0;
40  };
41 
42  struct SDrawCall
43  {
44  SDrawCall(const SGUIImage* image) : m_Image(image) {}
45  CRect ComputeTexCoords() const;
46 
48 
51 
53  int m_CellID;
54 
56 
59 
61  float m_DeltaZ;
62 
63  CColor m_BorderColor; // == CColor() for no border
65  };
66 
67  class DrawCalls : public std::vector<SDrawCall>
68  {
69  public:
70  DrawCalls();
71  // Copy/assignment results in an empty list, not an actual copy
72  DrawCalls(const DrawCalls&);
73  DrawCalls& operator=(const DrawCalls&);
74  };
75 }
76 
77 #include "gui/CGUISprite.h"
78 
79 namespace GUIRenderer
80 {
81  void UpdateDrawCallCache(DrawCalls& Calls, const CStr& SpriteName, const CRect& Size, int CellID, std::map<CStr, CGUISprite*>& Sprites);
82 
83  void Draw(DrawCalls& Calls, float Z);
84 }
85 
86 #endif // INCLUDED_GUIRENDERER
Definition: CGUISprite.h:44
int m_CellID
Definition: GUIRenderer.h:53
CTexturePtr m_Texture
Definition: GUIRenderer.h:50
Definition: Shapes.h:36
CRect m_ObjectSize
Definition: GUIRenderer.h:52
bool m_HasTexture
Definition: GUIRenderer.h:49
virtual void Set(const CTexturePtr &tex)=0
shared_ptr< CShaderTechnique > CShaderTechniquePtr
Definition: ShaderTechnique.h:113
void UpdateDrawCallCache(DrawCalls &Calls, const CStr &SpriteName, const CRect &Size, int CellID, std::map< CStr, CGUISprite * > &Sprites)
Definition: GUIRenderer.cpp:60
Definition: GUIRenderer.h:32
CRect m_Vertices
Definition: GUIRenderer.h:60
float m_DeltaZ
Definition: GUIRenderer.h:61
bool m_EnableBlending
Definition: GUIRenderer.h:55
virtual void Unset()=0
Definition: GUIRenderer.h:67
virtual ~IGLState()
Definition: GUIRenderer.h:37
A CGUISprite is actually a collage of several real sprites, this struct represents is such real sprit...
Definition: CGUISprite.h:56
Definition: GUIRenderer.h:42
std::shared_ptr< CTexture > CTexturePtr
Definition: Texture.h:22
CColor m_ShaderColorParameter
Definition: GUIRenderer.h:58
Definition: Decompose.h:22
CColor m_BorderColor
Definition: GUIRenderer.h:63
SDrawCall(const SGUIImage *image)
Definition: GUIRenderer.h:44
void Draw(DrawCalls &Calls, float Z)
Definition: GUIRenderer.cpp:345
const SGUIImage * m_Image
Definition: GUIRenderer.h:47
CShaderTechniquePtr m_Shader
Definition: GUIRenderer.h:57
CColor m_BackColor
Definition: GUIRenderer.h:64
Definition: GUIRenderer.h:34
Rectangle class used for screen rectangles.
Definition: Shapes.h:73