Crazy Eddie's GUI System  0.8.7
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 #if (CEGUI_OGRE_VERSION >= (2 << 16))
68 // The new Ogre Compositor2 system has to be used since ViewPorts
69 // no longer have the required functionality
70 #define CEGUI_USE_OGRE_COMPOSITOR2
71 #endif
72 
73 #if (CEGUI_OGRE_VERSION >= ((2 << 16) | (1 << 8) | 0))
74 // The HLMS has to be used since fixed pipeline is disabled
75 #define CEGUI_USE_OGRE_HLMS
76 #include <OgreRenderOperation.h>
77 #include <OgreHlmsSamplerblock.h>
78 #endif
79 
80 // Start of CEGUI namespace section
81 namespace CEGUI
82 {
83 class OgreGeometryBuffer;
84 class OgreTexture;
85 class OgreResourceProvider;
86 class OgreImageCodec;
87 class OgreWindowTarget;
88 struct OgreRenderer_impl;
89 
91 class OGRE_GUIRENDERER_API OgreRenderer : public Renderer
92 {
93 public:
94 #if !defined(CEGUI_USE_OGRE_COMPOSITOR2)
95 
120  static OgreRenderer& bootstrapSystem(const int abi = CEGUI_VERSION_ABI);
121 #endif
122 
146  static OgreRenderer& bootstrapSystem(Ogre::RenderTarget& target,
147  const int abi = CEGUI_VERSION_ABI);
148 
165  static void destroySystem();
166 
167 #if !defined(CEGUI_USE_OGRE_COMPOSITOR2)
168 
178  static OgreRenderer& create(const int abi = CEGUI_VERSION_ABI);
179 #endif
180 
186  static OgreRenderer& create(Ogre::RenderTarget& target,
187  const int abi = CEGUI_VERSION_ABI);
188 
190  static void destroy(OgreRenderer& renderer);
191 
193  static OgreResourceProvider& createOgreResourceProvider();
194 
196  static void destroyOgreResourceProvider(OgreResourceProvider& rp);
197 
199  static OgreImageCodec& createOgreImageCodec();
200 
202  static void destroyOgreImageCodec(OgreImageCodec& ic);
203 
205  void setRenderingEnabled(const bool enabled);
206 
208  bool isRenderingEnabled() const;
209 
227  Texture& createTexture(const String& name, Ogre::TexturePtr& tex,
228  bool take_ownership = false);
229 
231  void setupRenderingBlendMode(const BlendMode mode,
232  const bool force = false);
233 
251  void setFrameControlExecutionEnabled(const bool enabled);
252 
270  bool isFrameControlExecutionEnabled() const;
271 
280  void initialiseRenderStateSettings();
281 
291  void setDefaultRootRenderTarget(Ogre::RenderTarget& target);
292 
302  bool isUsingShaders() const;
303 
322  void setUsingShaders(const bool use_shaders);
323 
333  void bindShaders();
334 
342  void updateShaderParams() const;
343 
345  void setWorldMatrix(const Ogre::Matrix4& m);
347  void setViewMatrix(const Ogre::Matrix4& m);
349  void setProjectionMatrix(const Ogre::Matrix4& m);
351  const Ogre::Matrix4& getWorldMatrix() const;
353  const Ogre::Matrix4& getViewMatrix() const;
355  const Ogre::Matrix4& getProjectionMatrix() const;
356 
367  const Ogre::Matrix4& getWorldViewProjMatrix() const;
368 
384  bool isTexCoordSystemFlipped() const { return false; }
385 
386 #ifdef CEGUI_USE_OGRE_HLMS
387  Ogre::RenderTarget* getOgreRenderTarget();
388  const Ogre::HlmsSamplerblock* getHlmsSamplerblock();
389 #endif
390 
391  // implement CEGUI::Renderer interface
392  RenderTarget& getDefaultRenderTarget();
393  GeometryBuffer& createGeometryBuffer();
394  void destroyGeometryBuffer(const GeometryBuffer& buffer);
395  void destroyAllGeometryBuffers();
396  TextureTarget* createTextureTarget();
397  void destroyTextureTarget(TextureTarget* target);
398  void destroyAllTextureTargets();
399  Texture& createTexture(const String& name);
400  Texture& createTexture(const String& name,
401  const String& filename,
402  const String& resourceGroup);
403  Texture& createTexture(const String& name, const Sizef& size);
404  void destroyTexture(Texture& texture);
405  void destroyTexture(const String& name);
406  void destroyAllTextures();
407  Texture& getTexture(const String& name) const;
408  bool isTextureDefined(const String& name) const;
409  void beginRendering();
410  void endRendering();
411  void setDisplaySize(const Sizef& sz);
412  const Sizef& getDisplaySize() const;
413  const Vector2f& getDisplayDPI() const;
414  uint getMaxTextureSize() const;
415  const String& getIdentifierString() const;
416 
417 protected:
419  OgreRenderer();
421  OgreRenderer(Ogre::RenderTarget& target);
423  virtual ~OgreRenderer();
424 
426  void checkOgreInitialised();
428  void throwIfNameExists(const String& name) const;
430  static void logTextureCreation(const String& name);
432  static void logTextureDestruction(const String& name);
433 
435  void constructor_impl(Ogre::RenderTarget& target);
437  void initialiseShaders();
439  void cleanupShaders();
440 
442  OgreRenderer_impl* d_pimpl;
443 };
444 
445 
446 } // End of CEGUI namespace section
447 
448 #if defined(_MSC_VER)
449 # pragma warning(pop)
450 #endif
451 
452 #endif // end of guard _CEGUIOgreRenderer_h_
CEGUI::Renderer implementation for the Ogre engine.
Definition: RendererModules/Ogre/Renderer.h:91
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
ImageCodec object that loads data via image loading facilities in Ogre.
Definition: RendererModules/Ogre/ImageCodec.h:40
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:42
Definition: RendererModules/Ogre/ResourceProvider.h:38
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:40
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:52
bool isTexCoordSystemFlipped() const
Returns if the texture coordinate system is vertically flipped or not. The original of a texture coor...
Definition: RendererModules/Ogre/Renderer.h:384
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:82
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: Renderer.h:61
OgreRenderer_impl * d_pimpl
Pointer to the hidden implementation data.
Definition: RendererModules/Ogre/Renderer.h:442
Definition: RendererModules/Ogre/GeometryBuffer.h:48
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:57
String class used within the GUI system.
Definition: String.h:62