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