Crazy Eddie's GUI System  0.8.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererModules/Ogre/Renderer.h
1 /***********************************************************************
2  filename: CEGUIOgreRenderer.h
3  created: Tue Feb 17 2009
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2013 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 "../../Renderer.h"
32 #include "../../Size.h"
33 #include "../../Vector.h"
34 #include "CEGUI/Config.h"
35 
36 #include <vector>
37 
38 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
39 # ifdef CEGUIOGRERENDERER_EXPORTS
40 # define OGRE_GUIRENDERER_API __declspec(dllexport)
41 # else
42 # define OGRE_GUIRENDERER_API __declspec(dllimport)
43 # endif
44 #else
45 # define OGRE_GUIRENDERER_API
46 #endif
47 
48 #if defined(_MSC_VER)
49 # pragma warning(push)
50 # pragma warning(disable : 4251)
51 #endif
52 
53 namespace Ogre
54 {
55 class Root;
56 class RenderSystem;
57 class RenderTarget;
58 #if (CEGUI_OGRE_VERSION < ((1 << 16) | (9 << 8) | 0))
59 class TexturePtr;
60 #else
61 template<typename T> class SharedPtr;
62 class Texture;
63 typedef SharedPtr<Texture> TexturePtr;
64 #endif
65 class Matrix4;
66 }
67 
68 // Start of CEGUI namespace section
69 namespace CEGUI
70 {
71 class OgreGeometryBuffer;
72 class OgreTexture;
73 class OgreResourceProvider;
74 class OgreImageCodec;
75 class OgreWindowTarget;
76 struct OgreRenderer_impl;
77 
79 class OGRE_GUIRENDERER_API OgreRenderer : public Renderer
80 {
81 public:
107  static OgreRenderer& bootstrapSystem(const int abi = CEGUI_VERSION_ABI);
108 
133  static OgreRenderer& bootstrapSystem(Ogre::RenderTarget& target,
134  const int abi = CEGUI_VERSION_ABI);
135 
152  static void destroySystem();
153 
164  static OgreRenderer& create(const int abi = CEGUI_VERSION_ABI);
165 
171  static OgreRenderer& create(Ogre::RenderTarget& target,
172  const int abi = CEGUI_VERSION_ABI);
173 
175  static void destroy(OgreRenderer& renderer);
176 
178  static OgreResourceProvider& createOgreResourceProvider();
179 
181  static void destroyOgreResourceProvider(OgreResourceProvider& rp);
182 
184  static OgreImageCodec& createOgreImageCodec();
185 
187  static void destroyOgreImageCodec(OgreImageCodec& ic);
188 
190  void setRenderingEnabled(const bool enabled);
191 
193  bool isRenderingEnabled() const;
194 
212  Texture& createTexture(const String& name, Ogre::TexturePtr& tex,
213  bool take_ownership = false);
214 
216  void setupRenderingBlendMode(const BlendMode mode,
217  const bool force = false);
218 
236  void setFrameControlExecutionEnabled(const bool enabled);
237 
255  bool isFrameControlExecutionEnabled() const;
256 
265  void initialiseRenderStateSettings();
266 
276  void setDefaultRootRenderTarget(Ogre::RenderTarget& target);
277 
287  bool isUsingShaders() const;
288 
307  void setUsingShaders(const bool use_shaders);
308 
318  void bindShaders();
319 
327  void updateShaderParams() const;
328 
330  void setWorldMatrix(const Ogre::Matrix4& m);
332  void setViewMatrix(const Ogre::Matrix4& m);
334  void setProjectionMatrix(const Ogre::Matrix4& m);
336  const Ogre::Matrix4& getWorldMatrix() const;
338  const Ogre::Matrix4& getViewMatrix() const;
340  const Ogre::Matrix4& getProjectionMatrix() const;
341 
352  const Ogre::Matrix4& getWorldViewProjMatrix() const;
353 
354  // implement CEGUI::Renderer interface
355  RenderTarget& getDefaultRenderTarget();
356  GeometryBuffer& createGeometryBuffer();
357  void destroyGeometryBuffer(const GeometryBuffer& buffer);
358  void destroyAllGeometryBuffers();
359  TextureTarget* createTextureTarget();
360  void destroyTextureTarget(TextureTarget* target);
361  void destroyAllTextureTargets();
362  Texture& createTexture(const String& name);
363  Texture& createTexture(const String& name,
364  const String& filename,
365  const String& resourceGroup);
366  Texture& createTexture(const String& name, const Sizef& size);
367  void destroyTexture(Texture& texture);
368  void destroyTexture(const String& name);
369  void destroyAllTextures();
370  Texture& getTexture(const String& name) const;
371  bool isTextureDefined(const String& name) const;
372  void beginRendering();
373  void endRendering();
374  void setDisplaySize(const Sizef& sz);
375  const Sizef& getDisplaySize() const;
376  const Vector2f& getDisplayDPI() const;
377  uint getMaxTextureSize() const;
378  const String& getIdentifierString() const;
379 
380 protected:
382  OgreRenderer();
384  OgreRenderer(Ogre::RenderTarget& target);
386  virtual ~OgreRenderer();
387 
389  void checkOgreInitialised();
391  void throwIfNameExists(const String& name) const;
393  static void logTextureCreation(const String& name);
395  static void logTextureDestruction(const String& name);
396 
398  void constructor_impl(Ogre::RenderTarget& target);
400  void initialiseShaders();
402  void cleanupShaders();
403 
405  OgreRenderer_impl* d_pimpl;
406 };
407 
408 
409 } // End of CEGUI namespace section
410 
411 #if defined(_MSC_VER)
412 # pragma warning(pop)
413 #endif
414 
415 #endif // end of guard _CEGUIOgreRenderer_h_