Crazy Eddies GUI System 0.7.6
|
00001 /*********************************************************************** 00002 filename: CEGUIDirect3D10GeometryBuffer.h 00003 created: Sat Mar 7 2009 00004 author: Paul D Turner (parts based on code by Rajko Stojadinovic) 00005 *************************************************************************/ 00006 /*************************************************************************** 00007 * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining 00010 * a copy of this software and associated documentation files (the 00011 * "Software"), to deal in the Software without restriction, including 00012 * without limitation the rights to use, copy, modify, merge, publish, 00013 * distribute, sublicense, and/or sell copies of the Software, and to 00014 * permit persons to whom the Software is furnished to do so, subject to 00015 * the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be 00018 * included in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00021 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00022 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00023 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00024 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00025 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00026 * OTHER DEALINGS IN THE SOFTWARE. 00027 ***************************************************************************/ 00028 #ifndef _CEGUIDirect3D10GeometryBuffer_h_ 00029 #define _CEGUIDirect3D10GeometryBuffer_h_ 00030 00031 #include "../../CEGUIGeometryBuffer.h" 00032 #include "CEGUIDirect3D10Renderer.h" 00033 #include "../../CEGUIRect.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 Vector3& v); 00063 void setRotation(const Vector3& r); 00064 void setPivot(const Vector3& p); 00065 void setClippingRegion(const Rect& 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 00076 protected: 00078 void updateMatrix() const; 00080 void syncHardwareBuffer() const; 00082 void allocateVertexBuffer(const size_t count) const; 00084 void cleanupVertexBuffer() const; 00085 00087 struct D3DVertex 00088 { 00090 FLOAT x, y, z; 00092 DWORD diffuse; 00094 float tu, tv; 00095 }; 00096 00097 // Direct3D10Renderer object that created and owns this GeometryBuffer. 00098 Direct3D10Renderer& d_owner; 00100 ID3D10Device& d_device; 00102 Direct3D10Texture* d_activeTexture; 00104 mutable ID3D10Buffer* d_vertexBuffer; 00106 mutable UINT d_bufferSize; 00108 mutable bool d_bufferSynched; 00110 typedef std::pair<const ID3D10ShaderResourceView*, uint> BatchInfo; 00112 typedef std::vector<BatchInfo> BatchList; 00114 BatchList d_batches; 00116 typedef std::vector<D3DVertex> VertexList; 00118 VertexList d_vertices; 00120 Rect d_clipRect; 00122 Vector3 d_translation; 00124 Vector3 d_rotation; 00126 Vector3 d_pivot; 00128 RenderEffect* d_effect; 00130 mutable D3DXMATRIX d_matrix; 00132 mutable bool d_matrixValid; 00133 }; 00134 00135 00136 } // End of CEGUI namespace section 00137 00138 #if defined(_MSC_VER) 00139 # pragma warning(pop) 00140 #endif 00141 00142 #endif // end of guard _CEGUIDirect3D10GeometryBuffer_h_