Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Irrlicht/Renderer.h
1 /***********************************************************************
2  created: Tue Mar 3 2009
3  author: Paul D Turner (parts based on original code by Thomas Suter)
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 _CEGUIIrrlichtRenderer_h_
28 #define _CEGUIIrrlichtRenderer_h_
29 
30 #include "CEGUI/RendererModules/Irrlicht/RendererDef.h"
31 #include "../../Renderer.h"
32 #include "../../Size.h"
33 #include "../../Vector.h"
34 
35 #include <vector>
36 #include <map>
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 // forward reference irrlicht classes
44 namespace irr
45 {
46 class IrrlichtDevice;
47 struct SEvent;
48 
49 namespace video
50 {
51 class IVideoDriver;
52 }
53 
54 namespace io
55 {
56 class IFileSystem;
57 }
58 
59 }
60 
61 // Start of CEGUI namespace section
62 namespace CEGUI
63 {
64 class IrrlichtTexture;
65 class IrrlichtGeometryBuffer;
66 class IrrlichtResourceProvider;
67 class IrrlichtEventPusher;
68 class IrrlichtImageCodec;
69 
71 class IRR_GUIRENDERER_API IrrlichtRenderer : public Renderer
72 {
73 public:
95  static IrrlichtRenderer& bootstrapSystem(irr::IrrlichtDevice& device,
96  const int abi = CEGUI_VERSION_ABI);
97 
114  static void destroySystem();
115 
117  static IrrlichtRenderer& create(irr::IrrlichtDevice& device,
118  const int abi = CEGUI_VERSION_ABI);
119 
121  static void destroy(IrrlichtRenderer& renderer);
122 
125  createIrrlichtResourceProvider(irr::io::IFileSystem& fs);
126 
128  static void destroyIrrlichtResourceProvider(IrrlichtResourceProvider& rp);
129 
131  static IrrlichtImageCodec& createIrrlichtImageCodec(
132  irr::video::IVideoDriver& driver);
133 
135  static void destroyIrrlichtImageCodec(IrrlichtImageCodec& ic);
136 
138  bool injectEvent(const irr::SEvent& event);
139 
150  Sizef getAdjustedTextureSize(const Sizef& sz) const;
151 
157  static float getNextPOTSize(const float f);
158 
159  // implement Renderer interface
160  RenderTarget& getDefaultRenderTarget();
161  GeometryBuffer& createGeometryBuffer();
162  void destroyGeometryBuffer(const GeometryBuffer& buffer);
163  void destroyAllGeometryBuffers();
164  TextureTarget* createTextureTarget();
165  void destroyTextureTarget(TextureTarget* target);
166  void destroyAllTextureTargets();
167  Texture& createTexture(const String& name);
168  Texture& createTexture(const String& name,
169  const String& filename,
170  const String& resourceGroup);
171  Texture& createTexture(const String& name, const Sizef& size);
172  void destroyTexture(Texture& texture);
173  void destroyTexture(const String& name);
174  void destroyAllTextures();
175  Texture& getTexture(const String& name) const;
176  bool isTextureDefined(const String& name) const;
177  void beginRendering();
178  void endRendering();
179  void setDisplaySize(const Sizef& sz);
180  const Sizef& getDisplaySize() const;
181  const Vector2f& getDisplayDPI() const;
182  uint getMaxTextureSize() const;
183  const String& getIdentifierString() const;
184  const IrrlichtEventPusher* getEventPusher() const;
185 
186 protected:
188  IrrlichtRenderer(irr::IrrlichtDevice& device);
190  ~IrrlichtRenderer();
191 
193  void throwIfNameExists(const String& name) const;
195  static void logTextureCreation(const String& name);
197  static void logTextureDestruction(const String& name);
198 
202  irr::IrrlichtDevice& d_device;
204  irr::video::IVideoDriver* d_driver;
212  typedef std::vector<TextureTarget*> TextureTargetList;
216  typedef std::vector<IrrlichtGeometryBuffer*> GeometryBufferList;
220  typedef std::map<String, IrrlichtTexture*, StringFastLessCompare
221  CEGUI_MAP_ALLOC(String, IrrlichtTexture*)> TextureMap;
232 };
233 
234 } // End of CEGUI namespace section
235 
236 #if defined(_MSC_VER)
237 # pragma warning(pop)
238 #endif
239 
240 #endif // end of guard _CEGUIIrrlichtRenderer_h_
Vector2f d_displayDPI
What the renderer considers to be the current display DPI resolution.
Definition: RendererModules/Irrlicht/Renderer.h:208
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5579
std::map< String, IrrlichtTexture *, StringFastLessCompare CEGUI_MAP_ALLOC(String, IrrlichtTexture *)> TextureMap
container type used to hold Textures we create.
Definition: RendererModules/Irrlicht/Renderer.h:221
TextureTargetList d_textureTargets
Container used to track texture targets.
Definition: RendererModules/Irrlicht/Renderer.h:214
Definition: EventPusher.h:37
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:42
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:40
bool d_supportsNSquareTextures
true if driver supports non square textures
Definition: RendererModules/Irrlicht/Renderer.h:229
Implementation of the CEGUI::Texture class for the Irrlicht engine.
Definition: RendererModules/Irrlicht/Texture.h:49
irr::IrrlichtDevice & d_device
The IrrlichtDevide that we'll be using.
Definition: RendererModules/Irrlicht/Renderer.h:202
std::vector< IrrlichtGeometryBuffer * > GeometryBufferList
container type used to hold GeometryBuffers we create.
Definition: RendererModules/Irrlicht/Renderer.h:216
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:52
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:82
Sizef d_displaySize
What the renderer considers to be the current display size.
Definition: RendererModules/Irrlicht/Renderer.h:206
Definition: RendererModules/Irrlicht/ResourceProvider.h:39
std::vector< TextureTarget * > TextureTargetList
container type used to hold TextureTargets we create.
Definition: RendererModules/Irrlicht/Renderer.h:212
CEGUI::Renderer implementation for the Irrlicht engine.
Definition: RendererModules/Irrlicht/Renderer.h:71
uint d_maxTextureSize
What the renderer thinks the max texture size is.
Definition: RendererModules/Irrlicht/Renderer.h:225
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:57
GeometryBufferList d_geometryBuffers
Container used to track geometry buffers.
Definition: RendererModules/Irrlicht/Renderer.h:218
ImageCodec object that loads data via image loading facilities in Irrlicht.
Definition: RendererModules/Irrlicht/ImageCodec.h:46
static String d_rendererID
String holding the renderer identification text.
Definition: RendererModules/Irrlicht/Renderer.h:200
IrrlichtEventPusher * d_eventPusher
ptr to helper object that aids in injection of events from Irrlicht.
Definition: RendererModules/Irrlicht/Renderer.h:227
RenderTarget * d_defaultTarget
The default RenderTarget.
Definition: RendererModules/Irrlicht/Renderer.h:210
bool d_supportsNPOTTextures
true if driver supports non power of two textures
Definition: RendererModules/Irrlicht/Renderer.h:231
irr::video::IVideoDriver * d_driver
Irrlicht video driver (as obtained from the device)
Definition: RendererModules/Irrlicht/Renderer.h:204
TextureMap d_textures
Container used to track textures.
Definition: RendererModules/Irrlicht/Renderer.h:223
String class used within the GUI system.
Definition: String.h:62