Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Ogre/GeometryBuffer.h
1 /***********************************************************************
2  created: Tue Feb 17 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIOgreGeometryBuffer_h_
28 #define _CEGUIOgreGeometryBuffer_h_
29 
30 #include "CEGUI/GeometryBuffer.h"
31 #include "CEGUI/RendererModules/Ogre/Renderer.h"
32 #include "CEGUI/Rect.h"
33 #include "CEGUI/Quaternion.h"
34 
35 #include <OgreMatrix4.h>
36 #include <OgreColourValue.h>
37 #include <OgreRenderOperation.h>
38 #include <OgreTexture.h>
39 
40 #include <utility>
41 #include <vector>
42 
43 // Ogre forward refs
44 namespace Ogre
45 {
46 class RenderSystem;
47 }
48 
49 // Start of CEGUI namespace section
50 namespace CEGUI
51 {
53 class OGRE_GUIRENDERER_API OgreGeometryBuffer : public GeometryBuffer
54 {
55 public:
57  OgreGeometryBuffer(OgreRenderer& owner, Ogre::RenderSystem& rs);
59  virtual ~OgreGeometryBuffer();
60 
62  const Ogre::Matrix4& getMatrix() const;
63 
64  // implement CEGUI::GeometryBuffer interface.
65  virtual void draw() const;
66  virtual void setTranslation(const Vector3f& v);
67  virtual void setRotation(const Quaternion& r);
68  virtual void setPivot(const Vector3f& p);
69  virtual void setClippingRegion(const Rectf& region);
70  virtual void appendVertex(const Vertex& vertex);
71  virtual void appendGeometry(const Vertex* const vbuff, uint vertex_count);
72  virtual void setActiveTexture(Texture* texture);
73  virtual void reset();
74  virtual Texture* getActiveTexture() const;
75  virtual uint getVertexCount() const;
76  virtual uint getBatchCount() const;
77  virtual void setRenderEffect(RenderEffect* effect);
78  virtual RenderEffect* getRenderEffect();
79  void setClippingActive(const bool active);
80  bool isClippingActive() const;
81 
82 protected:
84  Ogre::RGBA colourToOgre(const Colour& col) const;
86  void updateMatrix() const;
88  void syncHardwareBuffer() const;
90  void initialiseTextureStates() const;
91 
93  struct OgreVertex
94  {
95  float x, y, z;
96  Ogre::RGBA diffuse;
97  float u, v;
98  };
99 
101  struct BatchInfo
102  {
103  Ogre::TexturePtr texture;
104  uint vertexCount;
105  bool clip;
106  };
107 
111  Ogre::RenderSystem& d_renderSystem;
129  mutable Ogre::Matrix4 d_matrix;
131  mutable bool d_matrixValid;
133  mutable Ogre::RenderOperation d_renderOp;
135  mutable Ogre::HardwareVertexBufferSharedPtr d_hwBuffer;
137  mutable bool d_sync;
139  typedef std::vector<BatchInfo> BatchList;
143  typedef std::vector<OgreVertex> VertexList;
146 };
147 
148 
149 } // End of CEGUI namespace section
150 
151 #endif // end of guard _CEGUIOgreGeometryBuffer_h_