Crazy Eddie's GUI System  0.8.4
GeometryBuffer.h
00001 /***********************************************************************
00002     created:    Tue Feb 17 2009
00003     author:     Paul D Turner
00004 *************************************************************************/
00005 /***************************************************************************
00006  *   Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
00007  *
00008  *   Permission is hereby granted, free of charge, to any person obtaining
00009  *   a copy of this software and associated documentation files (the
00010  *   "Software"), to deal in the Software without restriction, including
00011  *   without limitation the rights to use, copy, modify, merge, publish,
00012  *   distribute, sublicense, and/or sell copies of the Software, and to
00013  *   permit persons to whom the Software is furnished to do so, subject to
00014  *   the following conditions:
00015  *
00016  *   The above copyright notice and this permission notice shall be
00017  *   included in all copies or substantial portions of the Software.
00018  *
00019  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00020  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00022  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00023  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00024  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  *   OTHER DEALINGS IN THE SOFTWARE.
00026  ***************************************************************************/
00027 #ifndef _CEGUIOgreGeometryBuffer_h_
00028 #define _CEGUIOgreGeometryBuffer_h_
00029 
00030 #include "CEGUI/GeometryBuffer.h"
00031 #include "CEGUI/RendererModules/Ogre/Renderer.h"
00032 #include "CEGUI/Rect.h"
00033 #include "CEGUI/Quaternion.h"
00034 
00035 #include <OgreMatrix4.h>
00036 #include <OgreColourValue.h>
00037 #include <OgreRenderOperation.h>
00038 #include <OgreTexture.h>
00039 
00040 #include <utility>
00041 #include <vector>
00042 
00043 // Ogre forward refs
00044 namespace Ogre
00045 {
00046 class RenderSystem;
00047 }
00048 
00049 // Start of CEGUI namespace section
00050 namespace CEGUI
00051 {
00053 class OGRE_GUIRENDERER_API OgreGeometryBuffer : public GeometryBuffer
00054 {
00055 public:
00057     OgreGeometryBuffer(OgreRenderer& owner, Ogre::RenderSystem& rs);
00059     virtual ~OgreGeometryBuffer();
00060 
00062     const Ogre::Matrix4& getMatrix() const;
00063 
00064     // implement CEGUI::GeometryBuffer interface.
00065     virtual void draw() const;
00066     virtual void setTranslation(const Vector3f& v);
00067     virtual void setRotation(const Quaternion& r);
00068     virtual void setPivot(const Vector3f& p);
00069     virtual void setClippingRegion(const Rectf& region);
00070     virtual void appendVertex(const Vertex& vertex);
00071     virtual void appendGeometry(const Vertex* const vbuff, uint vertex_count);
00072     virtual void setActiveTexture(Texture* texture);
00073     virtual void reset();
00074     virtual Texture* getActiveTexture() const;
00075     virtual uint getVertexCount() const;
00076     virtual uint getBatchCount() const;
00077     virtual void setRenderEffect(RenderEffect* effect);
00078     virtual RenderEffect* getRenderEffect();
00079     void setClippingActive(const bool active);
00080     bool isClippingActive() const;
00081 
00082 protected:
00084     Ogre::RGBA colourToOgre(const Colour& col) const;
00086     void updateMatrix() const;
00088     void syncHardwareBuffer() const;
00090     void initialiseTextureStates() const;
00091 
00093     struct OgreVertex
00094     {
00095         float x, y, z;
00096         Ogre::RGBA diffuse;
00097         float u, v;
00098     };
00099 
00101     struct BatchInfo
00102     {
00103         Ogre::TexturePtr texture;
00104         uint vertexCount;
00105         bool clip;
00106     };
00107 
00109     OgreRenderer& d_owner;
00111     Ogre::RenderSystem& d_renderSystem;
00113     OgreTexture* d_activeTexture;
00115     Rectf d_clipRect;
00117     bool d_clippingActive;
00119     Vector3f d_translation;
00121     Quaternion d_rotation;
00123     Vector3f d_pivot;
00125     RenderEffect* d_effect;
00127     Vector2f d_texelOffset;
00129     mutable Ogre::Matrix4 d_matrix;
00131     mutable bool d_matrixValid;
00133     mutable Ogre::RenderOperation d_renderOp;
00135     mutable Ogre::HardwareVertexBufferSharedPtr d_hwBuffer;
00137     mutable bool d_sync;
00139     typedef std::vector<BatchInfo> BatchList;
00141     BatchList d_batches;
00143     typedef std::vector<OgreVertex> VertexList;
00145     VertexList d_vertices;
00146 };
00147 
00148 
00149 } // End of  CEGUI namespace section
00150 
00151 #endif  // end of guard _CEGUIOgreGeometryBuffer_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends