Orxonox  0.0.5 Codename: Arcturus
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
orxonox::Shader Class Reference

Shader is a wrapper class around Ogre::CompositorInstance. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/tools/Shader.h>

Inheritance diagram for orxonox::Shader:
orxonox::ViewportEventListener orxonox::Listable orxonox::Identifiable

Classes

struct  ParameterContainer
 Helper struct to store parameters for shader programs. More...
 

Public Member Functions

 Shader (Ogre::SceneManager *scenemanager=nullptr)
 Initializes the values and sets the scene manager. More...
 
virtual ~Shader ()
 Removes the compositor and frees the resources. More...
 
virtual void cameraChanged (Ogre::Viewport *viewport, Ogre::Camera *oldCamera) override
 Inherited from ViewportEventListener - called if the camera changes. More...
 
void changedCompositorName ()
 Changes the compositor - default viewport. More...
 
void changedCompositorName (Ogre::Viewport *viewport)
 Changes the compositor. More...
 
const std::string & getCompositorName () const
 Returns the compositor's name. More...
 
Ogre::SceneManager * getSceneManager () const
 Returns the scene manager. More...
 
bool isVisible () const
 Returns whether or not the shader is visible. More...
 
virtual void notifyMaterialRender (Ogre::uint32 pass_id, Ogre::MaterialPtr &materialPtr) override
 Inherited by Ogre::CompositorInstance::Listener, called whenever the material is rendered. More...
 
void setCompositorName (const std::string &name)
 Defines the compositor's name (located in a .compositor file). More...
 
void setParameter (unsigned short technique, unsigned short pass, const std::string &parameter, float value)
 Defines a new float value for a given parameter. More...
 
void setParameter (unsigned short technique, unsigned short pass, const std::string &parameter, int value)
 Defines a new integer value for a given parameter. More...
 
void setSceneManager (Ogre::SceneManager *scenemanager)
 Sets the scenemanager (usually provided in the constructor, but can be set later). Shouldn't be changed once it's set. More...
 
void setVisible (bool bVisible)
 Defines if the shader is visible or not. More...
 
void updateVisibility ()
 Changes the visibility of the shader. More...
 
- Public Member Functions inherited from orxonox::Listable
 Listable ()
 Constructor: Allocates space in the element list. More...
 
 Listable (Context *context)
 Constructor: Allocates space in the element list and assigns the context. More...
 
virtual ~Listable ()
 Destructor: Removes the object from the object-lists. More...
 
ContextgetContext () const
 
void setContext (Context *context)
 Changes the context. More...
 
void unregisterObject ()
 Removes this object from the object-lists. More...
 
- Public Member Functions inherited from orxonox::Identifiable
 Identifiable ()
 Constructor: Sets the default values. More...
 
virtual ~Identifiable ()
 
ORX_FORCEINLINE voidgetDerivedPointer (unsigned int classID)
 Returns a valid pointer of any derived type that is registered in the class hierarchy. More...
 
template<class T >
ORX_FORCEINLINE T * getDerivedPointer (unsigned int classID)
 Version of getDerivedPointer with template. More...
 
template<class T >
ORX_FORCEINLINE const T * getDerivedPointer (unsigned int classID) const
 Const version of getDerivedPointer with template. More...
 
IdentifiergetIdentifier () const
 Returns the Identifier of the object. More...
 
bool isA (const Identifier *identifier)
 Returns true if the object's class is of the given type or a derivative. More...
 
