Crazy Eddie's GUI System  0.8.1
 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 
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 class TexturePtr;
58 class Matrix4;
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 struct OgreRenderer_impl;
70 
72 class OGRE_GUIRENDERER_API OgreRenderer : public Renderer
73 {
74 public:
100  static OgreRenderer& bootstrapSystem(const int abi = CEGUI_VERSION_ABI);
101 
126  static OgreRenderer& bootstrapSystem(Ogre::RenderTarget& target,
127  const int abi = CEGUI_VERSION_ABI);
128 
145  static void destroySystem();
146 
157  static OgreRenderer& create(const int abi = CEGUI_VERSION_ABI);
158 
164  static OgreRenderer& create(Ogre::RenderTarget& target,
165  const int abi = CEGUI_VERSION_ABI);
166 
168  static void destroy(OgreRenderer& renderer);
169 
171  static OgreResourceProvider& createOgreResourceProvider();
172 
174  static void destroyOgreResourceProvider(OgreResourceProvider& rp);
175 
177  static OgreImageCodec& createOgreImageCodec();
178 
180  static void destroyOgreImageCodec(OgreImageCodec& ic);
181 
183  void setRenderingEnabled(const bool enabled);
184 
186  bool isRenderingEnabled() const;
187 
205  Texture& createTexture(const String& name, Ogre::TexturePtr& tex,
206  bool take_ownership = false);
207 
209  void setupRenderingBlendMode(const BlendMode mode,
210  const bool force = false);
211 
229  void setFrameControlExecutionEnabled(const bool enabled);
230 
248  bool isFrameControlExecutionEnabled() const;
249 
258  void initialiseRenderStateSettings();
259 
269  void setDefaultRootRenderTarget(Ogre::RenderTarget& target);
270 
280  bool isUsingShaders() const;
281 
300  void setUsingShaders(const bool use_shaders);
301 
311  void bindShaders();
312 
320  void updateShaderParams() const;
321 
323  void setWorldMatrix(const Ogre::Matrix4& m);
325  void setViewMatrix(const Ogre::Matrix4& m);
327  void setProjectionMatrix(const Ogre::Matrix4& m);
329  const Ogre::Matrix4& getWorldMatrix() const;
331  const Ogre::Matrix4& getViewMatrix() const;
333  const Ogre::Matrix4& getProjectionMatrix() const;
334 
345  const Ogre::Matrix4& getWorldViewProjMatrix() const;
346 
347  // implement CEGUI::Renderer interface
348  RenderTarget& getDefaultRenderTarget();
349  GeometryBuffer& createGeometryBuffer();
350  void destroyGeometryBuffer(const GeometryBuffer& buffer);
351  void destroyAllGeometryBuffers();
352  TextureTarget* createTextureTarget();
353  void destroyTextureTarget(TextureTarget* target);
354  void destroyAllTextureTargets();
355  Texture& createTexture(const String& name);
356  Texture& createTexture(const String& name,
357  const String& filename,
358  const String& resourceGroup);
359  Texture& createTexture(const String& name, const Sizef& size);
360  void destroyTexture(Texture& texture);
361  void destroyTexture(const String& name);
362  void destroyAllTextures();
363  Texture& getTexture(const String& name) const;
364  bool isTextureDefined(const String& name) const;
365  void beginRendering();
366  void endRendering();
367  void setDisplaySize(const Sizef& sz);
368  const Sizef& getDisplaySize() const;
369  const Vector2f& getDisplayDPI() const;
370  uint getMaxTextureSize() const;
371  const String& getIdentifierString() const;
372 
373 protected:
375  OgreRenderer();
377  OgreRenderer(Ogre::RenderTarget& target);
379  virtual ~OgreRenderer();
380 
382  void checkOgreInitialised();
384  void throwIfNameExists(const String& name) const;
386  static void logTextureCreation(const String& name);
388  static void logTextureDestruction(const String& name);
389 
391  void constructor_impl(Ogre::RenderTarget& target);
393  void initialiseShaders();
395  void cleanupShaders();
396 
398  OgreRenderer_impl* d_pimpl;
399 };
400 
401 
402 } // End of CEGUI namespace section
403 
404 #if defined(_MSC_VER)
405 # pragma warning(pop)
406 #endif
407 
408 #endif // end of guard _CEGUIOgreRenderer_h_