Crazy Eddie's GUI System  0.8.7
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 
129 
132  irr::video::IVideoDriver& driver);
133 
136 
138  bool injectEvent(const irr::SEvent& event);
139 
151 
157  static float getNextPOTSize(const float f);
158 
174  bool isTexCoordSystemFlipped() const { return false; }
175 
176  // implement Renderer interface
184  Texture& createTexture(const String& name);
186  const String& filename,
187  const String& resourceGroup);
188  Texture& createTexture(const String& name, const Sizef& size);
189  void destroyTexture(Texture& texture);
190  void destroyTexture(const String& name);
192  Texture& getTexture(const String& name) const;
193  bool isTextureDefined(const String& name) const;
195  void endRendering();
196  void setDisplaySize(const Sizef& sz);
197  const Sizef& getDisplaySize() const;
198  const Vector2f& getDisplayDPI() const;
199  uint getMaxTextureSize() const;
200  const String& getIdentifierString() const;
201  const IrrlichtEventPusher* getEventPusher() const;
202 
203 protected:
205  IrrlichtRenderer(irr::IrrlichtDevice& device);
208 
210  void throwIfNameExists(const String& name) const;
212  static void logTextureCreation(const String& name);
214  static void logTextureDestruction(const String& name);
215 
219  irr::IrrlichtDevice& d_device;
221  irr::video::IVideoDriver* d_driver;
229  typedef std::vector<TextureTarget*> TextureTargetList;
233  typedef std::vector<IrrlichtGeometryBuffer*> GeometryBufferList;
237  typedef std::map<String, IrrlichtTexture*, StringFastLessCompare
238  CEGUI_MAP_ALLOC(String, IrrlichtTexture*)> TextureMap;
249 };
250 
251 } // End of CEGUI namespace section
252 
253 #if defined(_MSC_VER)
254 # pragma warning(pop)
255 #endif
256 
257 #endif // end of guard _CEGUIIrrlichtRenderer_h_
CEGUI::IrrlichtRenderer::destroyIrrlichtImageCodec
static void destroyIrrlichtImageCodec(IrrlichtImageCodec &ic)
function to destroy a CEGUI::IrrlichtImageCodec object.
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::IrrlichtRenderer::destroyAllTextureTargets
void destroyAllTextureTargets()
Destory all TextureTarget objects created by this Renderer.
CEGUI::IrrlichtRenderer::destroy
static void destroy(IrrlichtRenderer &renderer)
Function to destroy IrrlichtRenderer objects.
CEGUI::IrrlichtRenderer::d_textureTargets
TextureTargetList d_textureTargets
Container used to track texture targets.
Definition: RendererModules/Irrlicht/Renderer.h:231
CEGUI::IrrlichtRenderer::d_supportsNSquareTextures
bool d_supportsNSquareTextures
true if driver supports non square textures
Definition: RendererModules/Irrlicht/Renderer.h:246
CEGUI::IrrlichtRenderer::destroyGeometryBuffer
void destroyGeometryBuffer(const GeometryBuffer &buffer)
Destroy a GeometryBuffer that was returned when calling the createGeometryBuffer function....
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::IrrlichtEventPusher
Definition: EventPusher.h:38
CEGUI::IrrlichtRenderer::IrrlichtRenderer
IrrlichtRenderer(irr::IrrlichtDevice &device)
Constructor.
CEGUI::IrrlichtRenderer::d_maxTextureSize
uint d_maxTextureSize
What the renderer thinks the max texture size is.
Definition: RendererModules/Irrlicht/Renderer.h:242
CEGUI::IrrlichtRenderer::beginRendering
void beginRendering()
Perform any operations required to put the system into a state ready for rendering operations to begi...
CEGUI::IrrlichtRenderer::~IrrlichtRenderer
~IrrlichtRenderer()
Destructor.
CEGUI::IrrlichtRenderer::TextureTargetList
std::vector< TextureTarget * > TextureTargetList
container type used to hold TextureTargets we create.
Definition: RendererModules/Irrlicht/Renderer.h:229
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::IrrlichtRenderer::d_driver
irr::video::IVideoDriver * d_driver
Irrlicht video driver (as obtained from the device)
Definition: RendererModules/Irrlicht/Renderer.h:221
CEGUI::IrrlichtRenderer::createIrrlichtResourceProvider
static IrrlichtResourceProvider & createIrrlichtResourceProvider(irr::io::IFileSystem &fs)
Create a IrrlichtResourceProvider object.
CEGUI::IrrlichtRenderer::getTexture
Texture & getTexture(const String &name) const
Return a Texture object that was previously created by calling the createTexture functions.
CEGUI::Vector2< float >
CEGUI::IrrlichtRenderer::create
static IrrlichtRenderer & create(irr::IrrlichtDevice &device, const int abi=CEGUI_VERSION_ABI)
Function to create and return IrrlichtRenderer objects.
CEGUI::IrrlichtRenderer::destroyTextureTarget
void destroyTextureTarget(TextureTarget *target)
Function that cleans up TextureTarget objects created with the createTextureTarget function.
CEGUI::IrrlichtRenderer::d_displaySize
Sizef d_displaySize
What the renderer considers to be the current display size.
Definition: RendererModules/Irrlicht/Renderer.h:223
CEGUI::IrrlichtRenderer::getMaxTextureSize
uint getMaxTextureSize() const
Return the pixel size of the maximum supported texture.
CEGUI::IrrlichtRenderer::d_eventPusher
IrrlichtEventPusher * d_eventPusher
ptr to helper object that aids in injection of events from Irrlicht.
Definition: RendererModules/Irrlicht/Renderer.h:244
CEGUI::IrrlichtRenderer::bootstrapSystem
static IrrlichtRenderer & bootstrapSystem(irr::IrrlichtDevice &device, const int abi=CEGUI_VERSION_ABI)
Convenience function that creates all the Irrlicht specific objects and then initialises the CEGUI sy...
CEGUI::IrrlichtRenderer::d_displayDPI
Vector2f d_displayDPI
What the renderer considers to be the current display DPI resolution.
Definition: RendererModules/Irrlicht/Renderer.h:225
CEGUI::IrrlichtRenderer::destroyTexture
void destroyTexture(const String &name)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::IrrlichtRenderer::isTextureDefined
bool isTextureDefined(const String &name) const
Return whether a texture with the given name exists.
CEGUI::IrrlichtRenderer::d_supportsNPOTTextures
bool d_supportsNPOTTextures
true if driver supports non power of two textures
Definition: RendererModules/Irrlicht/Renderer.h:248
CEGUI::IrrlichtRenderer::getNextPOTSize
static float getNextPOTSize(const float f)
Utility function that will return f if it's a power of two, or the next power of two up from f if it'...
CEGUI::IrrlichtRenderer::d_device
irr::IrrlichtDevice & d_device
The IrrlichtDevide that we'll be using.
Definition: RendererModules/Irrlicht/Renderer.h:219
CEGUI::IrrlichtRenderer::isTexCoordSystemFlipped
bool isTexCoordSystemFlipped() const
Returns if the texture coordinate system is vertically flipped or not. The original of a texture coor...
Definition: RendererModules/Irrlicht/Renderer.h:174
CEGUI::IrrlichtRenderer::throwIfNameExists
void throwIfNameExists(const String &name) const
helper to throw exception if name is already used.
CEGUI::IrrlichtRenderer::createTexture
Texture & createTexture(const String &name, const String &filename, const String &resourceGroup)
Create a Texture object using the given image file.
CEGUI::IrrlichtRenderer::logTextureCreation
static void logTextureCreation(const String &name)
helper to safely log the creation of a named texture
CEGUI::IrrlichtRenderer::destroyIrrlichtResourceProvider
static void destroyIrrlichtResourceProvider(IrrlichtResourceProvider &rp)
Destroy a IrrlichtResourceProvider object.
CEGUI::IrrlichtResourceProvider
Definition: RendererModules/Irrlicht/ResourceProvider.h:40
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::IrrlichtRenderer::createTexture
Texture & createTexture(const String &name, const Sizef &size)
Create a Texture object with the given pixel dimensions as specified by size.
CEGUI::IrrlichtRenderer::logTextureDestruction
static void logTextureDestruction(const String &name)
helper to safely log the destruction of a named texture
CEGUI::IrrlichtRenderer::GeometryBufferList
std::vector< IrrlichtGeometryBuffer * > GeometryBufferList
container type used to hold GeometryBuffers we create.
Definition: RendererModules/Irrlicht/Renderer.h:233
CEGUI::IrrlichtRenderer::createGeometryBuffer
GeometryBuffer & createGeometryBuffer()
Create a new GeometryBuffer and return a reference to it. You should remove the GeometryBuffer from a...
CEGUI::IrrlichtRenderer::destroyAllTextures
void destroyAllTextures()
Destroy all Texture objects created by this Renderer.
CEGUI::IrrlichtRenderer::injectEvent
bool injectEvent(const irr::SEvent &event)
inject irrlicht event to CEGUI system
CEGUI::IrrlichtRenderer::d_geometryBuffers
GeometryBufferList d_geometryBuffers
Container used to track geometry buffers.
Definition: RendererModules/Irrlicht/Renderer.h:235
CEGUI::IrrlichtImageCodec
ImageCodec object that loads data via image loading facilities in Irrlicht.
Definition: RendererModules/Irrlicht/ImageCodec.h:47
CEGUI::IrrlichtRenderer::TextureMap
std::map< String, IrrlichtTexture *, StringFastLessCompare CEGUI_MAP_ALLOC(String, IrrlichtTexture *)> TextureMap
container type used to hold Textures we create.
Definition: RendererModules/Irrlicht/Renderer.h:238
CEGUI::IrrlichtRenderer::getDefaultRenderTarget
RenderTarget & getDefaultRenderTarget()
Returns the default RenderTarget object. The default render target is is typically one that targets t...
CEGUI::IrrlichtRenderer::setDisplaySize
void setDisplaySize(const Sizef &sz)
Set the size of the display or host window in pixels for this Renderer object.
CEGUI::RenderTarget
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:60
CEGUI::IrrlichtTexture
Implementation of the CEGUI::Texture class for the Irrlicht engine.
Definition: RendererModules/Irrlicht/Texture.h:50
CEGUI::IrrlichtRenderer::createTexture
Texture & createTexture(const String &name)
Create a 'null' Texture object.
CEGUI::Size< float >
CEGUI::IrrlichtRenderer::destroyAllGeometryBuffers
void destroyAllGeometryBuffers()
Destroy all GeometryBuffer objects created by this Renderer.
CEGUI::TextureTarget
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:41
CEGUI::IrrlichtRenderer::getIdentifierString
const String & getIdentifierString() const
Return identification string for the renderer module.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::IrrlichtRenderer::destroySystem
static void destroySystem()
Convenience function to cleanup the CEGUI system and related objects that were created by calling the...
CEGUI::IrrlichtRenderer::getDisplayDPI
const Vector2f & getDisplayDPI() const
Return the resolution of the display or host window in dots per inch.
CEGUI::IrrlichtRenderer::createIrrlichtImageCodec
static IrrlichtImageCodec & createIrrlichtImageCodec(irr::video::IVideoDriver &driver)
function to create a CEGUI::IrrlichtImageCodec object.
CEGUI::IrrlichtRenderer::d_textures
TextureMap d_textures
Container used to track textures.
Definition: RendererModules/Irrlicht/Renderer.h:240
CEGUI::IrrlichtRenderer::getAdjustedTextureSize
Sizef getAdjustedTextureSize(const Sizef &sz) const
Helper to return a valid texture size according to device capabilities.
CEGUI::IrrlichtRenderer::getDisplaySize
const Sizef & getDisplaySize() const
Return the size of the display or host window in pixels.
CEGUI::Renderer
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:84
CEGUI::IrrlichtRenderer
CEGUI::Renderer implementation for the Irrlicht engine.
Definition: RendererModules/Irrlicht/Renderer.h:72
CEGUI::IrrlichtRenderer::d_rendererID
static String d_rendererID
String holding the renderer identification text.
Definition: RendererModules/Irrlicht/Renderer.h:217
CEGUI::IrrlichtRenderer::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::IrrlichtRenderer::createTextureTarget
TextureTarget * createTextureTarget()
Create a TextureTarget that can be used to cache imagery; this is a RenderTarget that does not lose i...
CEGUI::IrrlichtRenderer::d_defaultTarget
RenderTarget * d_defaultTarget
The default RenderTarget.
Definition: RendererModules/Irrlicht/Renderer.h:227
CEGUI::IrrlichtRenderer::endRendering
void endRendering()
Perform any operations required to finalise rendering.