template<class B >
bool isA (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is of the given type or a derivative. More...
 
bool isA (const Identifiable *object)
 Returns true if the object's class is of the given type or a derivative. More...
 
bool isChildOf (const Identifier *identifier)
 Returns true if the object's class is a child of the given type. More...
 
template<class B >
bool isChildOf (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is a child of the given type. More...
 
bool isChildOf (const Identifiable *object)
 Returns true if the object's class is a child of the given type. More...
 
bool isDirectChildOf (const Identifier *identifier)
 Returns true if the object's class is a direct child of the given type. More...
 
template<class B >
bool isDirectChildOf (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is a direct child of the given type. More...
 
bool isDirectChildOf (const Identifiable *object)
 Returns true if the object's class is a direct child of the given type. More...
 
bool isDirectParentOf (const Identifier *identifier)
 Returns true if the object's class is a direct parent of the given type. More...
 
template<class B >
bool isDirectParentOf (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is a direct parent of the given type. More...
 
bool isDirectParentOf (const Identifiable *object)
 Returns true if the object's class is a direct child of the given type. More...
 
bool isExactlyA (const Identifier *identifier)
 Returns true if the object's class is exactly of the given type. More...
 
template<class B >
bool isExactlyA (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is exactly of the given type. More...
 
bool isExactlyA (const Identifiable *object)
 Returns true if the object's class is exactly of the given type. More...
 
bool isParentOf (const Identifier *identifier)
 Returns true if the object's class is a parent of the given type. More...
 
template<class B >
bool isParentOf (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is a parent of the given type. More...
 
bool isParentOf (const Identifiable *object)
 Returns true if the object's class is a parent of the given type. More...
 

Private Member Functions

void addAsListener ()
 Registers the shader as CompositorInstance::Listener at the compositor. More...
 

Static Private Member Functions

static bool hasCgProgramManager ()
 Detects if the Cg program manager plugin is active. More...
 

Private Attributes

bool bLoadCompositor_
 True if the compositor should be loaded (usually false if no graphics) More...
 
bool bVisible_
 True if the shader should be visible. More...
 
Ogre::CompositorInstance * compositorInstance_
 The compositor instance representing the wrapped compositor. More...
 
std::string compositorName_
 The name of the current compositor. More...
 
std::string oldcompositorName_
 The name of the previous compositor (used to unregister) More...
 
std::list< ParameterContainerparameters_
 The list of parameters that should be set on the next update. More...
 
bool registeredAsListener_
 True if the shader should register itself as listener at the compositor. More...
 
Ogre::SceneManager * scenemanager_
 The scenemanager for which the shader is active. More...
 

Additional Inherited Members

- Protected Member Functions inherited from orxonox::ViewportEventListener
 ViewportEventListener ()
 
virtual ~ViewportEventListener ()=default
 

Detailed Description

Shader is a wrapper class around Ogre::CompositorInstance.

It provides some functions to easily change the visibility and parameters for shader programs.

Constructor & Destructor Documentation

orxonox::Shader::Shader ( Ogre::SceneManager *  scenemanager = nullptr)

Initializes the values and sets the scene manager.

orxonox::Shader::~Shader ( )
virtual

Removes the compositor and frees the resources.

Member Function Documentation

void orxonox::Shader::addAsListener ( )
private

Registers the shader as CompositorInstance::Listener at the compositor.

Used to change parameters.

void orxonox::Shader::cameraChanged ( Ogre::Viewport *  viewport,
Ogre::Camera *  oldCamera 
)
overridevirtual

Inherited from ViewportEventListener - called if the camera changes.

Since the new camera could be in a different scene, the shader has to make sure it deactivates or activates itself accordingly.

Additionally the shader has to be turned off and on even if the camera stays in the same scene to fix a weird behavior of Ogre.

Reimplemented from orxonox::ViewportEventListener.

void orxonox::Shader::changedCompositorName ( )

Changes the compositor - default viewport.

void orxonox::Shader::changedCompositorName ( Ogre::Viewport *  viewport)

Changes the compositor.

const std::string& orxonox::Shader::getCompositorName ( ) const
inline

Returns the compositor's name.

Ogre::SceneManager* orxonox::Shader::getSceneManager ( ) const
inline

Returns the scene manager.

bool orxonox::Shader::hasCgProgramManager ( )
staticprivate

Detects if the Cg program manager plugin is active.

bool orxonox::Shader::isVisible ( ) const
inline

Returns whether or not the shader is visible.

void orxonox::Shader::notifyMaterialRender ( Ogre::uint32  pass_id,
Ogre::MaterialPtr &  materialPtr 
)
overridevirtual

Inherited by Ogre::CompositorInstance::Listener, called whenever the material is rendered.

Used to change parameters.

void orxonox::Shader::setCompositorName ( const std::string &  name)
inline

Defines the compositor's name (located in a .compositor file).

void orxonox::Shader::setParameter ( unsigned short  technique,
unsigned short  pass,
const std::string &  parameter,
float  value 
)

Defines a new float value for a given parameter.

The parameter will be updated if the compositor is rendered the next time.

void orxonox::Shader::setParameter ( unsigned short  technique,
unsigned short  pass,
const std::string &  parameter,
int  value 
)

Defines a new integer value for a given parameter.

The parameter will be updated if the compositor is rendered the next time.

void orxonox::Shader::setSceneManager ( Ogre::SceneManager *  scenemanager)
inline

Sets the scenemanager (usually provided in the constructor, but can be set later). Shouldn't be changed once it's set.

void orxonox::Shader::setVisible ( bool  bVisible)
inline

Defines if the shader is visible or not.

void orxonox::Shader::updateVisibility ( )

Changes the visibility of the shader.

Doesn't free any resources if set to invisible.

Member Data Documentation

bool orxonox::Shader::bLoadCompositor_
private

True if the compositor should be loaded (usually false if no graphics)

bool orxonox::Shader::bVisible_
private

True if the shader should be visible.

Ogre::CompositorInstance* orxonox::Shader::compositorInstance_
private

The compositor instance representing the wrapped compositor.

std::string orxonox::Shader::compositorName_
private

The name of the current compositor.

std::string orxonox::Shader::oldcompositorName_
private

The name of the previous compositor (used to unregister)

std::list<ParameterContainer> orxonox::Shader::parameters_
private

The list of parameters that should be set on the next update.

bool orxonox::Shader::registeredAsListener_
private

True if the shader should register itself as listener at the compositor.

Ogre::SceneManager* orxonox::Shader::scenemanager_
private

The scenemanager for which the shader is active.


The documentation for this class was generated from the following files: