Crazy Eddie's GUI System  0.8.4
GeometryBuffer.h
00001 /***********************************************************************
00002     created:    Tue Mar 3 2009
00003     author:     Paul D Turner (parts based on original code by Thomas Suter)
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 _CEGUIIrrlichtGeometryBuffer_h_
00028 #define _CEGUIIrrlichtGeometryBuffer_h_
00029 
00030 #include "CEGUI/RendererModules/Irrlicht/RendererDef.h"
00031 #include "CEGUI/GeometryBuffer.h"
00032 #include "CEGUI/Rect.h"
00033 #include "CEGUI/Vector.h"
00034 #include <irrlicht.h>
00035 #include <vector>
00036 
00037 #if defined(_MSC_VER)
00038 #   pragma warning(push)
00039 #   pragma warning(disable : 4251)
00040 #endif
00041 
00042 // Start of CEGUI namespace section
00043 namespace CEGUI
00044 {
00045 class IrrlichtTexture;
00046 
00048 class IRR_GUIRENDERER_API IrrlichtGeometryBuffer : public GeometryBuffer
00049 {
00050 public:
00052     IrrlichtGeometryBuffer(irr::video::IVideoDriver& driver);
00053 
00055     const irr::core::matrix4& getMatrix() const;
00056 
00058     irr::video::SMaterial& getMaterial();
00060     const irr::video::SMaterial& getMaterial() const;
00061 
00062 
00063     // implement GeometryBuffer interface
00064     void draw() const;
00065     void setTranslation(const Vector3f& v);
00066     void setRotation(const Quaternion& r);
00067     void setPivot(const Vector3f& p);
00068     void setClippingRegion(const Rectf& region);
00069     void appendVertex(const Vertex& vertex);
00070     void appendGeometry(const Vertex* const vbuff, uint vertex_count);
00071     void setActiveTexture(Texture* texture);
00072     void reset();
00073     Texture* getActiveTexture() const;
00074     uint getVertexCount() const;
00075     uint getBatchCount() const;
00076     void setRenderEffect(RenderEffect* effect);
00077     RenderEffect* getRenderEffect();
00078     void setClippingActive(const bool active);
00079     bool isClippingActive() const;
00080     // overrides of GeometryBuffer base functions.
00081     void setBlendMode(const BlendMode mode);
00082 
00083 protected:
00085     void updateMatrix() const;
00086     void setupClipping() const;
00087     void cleanupClipping() const;
00088 
00090     struct BatchInfo
00091     {
00092         irr::video::ITexture* texture;
00093         uint vertexCount;
00094         bool clip;
00095     };
00096 
00098     irr::video::IVideoDriver& d_driver;
00100     IrrlichtTexture* d_activeTexture;
00102     mutable irr::video::SMaterial d_material;
00104     Rectf d_clipRect;
00106     bool d_clippingActive;
00108     irr::core::vector3d<irr::f32> d_translation;
00110     irr::core::quaternion d_rotation;
00112     irr::core::vector3d<irr::f32> d_pivot;
00114     RenderEffect* d_effect;
00116     mutable irr::core::matrix4 d_matrix;
00118     mutable bool d_matrixValid;
00120     typedef std::vector<BatchInfo> BatchList;
00122     typedef std::vector<irr::video::S3DVertex> VertexList;
00124     typedef std::vector<irr::u16> IndexList;
00126     BatchList d_batches;
00128     VertexList d_vertices;
00130     IndexList d_indices;
00132     const float d_xViewDir;
00134     const float d_texelOffset;
00136     mutable irr::core::rect<irr::s32> d_savedViewport;
00138     mutable irr::core::matrix4 d_savedProjection;
00139 };
00140 
00141 
00142 } // End of  CEGUI namespace section
00143 
00144 #if defined(_MSC_VER)
00145 #   pragma warning(pop)
00146 #endif
00147 
00148 #endif  // end of guard _CEGUIIrrlichtGeometryBuffer_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends