Crazy Eddie's GUI System  0.8.7
RendererModules/Direct3D9/Renderer.h
1 /***********************************************************************
2  created: Mon Feb 9 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIDirect3D9Renderer_h_
28 #define _CEGUIDirect3D9Renderer_h_
29 
30 #include "../../Base.h"
31 #include "../../Renderer.h"
32 #include "../../Size.h"
33 #include "../../Vector.h"
34 
35 #include <d3d9.h>
36 #include <vector>
37 #include <map>
38 
39 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
40 # ifdef CEGUIDIRECT3D9RENDERER_EXPORTS
41 # define DIRECT3D9_GUIRENDERER_API __declspec(dllexport)
42 # else
43 # define DIRECT3D9_GUIRENDERER_API __declspec(dllimport)
44 # endif
45 #else
46 # define DIRECT3D9_GUIRENDERER_API
47 #endif
48 
49 #if defined(_MSC_VER)
50 # pragma warning(push)
51 # pragma warning(disable : 4251)
52 #endif
53 
54 // Start of CEGUI namespace section
55 namespace CEGUI
56 {
57 class Direct3D9Texture;
58 class Direct3D9GeometryBuffer;
59 
64 class DIRECT3D9_GUIRENDERER_API Direct3D9Renderer : public Renderer
65 {
66 public:
87  static Direct3D9Renderer& bootstrapSystem(LPDIRECT3DDEVICE9 device,
88  const int abi = CEGUI_VERSION_ABI);
89 
105  static void destroySystem();
106 
111  static Direct3D9Renderer& create(LPDIRECT3DDEVICE9 device,
112  const int abi = CEGUI_VERSION_ABI);
113 
121  static void destroy(Direct3D9Renderer& renderer);
122 
138  bool isTexCoordSystemFlipped() const { return false; }
139 
141  void preD3DReset();
142 
144  void postD3DReset();
145 
147  LPDIRECT3DDEVICE9 getDevice() const;
148 
150  Texture& createTexture(const String& name, LPDIRECT3DTEXTURE9 tex);
151 
154 
157 
160 
163  const bool force = false);
164 
165  // implement Renderer interface
173  Texture& createTexture(const String& name);
175  const String& filename,
176  const String& resourceGroup);
177  Texture& createTexture(const String& name, const Sizef& size);
178  void destroyTexture(Texture& texture);
179  void destroyTexture(const String& name);
181  Texture& getTexture(const String& name) const;
182  bool isTextureDefined(const String& name) const;
184  void endRendering();
185  void setDisplaySize(const Sizef& sz);
186  const Sizef& getDisplaySize() const;
187  const Vector2f& getDisplayDPI() const;
188  uint getMaxTextureSize() const;
189  const String& getIdentifierString() const;
190 
191 private:
193  Direct3D9Renderer(LPDIRECT3DDEVICE9 device);
194 
196  virtual ~Direct3D9Renderer();
197 
199  void throwIfNameExists(const String& name) const;
201  static void logTextureCreation(const String& name);
203  static void logTextureDestruction(const String& name);
204 
206  Sizef getViewportSize();
208  float getSizeNextPOT(float sz) const;
209 
211  static String d_rendererID;
213  LPDIRECT3DDEVICE9 d_device;
215  Sizef d_displaySize;
217  Vector2f d_displayDPI;
219  RenderTarget* d_defaultTarget;
221  typedef std::vector<TextureTarget*> TextureTargetList;
223  TextureTargetList d_textureTargets;
225  typedef std::vector<Direct3D9GeometryBuffer*> GeometryBufferList;
227  GeometryBufferList d_geometryBuffers;
229  typedef std::map<String, Direct3D9Texture*, StringFastLessCompare
230  CEGUI_MAP_ALLOC(String, Direct3D9Texture*)> TextureMap;
232  TextureMap d_textures;
234  uint d_maxTextureSize;
236  bool d_supportNPOTTex;
238  bool d_supportNonSquareTex;
240  BlendMode d_activeBlendMode;
241  };
242 
243 } // End of CEGUI namespace section
244 
245 #if defined(_MSC_VER)
246 # pragma warning(pop)
247 #endif
248 
249 #endif // end of guard _CEGUIDirect3D9Renderer_h_
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::Direct3D9Renderer::createTexture
Texture & createTexture(const String &name)
Create a 'null' Texture object.
CEGUI::Direct3D9Renderer::createTextureTarget
TextureTarget * createTextureTarget()
Create a TextureTarget that can be used to cache imagery; this is a RenderTarget that does not lose i...
CEGUI::Direct3D9Renderer::destroySystem
static void destroySystem()
Convenience function to cleanup the CEGUI system and related objects that were created by calling the...
CEGUI::Direct3D9Renderer::destroyAllTextures
void destroyAllTextures()
Destroy all Texture objects created by this Renderer.
CEGUI::Direct3D9Renderer::beginRendering
void beginRendering()
Perform any operations required to put the system into a state ready for rendering operations to begi...
CEGUI::StringFastLessCompare
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5580
CEGUI::Direct3D9Renderer::destroyTexture
void destroyTexture(const String &name)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::Direct3D9Renderer::supportsNPOTTextures
bool supportsNPOTTextures()
return true if we can use NPOT texture dimensions.
CEGUI::Direct3D9Renderer::createTexture
Texture & createTexture(const String &name, LPDIRECT3DTEXTURE9 tex)
create a CEGUI::texture from an existing D3D texture
CEGUI::Direct3D9Renderer::isTextureDefined
bool isTextureDefined(const String &name) const
Return whether a texture with the given name exists.
CEGUI::Direct3D9Renderer::createTexture
Texture & createTexture(const String &name, const Sizef &size)
Create a Texture object with the given pixel dimensions as specified by size.
CEGUI::Direct3D9Renderer::createGeometryBuffer
GeometryBuffer & createGeometryBuffer()
Create a new GeometryBuffer and return a reference to it. You should remove the GeometryBuffer from a...
CEGUI::Direct3D9Renderer::postD3DReset
void postD3DReset()
support function to be called after a Reset on the Direct3DDevice9.
CEGUI::Direct3D9Renderer::getDisplaySize
const Sizef & getDisplaySize() const
Return the size of the display or host window in pixels.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Direct3D9Renderer::destroyAllTextureTargets
void destroyAllTextureTargets()
Destory all TextureTarget objects created by this Renderer.
CEGUI::Direct3D9Renderer::preD3DReset
void preD3DReset()
support function to be called prior to a Reset on the Direct3DDevice9.
CEGUI::Vector2< float >
CEGUI::Direct3D9Renderer::destroyAllGeometryBuffers
void destroyAllGeometryBuffers()
Destroy all GeometryBuffer objects created by this Renderer.
CEGUI::Direct3D9Renderer::destroy
static void destroy(Direct3D9Renderer &renderer)
Destroy an Direct3D9Renderer object.
CEGUI::Direct3D9Renderer::supportsNonSquareTexture
bool supportsNonSquareTexture()
return true if we can use non square textures.
CEGUI::Direct3D9Renderer::bootstrapSystem
static Direct3D9Renderer & bootstrapSystem(LPDIRECT3DDEVICE9 device, const int abi=CEGUI_VERSION_ABI)
Convenience function that creates the required objects to initialise the CEGUI system.
CEGUI::Direct3D9Renderer::endRendering
void endRendering()
Perform any operations required to finalise rendering.
CEGUI::Direct3D9Renderer::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::Direct3D9Renderer::create
static Direct3D9Renderer & create(LPDIRECT3DDEVICE9 device, const int abi=CEGUI_VERSION_ABI)
Create an Direct3D9Renderer object.
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::Direct3D9Renderer::destroyGeometryBuffer
void destroyGeometryBuffer(const GeometryBuffer &buffer)
Destroy a GeometryBuffer that was returned when calling the createGeometryBuffer function....
CEGUI::Direct3D9Renderer::getMaxTextureSize
uint getMaxTextureSize() const
Return the pixel size of the maximum supported texture.
CEGUI::Direct3D9Texture
Texture implementation for the Direct3D9Renderer.
Definition: RendererModules/Direct3D9/Texture.h:45
CEGUI::Direct3D9Renderer::setupRenderingBlendMode
void setupRenderingBlendMode(const BlendMode mode, const bool force=false)
set the render states for the specified BlendMode.
CEGUI::BlendMode
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: Renderer.h:62
CEGUI::Direct3D9Renderer::setDisplaySize
void setDisplaySize(const Sizef &sz)
Set the size of the display or host window in pixels for this Renderer object.
CEGUI::Direct3D9Renderer::destroyTextureTarget
void destroyTextureTarget(TextureTarget *target)
Function that cleans up TextureTarget objects created with the createTextureTarget function.
CEGUI::Direct3D9Renderer::getDevice
LPDIRECT3DDEVICE9 getDevice() const
return the Direct3D 9 Device interface used by this renderer object.
CEGUI::Direct3D9Renderer::getDisplayDPI
const Vector2f & getDisplayDPI() const
Return the resolution of the display or host window in dots per inch.
CEGUI::RenderTarget
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:60
CEGUI::Size< float >
CEGUI::TextureTarget
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:41
CEGUI::Direct3D9Renderer::getAdjustedSize
Sizef getAdjustedSize(const Sizef &sz)
returns Size object from sz adjusted for hardware capabilities.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::Direct3D9Renderer::getTexture
Texture & getTexture(const String &name) const
Return a Texture object that was previously created by calling the createTexture functions.
CEGUI::Direct3D9Renderer::getIdentifierString
const String & getIdentifierString() const
Return identification string for the renderer module.
CEGUI::Direct3D9Renderer
Renderer class to interface with Direct3D 9.
Definition: RendererModules/Direct3D9/Renderer.h:65
CEGUI::Renderer
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:84
CEGUI::Direct3D9Renderer::createTexture
Texture & createTexture(const String &name, const String &filename, const String &resourceGroup)
Create a Texture object using the given image file.
CEGUI::Direct3D9Renderer::isTexCoordSystemFlipped
bool isTexCoordSystemFlipped() const
Returns if the texture coordinate system is vertically flipped or not. The original of a texture coor...
Definition: RendererModules/Direct3D9/Renderer.h:138
CEGUI::Direct3D9Renderer::getDefaultRenderTarget
RenderTarget & getDefaultRenderTarget()
Returns the default RenderTarget object. The default render target is is typically one that targets t...