forked from teamnwah/openmw-tes3coop
osgMyGUI: implement AdditiveLayer
parent
51f3a8fec6
commit
57b9eafa0f
@ -0,0 +1,33 @@
|
||||
#include "additivelayer.hpp"
|
||||
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include "myguirendermanager.hpp"
|
||||
|
||||
namespace osgMyGUI
|
||||
{
|
||||
|
||||
AdditiveLayer::AdditiveLayer()
|
||||
{
|
||||
mStateSet = new osg::StateSet;
|
||||
mStateSet->setAttributeAndModes(new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE));
|
||||
}
|
||||
|
||||
AdditiveLayer::~AdditiveLayer()
|
||||
{
|
||||
// defined in .cpp file since we can't delete incomplete types
|
||||
}
|
||||
|
||||
void AdditiveLayer::renderToTarget(MyGUI::IRenderTarget *_target, bool _update)
|
||||
{
|
||||
RenderManager& renderManager = static_cast<RenderManager&>(MyGUI::RenderManager::getInstance());
|
||||
|
||||
renderManager.setInjectState(mStateSet.get());
|
||||
|
||||
MyGUI::OverlappedLayer::renderToTarget(_target, _update);
|
||||
|
||||
renderManager.setInjectState(NULL);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#ifndef OPENMW_COMPONENTS_MYGUIPLATFORM_ADDITIVELAYER
|
||||
#define OPENMW_COMPONENTS_MYGUIPLATFORM_ADDITIVELAYER
|
||||
|
||||
#include <MyGUI_OverlappedLayer.h>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class StateSet;
|
||||
}
|
||||
|
||||
namespace osgMyGUI
|
||||
{
|
||||
|
||||
/// @brief A Layer rendering with additive blend mode.
|
||||
class AdditiveLayer : public MyGUI::OverlappedLayer
|
||||
{
|
||||
public:
|
||||
MYGUI_RTTI_DERIVED( AdditiveLayer )
|
||||
|
||||
AdditiveLayer();
|
||||
~AdditiveLayer();
|
||||
|
||||
virtual void renderToTarget(MyGUI::IRenderTarget* _target, bool _update);
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::StateSet> mStateSet;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue