Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: Sat Mar 7 2009 00003 author: Paul D Turner (parts based on code by Rajko Stojadinovic) 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 _CEGUIDirect3D10GeometryBuffer_h_ 00028 #define _CEGUIDirect3D10GeometryBuffer_h_ 00029 00030 #include "../../GeometryBuffer.h" 00031 #include "CEGUI/RendererModules/Direct3D10/Renderer.h" 00032 #include "../../Rect.h" 00033 #include "../../Quaternion.h" 00034 00035 #include <d3dx10.h> 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 Direct3D10Texture; 00046 00048 class D3D10_GUIRENDERER_API Direct3D10GeometryBuffer : public GeometryBuffer 00049 { 00050 public: 00052 Direct3D10GeometryBuffer(Direct3D10Renderer& owner); 00053 00055 ~Direct3D10GeometryBuffer(); 00056 00058 const D3DXMATRIX* getMatrix() const; 00059 00060 // Implement GeometryBuffer interface. 00061 void draw() const; 00062 void setTranslation(const Vector3f& v); 00063 void setRotation(const Quaternion& r); 00064 void setPivot(const Vector3f& p); 00065 void setClippingRegion(const Rectf& region); 00066 void appendVertex(const Vertex& vertex); 00067 void appendGeometry(const Vertex* const vbuff, uint vertex_count); 00068 void setActiveTexture(Texture* texture); 00069 void reset(); 00070 Texture* getActiveTexture() const; 00071 uint getVertexCount() const; 00072 uint getBatchCount() const; 00073 void setRenderEffect(RenderEffect* effect); 00074 RenderEffect* getRenderEffect(); 00075 void setClippingActive(const bool active); 00076 bool isClippingActive() const; 00077 00078 protected: 00080 void updateMatrix() const; 00082 void syncHardwareBuffer() const; 00084 void allocateVertexBuffer(const size_t count) const; 00086 void cleanupVertexBuffer() const; 00087 00089 struct D3DVertex 00090 { 00092 FLOAT x, y, z; 00094 DWORD diffuse; 00096 float tu, tv; 00097 }; 00098 00100 struct BatchInfo 00101 { 00102 const ID3D10ShaderResourceView* texture; 00103 uint vertexCount; 00104 bool clip; 00105 }; 00106 00107 // Direct3D10Renderer object that created and owns this GeometryBuffer. 00108 Direct3D10Renderer& d_owner; 00110 ID3D10Device& d_device; 00112 Direct3D10Texture* d_activeTexture; 00114 mutable ID3D10Buffer* d_vertexBuffer; 00116 mutable UINT d_bufferSize; 00118 mutable bool d_bufferSynched; 00120 typedef std::vector<BatchInfo> BatchList; 00122 BatchList d_batches; 00124 typedef std::vector<D3DVertex> VertexList; 00126 VertexList d_vertices; 00128 Rectf d_clipRect; 00130 bool d_clippingActive; 00132 Vector3f d_translation; 00134 Quaternion d_rotation; 00136 Vector3f d_pivot; 00138 RenderEffect* d_effect; 00140 mutable D3DXMATRIX d_matrix; 00142 mutable bool d_matrixValid; 00143 }; 00144 00145 00146 } // End of CEGUI namespace section 00147 00148 #if defined(_MSC_VER) 00149 # pragma warning(pop) 00150 #endif 00151 00152 #endif // end of guard _CEGUIDirect3D10GeometryBuffer_h_