[Orxonox-commit 6428] r11085 - in code/trunk/src: libraries/core orxonox orxonox/graphics
landauf at orxonox.net
landauf at orxonox.net
Sat Jan 23 21:34:29 CET 2016
Author: landauf
Date: 2016-01-23 21:34:29 +0100 (Sat, 23 Jan 2016)
New Revision: 11085
Added:
code/trunk/src/libraries/core/GlowMaterialListener.h
Modified:
code/trunk/src/libraries/core/CorePrereqs.h
code/trunk/src/libraries/core/GraphicsManager.cc
code/trunk/src/libraries/core/GraphicsManager.h
code/trunk/src/orxonox/Scene.cc
code/trunk/src/orxonox/Scene.h
code/trunk/src/orxonox/graphics/GlobalShader.h
Log:
enable glow shader in all scenes
Modified: code/trunk/src/libraries/core/CorePrereqs.h
===================================================================
--- code/trunk/src/libraries/core/CorePrereqs.h 2016-01-23 19:41:18 UTC (rev 11084)
+++ code/trunk/src/libraries/core/CorePrereqs.h 2016-01-23 20:34:29 UTC (rev 11085)
@@ -183,6 +183,7 @@
class GameState;
struct GameStateInfo;
struct GameStateTreeNode;
+ class GlowMaterialListener;
class GraphicsManager;
class GUIManager;
class Identifiable;
Added: code/trunk/src/libraries/core/GlowMaterialListener.h
===================================================================
--- code/trunk/src/libraries/core/GlowMaterialListener.h (rev 0)
+++ code/trunk/src/libraries/core/GlowMaterialListener.h 2016-01-23 20:34:29 UTC (rev 11085)
@@ -0,0 +1,36 @@
+#ifndef _GlowMaterialListener_H__
+#define _GlowMaterialListener_H__
+
+#include <Ogre.h>
+#include <OgreMaterialManager.h>
+
+namespace orxonox
+{
+ class GlowMaterialListener : public Ogre::MaterialManager::Listener
+ {
+ public:
+ GlowMaterialListener()
+ {
+ mBlackMat = Ogre::MaterialManager::getSingleton().create("mGlowBlack", "Internal");
+ mBlackMat->getTechnique(0)->getPass(0)->setDiffuse(0,0,0,0);
+ mBlackMat->getTechnique(0)->getPass(0)->setSpecular(0,0,0,0);
+ mBlackMat->getTechnique(0)->getPass(0)->setAmbient(0,0,0);
+ mBlackMat->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,0);
+ }
+
+ Ogre::Technique* handleSchemeNotFound(unsigned short, const Ogre::String& schemeName, Ogre::Material*mat, unsigned short, const Ogre::Renderable*)
+ {
+ if (schemeName == "glow")
+ {
+ //LogManager::getSingleton().logMessage(">> adding glow to material: "+mat->getName());
+ return mBlackMat->getTechnique(0);
+ }
+ return NULL;
+ }
+
+ private:
+ Ogre::MaterialPtr mBlackMat;
+ };
+}
+
+#endif /* _GlowMaterialListener_H__ */
Property changes on: code/trunk/src/libraries/core/GlowMaterialListener.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc 2016-01-23 19:41:18 UTC (rev 11084)
+++ code/trunk/src/libraries/core/GraphicsManager.cc 2016-01-23 20:34:29 UTC (rev 11085)
@@ -37,6 +37,7 @@
#include <OgreFrameListener.h>
#include <OgreRoot.h>
#include <OgreLogManager.h>
+#include <OgreMaterialManager.h>
#include <OgreRenderWindow.h>
#include <OgreRenderSystem.h>
#include <OgreResourceGroupManager.h>
@@ -55,6 +56,7 @@
#include "Core.h"
#include "Game.h"
#include "GameMode.h"
+#include "GlowMaterialListener.h"
#include "GUIManager.h"
#include "Loader.h"
#include "ApplicationPaths.h"
@@ -99,6 +101,7 @@
: ogreWindowEventListener_(new OgreWindowEventListener())
, renderWindow_(nullptr)
, viewport_(nullptr)
+ , glowMaterialListener_(nullptr)
, lastFrameStartTime_(0.0f)
, lastFrameEndTime_(0.0f)
, destructionHelper_(this)
@@ -139,7 +142,9 @@
{
orxout(internal_status) << "destroying GraphicsManager..." << endl;
+ Ogre::MaterialManager::getSingleton().removeListener(this->glowMaterialListener_);
Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_);
+
ModifyConsoleCommand(__CC_printScreen_name).resetFunction();
ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).resetFunction();
ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).resetFunction();
@@ -152,6 +157,7 @@
safeObjectDelete(&ogreRoot_);
safeObjectDelete(&ogreLogger_);
safeObjectDelete(&ogreWindowEventListener_);
+ safeObjectDelete(&glowMaterialListener_);
orxout(internal_status) << "finished destroying GraphicsManager" << endl;
}
@@ -306,6 +312,9 @@
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(Ogre::MIP_UNLIMITED);
+ this->glowMaterialListener_ = new GlowMaterialListener();
+ Ogre::MaterialManager::getSingleton().addListener(this->glowMaterialListener_);
+
//Add program icon
#if defined(ORXONOX_PLATFORM_WINDOWS)
HWND hwnd;
Modified: code/trunk/src/libraries/core/GraphicsManager.h
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.h 2016-01-23 19:41:18 UTC (rev 11084)
+++ code/trunk/src/libraries/core/GraphicsManager.h 2016-01-23 20:34:29 UTC (rev 11085)
@@ -126,10 +126,11 @@
OgreWindowEventListener* ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
Ogre::LogManager* ogreLogger_;
Ogre::Root* ogreRoot_; //!< Ogre's root
- Ogre::RenderWindow* renderWindow_; //!< the one and only render window
- Ogre::Viewport* viewport_; //!< default full size viewport
- float lastFrameStartTime_; //!< Time stamp of the beginning of the last frame
- float lastFrameEndTime_; //!< Time stamp of the end of the last frame
+ Ogre::RenderWindow* renderWindow_; //!< the one and only render window
+ Ogre::Viewport* viewport_; //!< default full size viewport
+ GlowMaterialListener* glowMaterialListener_; //!< Material Listener for the 'Glow' compositor
+ float lastFrameStartTime_; //!< Time stamp of the beginning of the last frame
+ float lastFrameEndTime_; //!< Time stamp of the end of the last frame
// XML files for the resources and the debug overlay
std::shared_ptr<XMLFile> resources_; //!< XML with resource locations
Modified: code/trunk/src/orxonox/Scene.cc
===================================================================
--- code/trunk/src/orxonox/Scene.cc 2016-01-23 19:41:18 UTC (rev 11084)
+++ code/trunk/src/orxonox/Scene.cc 2016-01-23 20:34:29 UTC (rev 11085)
@@ -57,6 +57,7 @@
#include "worldentities/WorldEntity.h"
#include "Level.h"
#include "RenderQueueListener.h"
+#include "graphics/GlobalShader.h"
namespace orxonox
{
@@ -90,6 +91,9 @@
this->sceneManager_->addRenderQueueListener(this->renderQueueListener_);//add our own renderQueueListener
this->radar_ = new Radar();
+ this->glowShader_ = new GlobalShader(this);
+ this->glowShader_->setScene(WeakPtr<Scene>(this), this->getObjectID()); // avoid circular reference
+ this->glowShader_->getShader().setCompositorName("Glow");
}
else
{
@@ -99,6 +103,7 @@
this->renderQueueListener_ = nullptr;
this->radar_ = nullptr;
+ this->glowShader_ = nullptr;
}
// No physics yet, XMLPort will do that.
@@ -123,6 +128,8 @@
if (this->radar_)
this->radar_->destroy();
+ if (this->glowShader_)
+ this->glowShader_->destroy();
if (GameMode::showsGraphics())
{
Modified: code/trunk/src/orxonox/Scene.h
===================================================================
--- code/trunk/src/orxonox/Scene.h 2016-01-23 19:41:18 UTC (rev 11084)
+++ code/trunk/src/orxonox/Scene.h 2016-01-23 20:34:29 UTC (rev 11085)
@@ -117,6 +117,7 @@
bool bShadows_; //!< Do we want shadows in our scene?
float soundReferenceDistance_; //!< This holds a reference distance, which represents the distance between our scene and the listener
Radar* radar_; //!< This is a pointer to a Radar object assigned with this scene
+ WeakPtr<GlobalShader> glowShader_;
/////////////
Modified: code/trunk/src/orxonox/graphics/GlobalShader.h
===================================================================
--- code/trunk/src/orxonox/graphics/GlobalShader.h 2016-01-23 19:41:18 UTC (rev 11084)
+++ code/trunk/src/orxonox/graphics/GlobalShader.h 2016-01-23 20:34:29 UTC (rev 11085)
@@ -47,7 +47,7 @@
virtual void changedVisibility() override;
- inline const Shader& getShader() const
+ inline Shader& getShader()
{ return this->shader_; }
private:
More information about the Orxonox-commit
mailing list