CEffect.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "CEffect.h"
  2. using namespace WallpaperEngine::Render::Objects;
  3. using namespace WallpaperEngine::Render;
  4. CEffect::CEffect (CImage* image, Core::Objects::CEffect* effect) :
  5. m_image (image),
  6. m_effect (effect)
  7. {
  8. this->generateFBOs ();
  9. this->generatePasses ();
  10. }
  11. CImage* CEffect::getImage () const
  12. {
  13. return this->m_image;
  14. }
  15. const std::vector<Effects::CMaterial*>& CEffect::getMaterials () const
  16. {
  17. return this->m_materials;
  18. }
  19. const CFBO* CEffect::findFBO (const std::string& name) const
  20. {
  21. auto cur = this->m_fbos.begin ();
  22. auto end = this->m_fbos.end ();
  23. for (; cur != end; cur ++)
  24. {
  25. if ((*cur)->getName () == name)
  26. {
  27. return *cur;
  28. }
  29. }
  30. return nullptr;
  31. }
  32. void CEffect::generatePasses ()
  33. {
  34. auto cur = this->m_effect->getMaterials ().begin ();
  35. auto end = this->m_effect->getMaterials ().end ();
  36. for (; cur != end; cur ++)
  37. this->m_materials.emplace_back (new Effects::CMaterial (this, *cur));
  38. }
  39. void CEffect::generateFBOs ()
  40. {
  41. auto cur = this->m_effect->getFbos ().begin ();
  42. auto end = this->m_effect->getFbos ().end ();
  43. for (; cur != end; cur ++)
  44. {
  45. this->m_fbos.push_back (
  46. new CFBO (
  47. (*cur)->getName (),
  48. ITexture::TextureFormat::ARGB8888, // TODO: CHANGE
  49. this->m_image->getTexture ()->getFlags (), // TODO: CHANGE
  50. (*cur)->getScale (),
  51. this->m_image->getSize ().x / (*cur)->getScale (),
  52. this->m_image->getSize ().y / (*cur)->getScale (),
  53. this->m_image->getSize ().x / (*cur)->getScale (),
  54. this->m_image->getSize ().y / (*cur)->getScale ()
  55. )
  56. );
  57. }
  58. }
  59. bool CEffect::isVisible () const
  60. {
  61. return this->m_effect->isVisible ();
  62. }