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 _CEGUIDirect3D10Renderer_h_ 00028 #define _CEGUIDirect3D10Renderer_h_ 00029 00030 #include "../../Renderer.h" 00031 #include "../../Size.h" 00032 #include "../../Vector.h" 00033 #include <vector> 00034 #include <map> 00035 00036 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC) 00037 # ifdef CEGUIDIRECT3D10RENDERER_EXPORTS 00038 # define D3D10_GUIRENDERER_API __declspec(dllexport) 00039 # else 00040 # define D3D10_GUIRENDERER_API __declspec(dllimport) 00041 # endif 00042 #else 00043 # define D3D10_GUIRENDERER_API 00044 #endif 00045 00046 #if defined(_MSC_VER) 00047 # pragma warning(push) 00048 # pragma warning(disable : 4251) 00049 #endif 00050 00051 // D3D forward refs 00052 struct ID3D10Device; 00053 struct ID3D10Effect; 00054 struct ID3D10EffectTechnique; 00055 struct ID3D10InputLayout; 00056 struct ID3D10EffectShaderResourceVariable; 00057 struct ID3D10EffectMatrixVariable; 00058 struct ID3D10ShaderResourceView; 00059 struct D3DXMATRIX; 00060 00061 // Start of CEGUI namespace section 00062 namespace CEGUI 00063 { 00064 class Direct3D10GeometryBuffer; 00065 class Direct3D10Texture; 00066 00068 class D3D10_GUIRENDERER_API Direct3D10Renderer : public Renderer 00069 { 00070 public: 00091 static Direct3D10Renderer& bootstrapSystem(ID3D10Device* device, 00092 const int abi = CEGUI_VERSION_ABI); 00093 00109 static void destroySystem(); 00110 00115 static Direct3D10Renderer& create(ID3D10Device* device, 00116 const int abi = CEGUI_VERSION_ABI); 00117 00125 static void destroy(Direct3D10Renderer& renderer); 00126 00128 ID3D10Device& getDirect3DDevice() const; 00129 00131 void bindTechniquePass(const BlendMode mode, const bool clipped); 00133 void setCurrentTextureShaderResource(ID3D10ShaderResourceView* srv); 00135 void setProjectionMatrix(D3DXMATRIX& matrix); 00137 void setWorldMatrix(D3DXMATRIX& matrix); 00138 00139 // Implement interface from Renderer 00140 RenderTarget& getDefaultRenderTarget(); 00141 GeometryBuffer& createGeometryBuffer(); 00142 void destroyGeometryBuffer(const GeometryBuffer& buffer); 00143 void destroyAllGeometryBuffers(); 00144 TextureTarget* createTextureTarget(); 00145 void destroyTextureTarget(TextureTarget* target); 00146 void destroyAllTextureTargets(); 00147 Texture& createTexture(const String& name); 00148 Texture& createTexture(const String& name, 00149 const String& filename, 00150 const String& resourceGroup); 00151 Texture& createTexture(const String& name, const Sizef& size); 00152 void destroyTexture(Texture& texture); 00153 void destroyTexture(const String& name); 00154 void destroyAllTextures(); 00155 Texture& getTexture(const String& name) const; 00156 bool isTextureDefined(const String& name) const; 00157 void beginRendering(); 00158 void endRendering(); 00159 void setDisplaySize(const Sizef& sz); 00160 const Sizef& getDisplaySize() const; 00161 const Vector2f& getDisplayDPI() const; 00162 uint getMaxTextureSize() const; 00163 const String& getIdentifierString() const; 00164 00165 protected: 00167 Direct3D10Renderer(ID3D10Device* device); 00168 00170 ~Direct3D10Renderer(); 00171 00173 Sizef getViewportSize(); 00174 00176 void throwIfNameExists(const String& name) const; 00178 static void logTextureCreation(const String& name); 00180 static void logTextureDestruction(const String& name); 00181 00183 static String d_rendererID; 00185 ID3D10Device* d_device; 00187 Sizef d_displaySize; 00189 Vector2f d_displayDPI; 00191 RenderTarget* d_defaultTarget; 00193 typedef std::vector<TextureTarget*> TextureTargetList; 00195 TextureTargetList d_textureTargets; 00197 typedef std::vector<Direct3D10GeometryBuffer*> GeometryBufferList; 00199 GeometryBufferList d_geometryBuffers; 00201 typedef std::map<String, Direct3D10Texture*, StringFastLessCompare 00202 CEGUI_MAP_ALLOC(String, Direct3D10Texture*)> TextureMap; 00204 TextureMap d_textures; 00206 ID3D10Effect* d_effect; 00208 ID3D10EffectTechnique* d_normalClippedTechnique; 00210 ID3D10EffectTechnique* d_normalUnclippedTechnique; 00212 ID3D10EffectTechnique* d_premultipliedClippedTechnique; 00214 ID3D10EffectTechnique* d_premultipliedUnclippedTechnique; 00216 ID3D10InputLayout* d_inputLayout; 00218 ID3D10EffectShaderResourceVariable* d_boundTextureVariable; 00220 ID3D10EffectMatrixVariable* d_worldMatrixVariable; 00222 ID3D10EffectMatrixVariable* d_projectionMatrixVariable; 00223 }; 00224 00225 00226 } // End of CEGUI namespace section 00227 00228 #if defined(_MSC_VER) 00229 # pragma warning(pop) 00230 #endif 00231 00232 #endif // end of guard _CEGUIDirect3D10Renderer_h_