Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Irrlicht/Renderer.h
1 /***********************************************************************
2  filename: CEGUIIrrlichtRenderer.h
3  created: Tue Mar 3 2009
4  author: Paul D Turner (parts based on original code by Thomas Suter)
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIIrrlichtRenderer_h_
29 #define _CEGUIIrrlichtRenderer_h_
30 
31 #include "CEGUI/RendererModules/Irrlicht/RendererDef.h"
32 #include "../../Renderer.h"
33 #include "../../Size.h"
34 #include "../../Vector.h"
35 
36 #include <vector>
37 #include <map>
38 
39 #if defined(_MSC_VER)
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
42 #endif
43 
44 // forward reference irrlicht classes
45 namespace irr
46 {
47 class IrrlichtDevice;
48 struct SEvent;
49 
50 namespace video
51 {
52 class IVideoDriver;
53 }
54 
55 namespace io
56 {
57 class IFileSystem;
58 }
59 
60 }
61 
62 // Start of CEGUI namespace section
63 namespace CEGUI
64 {
65 class IrrlichtTexture;
66 class IrrlichtGeometryBuffer;
67 class IrrlichtResourceProvider;
68 class IrrlichtEventPusher;
69 class IrrlichtImageCodec;
70 
72 class IRR_GUIRENDERER_API IrrlichtRenderer : public Renderer
73 {
74 public:
96  static IrrlichtRenderer& bootstrapSystem(irr::IrrlichtDevice& device,
97  const int abi = CEGUI_VERSION_ABI);
98 
115  static void destroySystem();
116 
118  static IrrlichtRenderer& create(irr::IrrlichtDevice& device,
119  const int abi = CEGUI_VERSION_ABI);
120 
122  static void destroy(IrrlichtRenderer& renderer);
123 
126  createIrrlichtResourceProvider(irr::io::IFileSystem& fs);
127 
129  static void destroyIrrlichtResourceProvider(IrrlichtResourceProvider& rp);
130 
132  static IrrlichtImageCodec& createIrrlichtImageCodec(
133  irr::video::IVideoDriver& driver);
134 
136  static void destroyIrrlichtImageCodec(IrrlichtImageCodec& ic);
137 
139  bool injectEvent(const irr::SEvent& event);
140 
151  Sizef getAdjustedTextureSize(const Sizef& sz) const;
152 
158  static float getNextPOTSize(const float f);
159 
160  // implement Renderer interface
161  RenderTarget& getDefaultRenderTarget();
162  GeometryBuffer& createGeometryBuffer();
163  void destroyGeometryBuffer(const GeometryBuffer& buffer);
164  void destroyAllGeometryBuffers();
165  TextureTarget* createTextureTarget();
166  void destroyTextureTarget(TextureTarget* target);
167  void destroyAllTextureTargets();
168  Texture& createTexture(const String& name);
169  Texture& createTexture(const String& name,
170  const String& filename,
171  const String& resourceGroup);
172  Texture& createTexture(const String& name, const Sizef& size);
173  void destroyTexture(Texture& texture);
174  void destroyTexture(const String& name);
175  void destroyAllTextures();
176  Texture& getTexture(const String& name) const;
177  bool isTextureDefined(const String& name) const;
178  void beginRendering();
179  void endRendering();
180  void setDisplaySize(const Sizef& sz);
181  const Sizef& getDisplaySize() const;
182  const Vector2f& getDisplayDPI() const;
183  uint getMaxTextureSize() const;
184  const String& getIdentifierString() const;
185  const IrrlichtEventPusher* getEventPusher() const;
186 
187 protected:
189  IrrlichtRenderer(irr::IrrlichtDevice& device);
191  ~IrrlichtRenderer();
192 
194  void throwIfNameExists(const String& name) const;
196  static void logTextureCreation(const String& name);
198  static void logTextureDestruction(const String& name);
199 
203  irr::IrrlichtDevice& d_device;
205  irr::video::IVideoDriver* d_driver;
213  typedef std::vector<TextureTarget*> TextureTargetList;
217  typedef std::vector<IrrlichtGeometryBuffer*> GeometryBufferList;
221  typedef std::map<String, IrrlichtTexture*, StringFastLessCompare
222  CEGUI_MAP_ALLOC(String, IrrlichtTexture*)> TextureMap;
233 };
234 
235 } // End of CEGUI namespace section
236 
237 #if defined(_MSC_VER)
238 # pragma warning(pop)
239 #endif
240 
241 #endif // end of guard _CEGUIIrrlichtRenderer_h_