Crazy Eddie's GUI System  0.8.4
GeometryBuffer.h
00001 /***********************************************************************
00002     created:    Wed May 5 2010
00003 *************************************************************************/
00004 /***************************************************************************
00005  *   Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
00006  *
00007  *   Permission is hereby granted, free of charge, to any person obtaining
00008  *   a copy of this software and associated documentation files (the
00009  *   "Software"), to deal in the Software without restriction, including
00010  *   without limitation the rights to use, copy, modify, merge, publish,
00011  *   distribute, sublicense, and/or sell copies of the Software, and to
00012  *   permit persons to whom the Software is furnished to do so, subject to
00013  *   the following conditions:
00014  *
00015  *   The above copyright notice and this permission notice shall be
00016  *   included in all copies or substantial portions of the Software.
00017  *
00018  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00019  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00021  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00022  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00023  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00024  *   OTHER DEALINGS IN THE SOFTWARE.
00025  ***************************************************************************/
00026 #ifndef _CEGUIDirect3D11GeometryBuffer_h_
00027 #define _CEGUIDirect3D11GeometryBuffer_h_
00028 
00029 #include "../../GeometryBuffer.h"
00030 #include "CEGUI/RendererModules/Direct3D11/Renderer.h"
00031 #include "../../Rect.h"
00032 #include "../../Quaternion.h"
00033 
00034 
00035 
00036 #if defined(_MSC_VER)
00037 #   pragma warning(push)
00038 #   pragma warning(disable : 4251)
00039 #endif
00040 
00041 // Start of CEGUI namespace section
00042 namespace CEGUI
00043 {
00044 class Direct3D11Texture;
00045 
00047 class D3D11_GUIRENDERER_API Direct3D11GeometryBuffer : public GeometryBuffer
00048 {
00049 public:
00051     Direct3D11GeometryBuffer(Direct3D11Renderer& owner);
00052 
00054     ~Direct3D11GeometryBuffer();
00055 
00057     const D3DXMATRIX* getMatrix() const;
00058 
00059     // Implement GeometryBuffer interface.
00060     void draw() const;
00061     void setTranslation(const Vector3f& v);
00062     void setRotation(const Quaternion& r);
00063     void setPivot(const Vector3f& p);
00064     void setClippingRegion(const Rectf& region);
00065     void appendVertex(const Vertex& vertex);
00066     void appendGeometry(const Vertex* const vbuff, uint vertex_count);
00067     void setActiveTexture(Texture* texture);
00068     void reset();
00069     Texture* getActiveTexture() const;
00070     uint getVertexCount() const;
00071     uint getBatchCount() const;
00072     void setRenderEffect(RenderEffect* effect);
00073     RenderEffect* getRenderEffect();
00074     void setClippingActive(const bool active);
00075     bool isClippingActive() const;
00076 
00077 protected:
00079     void updateMatrix() const;
00081     void syncHardwareBuffer() const;
00083     void allocateVertexBuffer(const size_t count) const;
00085     void cleanupVertexBuffer() const;
00086 
00088     struct D3DVertex
00089     {
00091         FLOAT x, y, z;
00093         DWORD diffuse;
00095         float tu, tv;
00096     };
00097 
00099     struct BatchInfo
00100     {
00101         const ID3D11ShaderResourceView* texture;
00102         uint vertexCount;
00103         bool clip;
00104     };
00105 
00106     // Direct3D11Renderer object that created and owns this GeometryBuffer.
00107     Direct3D11Renderer& d_owner;
00109     IDevice11& d_device;
00111     Direct3D11Texture* d_activeTexture;
00113     mutable ID3D11Buffer* d_vertexBuffer;
00115     mutable UINT d_bufferSize;
00117     mutable bool d_bufferSynched;
00119     typedef std::vector<BatchInfo> BatchList;
00121     BatchList d_batches;
00123     typedef std::vector<D3DVertex> VertexList;
00125     VertexList d_vertices;
00127     Rectf d_clipRect;
00129     bool d_clippingActive;
00131     Vector3f d_translation;
00133     Quaternion d_rotation;
00135     Vector3f d_pivot;
00137     RenderEffect* d_effect;
00139     mutable D3DXMATRIX d_matrix;
00141     mutable bool d_matrixValid;
00142 };
00143 
00144 
00145 } // End of  CEGUI namespace section
00146 
00147 #if defined(_MSC_VER)
00148 #   pragma warning(pop)
00149 #endif
00150 
00151 #endif  // end of guard _CEGUIDirect3D11GeometryBuffer_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends