osgMyGUI: implement AdditiveLayer

openmw-37
scrawl 9 years ago
parent 51f3a8fec6
commit 57b9eafa0f

@ -34,6 +34,7 @@
#include <components/myguiplatform/myguiplatform.hpp>
#include <components/myguiplatform/myguirendermanager.hpp>
#include <components/myguiplatform/additivelayer.hpp>
#include <components/vfs/manager.hpp>
@ -216,6 +217,7 @@ namespace MWGui
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollBar>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<VideoWidget>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<BackgroundImage>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<osgMyGUI::AdditiveLayer>("Layer");
BookPage::registerMyGUIComponents ();
ItemView::registerComponents();
ItemWidget::registerComponents();

@ -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…
Cancel
Save