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 
194 
197 
200 
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 
232  const bool force = false);
233 
251  void setFrameControlExecutionEnabled(const bool enabled);
252 
271 
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
399  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);
407  Texture& getTexture(const String& name) const;
408  bool isTextureDefined(const String& name) const;
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:
421  OgreRenderer(Ogre::RenderTarget& target);
423  virtual ~OgreRenderer();
424 
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);
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::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::OgreRenderer::setWorldMatrix
void setWorldMatrix(const Ogre::Matrix4 &m)
Set the current world matrix to the given matrix.
CEGUI::OgreRenderer::OgreRenderer
OgreRenderer()
default constructor.
CEGUI::OgreRenderer::createTextureTarget
TextureTarget * createTextureTarget()
Create a TextureTarget that can be used to cache imagery; this is a RenderTarget that does not lose i...
CEGUI::OgreRenderer::logTextureDestruction
static void logTextureDestruction(const String &name)
helper to safely log the destruction of a named texture
CEGUI::OgreRenderer::destroyOgreImageCodec
static void destroyOgreImageCodec(OgreImageCodec &ic)
function to destroy a CEGUI::OgreImageCodec object.
CEGUI::OgreRenderer::bootstrapSystem
static OgreRenderer & bootstrapSystem(const int abi=CEGUI_VERSION_ABI)
Convenience function that creates all the Ogre specific objects and then initialises the CEGUI system...
CEGUI::OgreRenderer::getMaxTextureSize
uint getMaxTextureSize() const
Return the pixel size of the maximum supported texture.
CEGUI::OgreRenderer::destroyTextureTarget
void destroyTextureTarget(TextureTarget *target)
Function that cleans up TextureTarget objects created with the createTextureTarget function.
CEGUI::OgreResourceProvider
Definition: RendererModules/Ogre/ResourceProvider.h:39
CEGUI::OgreRenderer
CEGUI::Renderer implementation for the Ogre engine.
Definition: RendererModules/Ogre/Renderer.h:92
CEGUI::OgreRenderer::destroyAllGeometryBuffers
void destroyAllGeometryBuffers()
Destroy all GeometryBuffer objects created by this Renderer.
CEGUI::OgreRenderer::beginRendering
void beginRendering()
Perform any operations required to put the system into a state ready for rendering operations to begi...
CEGUI::OgreRenderer::getWorldMatrix
const Ogre::Matrix4 & getWorldMatrix() const
return a const reference to the current world matrix.
CEGUI::OgreRenderer::initialiseShaders
void initialiseShaders()
helper that creates and sets up shaders
CEGUI::OgreRenderer::create
static OgreRenderer & create(Ogre::RenderTarget &target, const int abi=CEGUI_VERSION_ABI)
Create an OgreRenderer object that uses the specified Ogre::RenderTarget as the default output surfac...
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::OgreRenderer::checkOgreInitialised
void checkOgreInitialised()
checks Ogre initialisation. throws exceptions if an issue is detected.
CEGUI::OgreRenderer::updateShaderParams
void updateShaderParams() const
Updates the shader constant parameters (i.e. uniforms).
CEGUI::OgreRenderer::isTexCoordSystemFlipped
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
CEGUI::OgreRenderer::createTexture
Texture & createTexture(const String &name, Ogre::TexturePtr &tex, bool take_ownership=false)
Create a CEGUI::Texture that wraps an existing Ogre texture.
CEGUI::Vector2< float >
CEGUI::OgreRenderer::setDefaultRootRenderTarget
void setDefaultRootRenderTarget(Ogre::RenderTarget &target)
Sets the Ogre::RenderTarget that should be targetted by the default GUIContext.
CEGUI::OgreRenderer::d_pimpl
OgreRenderer_impl * d_pimpl
Pointer to the hidden implementation data.
Definition: RendererModules/Ogre/Renderer.h:442
CEGUI::OgreRenderer::logTextureCreation
static void logTextureCreation(const String &name)
helper to safely log the creation of a named texture
CEGUI::OgreRenderer::isUsingShaders
bool isUsingShaders() const
Returns whether the OgreRenderer is currently set to use shaders when doing its rendering operations.
CEGUI::OgreRenderer::getWorldViewProjMatrix
const Ogre::Matrix4 & getWorldViewProjMatrix() const
Return a const reference to the final transformation matrix that should be used when transforming geo...
CEGUI::OgreRenderer::destroyGeometryBuffer
void destroyGeometryBuffer(const GeometryBuffer &buffer)
Destroy a GeometryBuffer that was returned when calling the createGeometryBuffer function....
CEGUI::OgreRenderer::destroySystem
static void destroySystem()
Convenience function to cleanup the CEGUI system and related objects that were created by calling the...
CEGUI::OgreRenderer::setViewMatrix
void setViewMatrix(const Ogre::Matrix4 &m)
Set the current view matrix to the given matrix.
CEGUI::OgreRenderer::createTexture
Texture & createTexture(const String &name, const Sizef &size)
Create a Texture object with the given pixel dimensions as specified by size.
CEGUI::OgreRenderer::create
static OgreRenderer & create(const int abi=CEGUI_VERSION_ABI)
Create an OgreRenderer object that uses the default Ogre rendering window as the default output surfa...
CEGUI::OgreRenderer::getIdentifierString
const String & getIdentifierString() const
Return identification string for the renderer module.
CEGUI::OgreRenderer::setProjectionMatrix
void setProjectionMatrix(const Ogre::Matrix4 &m)
Set the current projection matrix to the given matrix.
CEGUI::OgreRenderer::~OgreRenderer
virtual ~OgreRenderer()
destructor.
CEGUI::OgreRenderer::getDisplayDPI
const Vector2f & getDisplayDPI() const
Return the resolution of the display or host window in dots per inch.
CEGUI::OgreRenderer::createTexture
Texture & createTexture(const String &name)
Create a 'null' Texture object.
CEGUI::OgreRenderer::initialiseRenderStateSettings
void initialiseRenderStateSettings()
Sets all the required render states needed for CEGUI rendering.
CEGUI::OgreRenderer::bootstrapSystem
static OgreRenderer & bootstrapSystem(Ogre::RenderTarget &target, const int abi=CEGUI_VERSION_ABI)
Convenience function that creates all the Ogre specific objects and then initialises the CEGUI system...
CEGUI::OgreRenderer::getProjectionMatrix
const Ogre::Matrix4 & getProjectionMatrix() const
return a const reference to the current projection matrix.
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::OgreRenderer::cleanupShaders
void cleanupShaders()
helper to clean up shaders
CEGUI::OgreRenderer::isRenderingEnabled
bool isRenderingEnabled() const
return whether CEGUI rendering is enabled.
CEGUI::OgreRenderer::throwIfNameExists
void throwIfNameExists(const String &name) const
helper to throw exception if name is already used.
CEGUI::OgreRenderer::constructor_impl
void constructor_impl(Ogre::RenderTarget &target)
common parts of constructor
CEGUI::OgreRenderer::createOgreImageCodec
static OgreImageCodec & createOgreImageCodec()
function to create a CEGUI::OgreImageCodec object.
CEGUI::OgreRenderer::createTexture
Texture & createTexture(const String &name, const String &filename, const String &resourceGroup)
Create a Texture object using the given image file.
CEGUI::OgreRenderer::destroyOgreResourceProvider
static void destroyOgreResourceProvider(OgreResourceProvider &rp)
function to destroy a CEGUI::OgreResourceProvider object
CEGUI::BlendMode
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: Renderer.h:62
CEGUI::OgreRenderer::getDisplaySize
const Sizef & getDisplaySize() const
Return the size of the display or host window in pixels.
CEGUI::OgreRenderer::createOgreResourceProvider
static OgreResourceProvider & createOgreResourceProvider()
function to create a CEGUI::OgreResourceProvider object
CEGUI::OgreRenderer::destroy
static void destroy(OgreRenderer &renderer)
destory an OgreRenderer object.
CEGUI::OgreRenderer::getViewMatrix
const Ogre::Matrix4 & getViewMatrix() const
return a const reference to the current view matrix.
CEGUI::OgreRenderer::isTextureDefined
bool isTextureDefined(const String &name) const
Return whether a texture with the given name exists.
CEGUI::OgreRenderer::OgreRenderer
OgreRenderer(Ogre::RenderTarget &target)
constructor takin the Ogre::RenderTarget to use as the default root.
CEGUI::OgreRenderer::isFrameControlExecutionEnabled
bool isFrameControlExecutionEnabled() const
Returns whether rendering done by CEGUI will be wrapped with calls to Ogre::RenderSystem::_beginFrame...
CEGUI::RenderTarget
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:60
CEGUI::OgreRenderer::endRendering
void endRendering()
Perform any operations required to finalise rendering.
CEGUI::OgreRenderer::bindShaders
void bindShaders()
Perform required operations to bind shaders (or unbind them) depending on whether shader based render...
CEGUI::OgreRenderer::getDefaultRenderTarget
RenderTarget & getDefaultRenderTarget()
Returns the default RenderTarget object. The default render target is is typically one that targets t...
CEGUI::OgreRenderer::createGeometryBuffer
GeometryBuffer & createGeometryBuffer()
Create a new GeometryBuffer and return a reference to it. You should remove the GeometryBuffer from a...
CEGUI::Size< float >
CEGUI::OgreRenderer::destroyTexture
void destroyTexture(const String &name)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::TextureTarget
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:41
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::OgreRenderer::setupRenderingBlendMode
void setupRenderingBlendMode(const BlendMode mode, const bool force=false)
set the render states for the specified BlendMode.
CEGUI::OgreRenderer::destroyAllTextures
void destroyAllTextures()
Destroy all Texture objects created by this Renderer.
CEGUI::OgreRenderer::setUsingShaders
void setUsingShaders(const bool use_shaders)
Set whether the OgreRenderer shound use shaders when performing its rendering operations.
CEGUI::OgreRenderer::setDisplaySize
void setDisplaySize(const Sizef &sz)
Set the size of the display or host window in pixels for this Renderer object.
CEGUI::OgreRenderer::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::OgreImageCodec
ImageCodec object that loads data via image loading facilities in Ogre.
Definition: RendererModules/Ogre/ImageCodec.h:41
CEGUI::Renderer
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:84
CEGUI::OgreRenderer::getTexture
Texture & getTexture(const String &name) const
Return a Texture object that was previously created by calling the createTexture functions.
CEGUI::OgreRenderer::destroyAllTextureTargets
void destroyAllTextureTargets()
Destory all TextureTarget objects created by this Renderer.
CEGUI::OgreRenderer::setRenderingEnabled
void setRenderingEnabled(const bool enabled)
set whether CEGUI rendering will occur
CEGUI::OgreRenderer::setFrameControlExecutionEnabled
void setFrameControlExecutionEnabled(const bool enabled)
Controls whether rendering done by CEGUI will be wrapped with calls to Ogre::RenderSystem::_beginFram...