| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #include "CEffect.h"
- using namespace WallpaperEngine::Render::Objects;
- CEffect::CEffect (CImage* image, Core::Objects::CEffect* effect, Irrlicht::CContext* context, irr::video::ITexture* input) :
- m_context (context),
- m_image (image),
- m_effect (effect),
- m_inputTexture (input)
- {
- irr::core::dimension2du size = irr::core::dimension2du (
- this->m_image->getImage ()->getSize ().X,
- this->m_image->getImage ()->getSize ().Y
- );
- this->m_outputTexture = this->m_context->getDevice ()->getVideoDriver ()->addRenderTargetTexture (
- size,
- (
- "_rt_WALLENGINELINUX_OUTPUT_" +
- std::to_string (image->getImage ()->getId ()) + "_" +
- std::to_string (this->m_image->getEffects ().size ()) +
- "_effect_output"
- ).c_str ()
- );
- this->generateFBOs ();
- this->generatePasses ();
- }
- const irr::video::ITexture* CEffect::getInputTexture () const
- {
- return this->m_inputTexture;
- }
- const irr::video::ITexture* CEffect::getOutputTexture () const
- {
- return this->m_outputTexture;
- }
- const CImage* CEffect::getImage () const
- {
- return this->m_image;
- }
- const std::vector<Effects::CMaterial*>& CEffect::getMaterials () const
- {
- return this->m_materials;
- }
- Effects::CFBO* CEffect::findFBO (const std::string& name)
- {
- auto cur = this->m_fbos.begin ();
- auto end = this->m_fbos.end ();
- for (; cur != end; cur ++)
- {
- if ((*cur)->getName () == name)
- {
- return *cur;
- }
- }
- return nullptr;
- }
- void CEffect::generatePasses ()
- {
- auto cur = this->m_effect->getMaterials ().begin ();
- auto end = this->m_effect->getMaterials ().end ();
- const irr::video::ITexture* inputTexture = this->getInputTexture ();
- for (; cur != end; cur ++)
- {
- Effects::CMaterial* material = new Effects::CMaterial (this->m_context, this, *cur, inputTexture);
- // next input texture will be the output texture of the material
- inputTexture = material->getOutputTexture ();
- this->m_materials.push_back (material);
- }
- }
- void CEffect::generateFBOs ()
- {
- auto cur = this->m_effect->getFbos ().begin ();
- auto end = this->m_effect->getFbos ().end ();
- for (; cur != end; cur ++)
- {
- this->m_fbos.push_back (
- new Effects::CFBO (*cur, this->m_image->getImage (), this->m_context)
- );
- }
- }
|