Crazy Eddies GUI System  0.7.2
CEGUIOgreRenderer.h
1 /***********************************************************************
2  filename: CEGUIOgreRenderer.h
3  created: Tue Feb 17 2009
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2010 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 _CEGUIOgreRenderer_h_
29 #define _CEGUIOgreRenderer_h_
30 
31 #include "../../CEGUIRenderer.h"
32 #include "../../CEGUISize.h"
33 #include "../../CEGUIVector.h"
34 
35 #include <OgreBlendMode.h>
36 #include <OgreTextureUnitState.h>
37 
38 #include <vector>
39 
40 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
41 # ifdef OGRE_GUIRENDERER_EXPORTS
42 # define OGRE_GUIRENDERER_API __declspec(dllexport)
43 # else
44 # define OGRE_GUIRENDERER_API __declspec(dllimport)
45 # endif
46 #else
47 # define OGRE_GUIRENDERER_API
48 #endif
49 
50 #if defined(_MSC_VER)
51 # pragma warning(push)
52 # pragma warning(disable : 4251)
53 #endif
54 
55 namespace Ogre
56 {
57 class Root;
58 class RenderSystem;
59 }
60 
61 // Start of CEGUI namespace section
62 namespace CEGUI
63 {
64 class OgreGeometryBuffer;
65 class OgreTexture;
66 class OgreResourceProvider;
67 class OgreImageCodec;
68 class OgreWindowTarget;
69 
71 class OGRE_GUIRENDERER_API OgreRenderer : public Renderer
72 {
73 public:
96  static OgreRenderer& bootstrapSystem();
97 
119  static OgreRenderer& bootstrapSystem(Ogre::RenderTarget& target);
120 
137  static void destroySystem();
138 
149  static OgreRenderer& create();
150 
156  static OgreRenderer& create(Ogre::RenderTarget& target);
157 
159  static void destroy(OgreRenderer& renderer);
160 
162  static OgreResourceProvider& createOgreResourceProvider();
163 
165  static void destroyOgreResourceProvider(OgreResourceProvider& rp);
166 
168  static OgreImageCodec& createOgreImageCodec();
169 
171  static void destroyOgreImageCodec(OgreImageCodec& ic);
172 
174  void setRenderingEnabled(const bool enabled);
175 
177  bool isRenderingEnabled() const;
178 
193  Texture& createTexture(Ogre::TexturePtr& tex, bool take_ownership = false);
194 
196  void setupRenderingBlendMode(const BlendMode mode,
197  const bool force = false);
198 
216  void setFrameControlExecutionEnabled(const bool enabled);
217 
235  bool isFrameControlExecutionEnabled() const;
236 
245  void initialiseRenderStateSettings();
246 
256  void setDefaultRootRenderTarget(Ogre::RenderTarget& target);
257 
258  // implement CEGUI::Renderer interface
259  RenderingRoot& getDefaultRenderingRoot();
260  GeometryBuffer& createGeometryBuffer();
261  void destroyGeometryBuffer(const GeometryBuffer& buffer);
262  void destroyAllGeometryBuffers();
263  TextureTarget* createTextureTarget();
264  void destroyTextureTarget(TextureTarget* target);
265  void destroyAllTextureTargets();
266  Texture& createTexture();
267  Texture& createTexture(const String& filename, const String& resourceGroup);
268  Texture& createTexture(const Size& size);
269  void destroyTexture(Texture& texture);
270  void destroyAllTextures();
271  void beginRendering();
272  void endRendering();
273  void setDisplaySize(const Size& sz);
274  const Size& getDisplaySize() const;
275  const Vector2& getDisplayDPI() const;
276  uint getMaxTextureSize() const;
277  const String& getIdentifierString() const;
278 
279 protected:
281  OgreRenderer();
283  OgreRenderer(Ogre::RenderTarget& target);
285  virtual ~OgreRenderer();
286 
288  void checkOgreInitialised();
289 
291  void constructor_impl(Ogre::RenderTarget& target);
292 
304  typedef std::vector<TextureTarget*> TextureTargetList;
308  typedef std::vector<OgreGeometryBuffer*> GeometryBufferList;
312  typedef std::vector<OgreTexture*> TextureList;
318  Ogre::Root* d_ogreRoot;
320  Ogre::RenderSystem* d_renderSystem;
325 };
326 
327 
328 } // End of CEGUI namespace section
329 
330 #if defined(_MSC_VER)
331 # pragma warning(pop)
332 #endif
333 
334 #endif // end of guard _CEGUIOgreRenderer_h_