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