Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Ogre/Renderer.h
1 /***********************************************************************
2  created: Tue Feb 17 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2013 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 _CEGUIOgreRenderer_h_
28 #define _CEGUIOgreRenderer_h_
29 
30 #include "../../Renderer.h"
31 #include "../../Size.h"
32 #include "../../Vector.h"
33 #include "CEGUI/Config.h"
34 
35 #include <vector>
36 
37 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
38 # ifdef CEGUIOGRERENDERER_EXPORTS
39 # define OGRE_GUIRENDERER_API __declspec(dllexport)
40 # else
41 # define OGRE_GUIRENDERER_API __declspec(dllimport)
42 # endif
43 #else
44 # define OGRE_GUIRENDERER_API
45 #endif
46 
47 #if defined(_MSC_VER)
48 # pragma warning(push)
49 # pragma warning(disable : 4251)
50 #endif
51 
52 namespace Ogre
53 {
54 class Root;
55 class RenderSystem;
56 class RenderTarget;
57 #if (CEGUI_OGRE_VERSION < ((1 << 16) | (9 << 8) | 0))
58 class TexturePtr;
59 #else
60 template<typename T> class SharedPtr;
61 class Texture;
62 typedef SharedPtr<Texture> TexturePtr;
63 #endif
64 class Matrix4;
65 }
66 
67 // Start of CEGUI namespace section
68 namespace CEGUI
69 {
70 class OgreGeometryBuffer;
71 class OgreTexture;
72 class OgreResourceProvider;
73 class OgreImageCodec;
74 class OgreWindowTarget;
75 struct OgreRenderer_impl;
76 
78 class OGRE_GUIRENDERER_API OgreRenderer : public Renderer
79 {
80 public:
106  static OgreRenderer& bootstrapSystem(const int abi = CEGUI_VERSION_ABI);
107 
132  static OgreRenderer& bootstrapSystem(Ogre::RenderTarget& target,
133  const int abi = CEGUI_VERSION_ABI);
134 
151  static void destroySystem();
152 
163  static OgreRenderer& create(const int abi = CEGUI_VERSION_ABI);
164 
170  static OgreRenderer& create(Ogre::RenderTarget& target,
171  const int abi = CEGUI_VERSION_ABI);
172 
174  static void destroy(OgreRenderer& renderer);
175 
177  static OgreResourceProvider& createOgreResourceProvider();
178 
180  static void destroyOgreResourceProvider(OgreResourceProvider& rp);
181 
183  static OgreImageCodec& createOgreImageCodec();
184 
186  static void destroyOgreImageCodec(OgreImageCodec& ic);
187 
189  void setRenderingEnabled(const bool enabled);
190 
192  bool isRenderingEnabled() const;
193 
211  Texture& createTexture(const String& name, Ogre::TexturePtr& tex,
212  bool take_ownership = false);
213 
215  void setupRenderingBlendMode(const BlendMode mode,
216  const bool force = false);
217 
235  void setFrameControlExecutionEnabled(const bool enabled);
236 
254  bool isFrameControlExecutionEnabled() const;
255 
264  void initialiseRenderStateSettings();
265 
275  void setDefaultRootRenderTarget(Ogre::RenderTarget& target);
276 
286  bool isUsingShaders() const;
287 
306  void setUsingShaders(const bool use_shaders);
307 
317  void bindShaders();
318 
326  void updateShaderParams() const;
327 
329  void setWorldMatrix(const Ogre::Matrix4& m);
331  void setViewMatrix(const Ogre::Matrix4& m);
333  void setProjectionMatrix(const Ogre::Matrix4& m);
335  const Ogre::Matrix4& getWorldMatrix() const;
337  const Ogre::Matrix4& getViewMatrix() const;
339  const Ogre::Matrix4& getProjectionMatrix() const;
340 
351  const Ogre::Matrix4& getWorldViewProjMatrix() const;
352 
353  // implement CEGUI::Renderer interface
354  RenderTarget& getDefaultRenderTarget();
355  GeometryBuffer& createGeometryBuffer();
356  void destroyGeometryBuffer(const GeometryBuffer& buffer);
357  void destroyAllGeometryBuffers();
358  TextureTarget* createTextureTarget();
359  void destroyTextureTarget(TextureTarget* target);
360  void destroyAllTextureTargets();
361  Texture& createTexture(const String& name);
362  Texture& createTexture(const String& name,
363  const String& filename,
364  const String& resourceGroup);
365  Texture& createTexture(const String& name, const Sizef& size);
366  void destroyTexture(Texture& texture);
367  void destroyTexture(const String& name);
368  void destroyAllTextures();
369  Texture& getTexture(const String& name) const;
370  bool isTextureDefined(const String& name) const;
371  void beginRendering();
372  void endRendering();
373  void setDisplaySize(const Sizef& sz);
374  const Sizef& getDisplaySize() const;
375  const Vector2f& getDisplayDPI() const;
376  uint getMaxTextureSize() const;
377  const String& getIdentifierString() const;
378 
379 protected:
381  OgreRenderer();
383  OgreRenderer(Ogre::RenderTarget& target);
385  virtual ~OgreRenderer();
386 
388  void checkOgreInitialised();
390  void throwIfNameExists(const String& name) const;
392  static void logTextureCreation(const String& name);
394  static void logTextureDestruction(const String& name);
395 
397  void constructor_impl(Ogre::RenderTarget& target);
399  void initialiseShaders();
401  void cleanupShaders();
402 
404  OgreRenderer_impl* d_pimpl;
405 };
406 
407 
408 } // End of CEGUI namespace section
409 
410 #if defined(_MSC_VER)
411 # pragma warning(pop)
412 #endif
413 
414 #endif // end of guard _CEGUIOgreRenderer_h_