Crazy Eddies GUI System  0.7.0
CEGUIOgreRenderer.h
1 /***********************************************************************
2  filename: CEGUIOgreRenderer.h
3  created: Tue Feb 17 2009
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2009 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 
70 class OGRE_GUIRENDERER_API OgreRenderer : public Renderer
71 {
72 public:
95  static OgreRenderer& bootstrapSystem();
96 
118  static OgreRenderer& bootstrapSystem(Ogre::RenderTarget& target);
119 
136  static void destroySystem();
137 
148  static OgreRenderer& create();
149 
155  static OgreRenderer& create(Ogre::RenderTarget& target);
156 
158  static void destroy(OgreRenderer& renderer);
159 
161  static OgreResourceProvider& createOgreResourceProvider();
162 
164  static void destroyOgreResourceProvider(OgreResourceProvider& rp);
165 
167  static OgreImageCodec& createOgreImageCodec();
168 
170  static void destroyOgreImageCodec(OgreImageCodec& ic);
171 
173  void setRenderingEnabled(const bool enabled);
174 
176  bool isRenderingEnabled() const;
177 
192  Texture& createTexture(Ogre::TexturePtr& tex, bool take_ownership = false);
193 
194  // implement CEGUI::Renderer interface
195  RenderingRoot& getDefaultRenderingRoot();
196  GeometryBuffer& createGeometryBuffer();
197  void destroyGeometryBuffer(const GeometryBuffer& buffer);
198  void destroyAllGeometryBuffers();
199  TextureTarget* createTextureTarget();
200  void destroyTextureTarget(TextureTarget* target);
201  void destroyAllTextureTargets();
202  Texture& createTexture();
203  Texture& createTexture(const String& filename, const String& resourceGroup);
204  Texture& createTexture(const Size& size);
205  void destroyTexture(Texture& texture);
206  void destroyAllTextures();
207  void beginRendering();
208  void endRendering();
209  void setDisplaySize(const Size& sz);
210  const Size& getDisplaySize() const;
211  const Vector2& getDisplayDPI() const;
212  uint getMaxTextureSize() const;
213  const String& getIdentifierString() const;
214 
215 protected:
217  OgreRenderer();
219  OgreRenderer(Ogre::RenderTarget& target);
221  virtual ~OgreRenderer();
222 
224  void checkOgreInitialised();
225 
227  void constructor_impl(Ogre::RenderTarget& target);
228 
240  typedef std::vector<TextureTarget*> TextureTargetList;
244  typedef std::vector<OgreGeometryBuffer*> GeometryBufferList;
248  typedef std::vector<OgreTexture*> TextureList;
254  Ogre::Root* d_ogreRoot;
256  Ogre::RenderSystem* d_renderSystem;
257 };
258 
259 
260 } // End of CEGUI namespace section
261 
262 #if defined(_MSC_VER)
263 # pragma warning(pop)
264 #endif
265 
266 #endif // end of guard _CEGUIOgreRenderer_h_