Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: Mon Feb 9 2009 00003 author: Paul D Turner 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 _CEGUIDirect3D9Renderer_h_ 00028 #define _CEGUIDirect3D9Renderer_h_ 00029 00030 #include "../../Base.h" 00031 #include "../../Renderer.h" 00032 #include "../../Size.h" 00033 #include "../../Vector.h" 00034 00035 #include <d3d9.h> 00036 #include <vector> 00037 #include <map> 00038 00039 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC) 00040 # ifdef CEGUIDIRECT3D9RENDERER_EXPORTS 00041 # define DIRECT3D9_GUIRENDERER_API __declspec(dllexport) 00042 # else 00043 # define DIRECT3D9_GUIRENDERER_API __declspec(dllimport) 00044 # endif 00045 #else 00046 # define DIRECT3D9_GUIRENDERER_API 00047 #endif 00048 00049 #if defined(_MSC_VER) 00050 # pragma warning(push) 00051 # pragma warning(disable : 4251) 00052 #endif 00053 00054 // Start of CEGUI namespace section 00055 namespace CEGUI 00056 { 00057 class Direct3D9Texture; 00058 class Direct3D9GeometryBuffer; 00059 00064 class DIRECT3D9_GUIRENDERER_API Direct3D9Renderer : public Renderer 00065 { 00066 public: 00087 static Direct3D9Renderer& bootstrapSystem(LPDIRECT3DDEVICE9 device, 00088 const int abi = CEGUI_VERSION_ABI); 00089 00105 static void destroySystem(); 00106 00111 static Direct3D9Renderer& create(LPDIRECT3DDEVICE9 device, 00112 const int abi = CEGUI_VERSION_ABI); 00113 00121 static void destroy(Direct3D9Renderer& renderer); 00122 00124 void preD3DReset(); 00125 00127 void postD3DReset(); 00128 00130 LPDIRECT3DDEVICE9 getDevice() const; 00131 00133 Texture& createTexture(const String& name, LPDIRECT3DTEXTURE9 tex); 00134 00136 bool supportsNonSquareTexture(); 00137 00139 bool supportsNPOTTextures(); 00140 00142 Sizef getAdjustedSize(const Sizef& sz); 00143 00145 void setupRenderingBlendMode(const BlendMode mode, 00146 const bool force = false); 00147 00148 // implement Renderer interface 00149 RenderTarget& getDefaultRenderTarget(); 00150 GeometryBuffer& createGeometryBuffer(); 00151 void destroyGeometryBuffer(const GeometryBuffer& buffer); 00152 void destroyAllGeometryBuffers(); 00153 TextureTarget* createTextureTarget(); 00154 void destroyTextureTarget(TextureTarget* target); 00155 void destroyAllTextureTargets(); 00156 Texture& createTexture(const String& name); 00157 Texture& createTexture(const String& name, 00158 const String& filename, 00159 const String& resourceGroup); 00160 Texture& createTexture(const String& name, const Sizef& size); 00161 void destroyTexture(Texture& texture); 00162 void destroyTexture(const String& name); 00163 void destroyAllTextures(); 00164 Texture& getTexture(const String& name) const; 00165 bool isTextureDefined(const String& name) const; 00166 void beginRendering(); 00167 void endRendering(); 00168 void setDisplaySize(const Sizef& sz); 00169 const Sizef& getDisplaySize() const; 00170 const Vector2f& getDisplayDPI() const; 00171 uint getMaxTextureSize() const; 00172 const String& getIdentifierString() const; 00173 00174 private: 00176 Direct3D9Renderer(LPDIRECT3DDEVICE9 device); 00177 00179 virtual ~Direct3D9Renderer(); 00180 00182 void throwIfNameExists(const String& name) const; 00184 static void logTextureCreation(const String& name); 00186 static void logTextureDestruction(const String& name); 00187 00189 Sizef getViewportSize(); 00191 float getSizeNextPOT(float sz) const; 00192 00194 static String d_rendererID; 00196 LPDIRECT3DDEVICE9 d_device; 00198 Sizef d_displaySize; 00200 Vector2f d_displayDPI; 00202 RenderTarget* d_defaultTarget; 00204 typedef std::vector<TextureTarget*> TextureTargetList; 00206 TextureTargetList d_textureTargets; 00208 typedef std::vector<Direct3D9GeometryBuffer*> GeometryBufferList; 00210 GeometryBufferList d_geometryBuffers; 00212 typedef std::map<String, Direct3D9Texture*, StringFastLessCompare 00213 CEGUI_MAP_ALLOC(String, Direct3D9Texture*)> TextureMap; 00215 TextureMap d_textures; 00217 uint d_maxTextureSize; 00219 bool d_supportNPOTTex; 00221 bool d_supportNonSquareTex; 00223 BlendMode d_activeBlendMode; 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 _CEGUIDirect3D9Renderer_h_