CImage.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include "WallpaperEngine/Core/Objects/CImage.h"
  3. #include "WallpaperEngine/Render/Objects/Effects/CMaterial.h"
  4. #include "WallpaperEngine/Render/Objects/Effects/CPass.h"
  5. #include "WallpaperEngine/Render/Objects/CEffect.h"
  6. #include "WallpaperEngine/Render/CObject.h"
  7. #include "WallpaperEngine/Render/CScene.h"
  8. #include "WallpaperEngine/Render/Shaders/Compiler.h"
  9. #include "WallpaperEngine/Assets/ITexture.h"
  10. #include <glm/vec3.hpp>
  11. using namespace WallpaperEngine;
  12. using namespace WallpaperEngine::Assets;
  13. namespace WallpaperEngine::Render::Objects::Effects
  14. {
  15. class CMaterial;
  16. class CPass;
  17. }
  18. namespace WallpaperEngine::Render::Objects
  19. {
  20. class CEffect;
  21. class CImage : public CObject
  22. {
  23. friend CObject;
  24. public:
  25. CImage (CScene* scene, Core::Objects::CImage* image);
  26. void setup ();
  27. void render () override;
  28. const Core::Objects::CImage* getImage () const;
  29. const std::vector<CEffect*>& getEffects () const;
  30. glm::vec2 getSize() const;
  31. GLuint getSceneSpacePosition () const;
  32. GLuint getCopySpacePosition () const;
  33. GLuint getPassSpacePosition () const;
  34. GLuint getTexCoordCopy () const;
  35. GLuint getTexCoordPass () const;
  36. const ITexture* getTexture () const;
  37. double getAnimationTime () const;
  38. /**
  39. * Performs a ping-pong on the available framebuffers to be able to continue rendering things to them
  40. *
  41. * @param drawTo The framebuffer to use
  42. * @param asInput The last texture used as output (if needed)
  43. */
  44. void pinpongFramebuffer (const CFBO** drawTo, const ITexture** asInput);
  45. protected:
  46. static const std::string Type;
  47. void setupPasses ();
  48. void updateScreenSpacePosition ();
  49. private:
  50. const ITexture* m_texture;
  51. GLuint m_sceneSpacePosition;
  52. GLuint m_copySpacePosition;
  53. GLuint m_passSpacePosition;
  54. GLuint m_texcoordCopy;
  55. GLuint m_texcoordPass;
  56. glm::mat4 m_modelViewProjectionScreen;
  57. glm::mat4 m_modelViewProjectionPass;
  58. glm::mat4 m_modelViewProjectionCopy;
  59. glm::mat4 m_modelViewProjectionScreenInverse;
  60. glm::mat4 m_modelViewProjectionPassInverse;
  61. glm::mat4 m_modelViewProjectionCopyInverse;
  62. glm::mat4 m_modelMatrix;
  63. glm::mat4 m_viewProjectionMatrix;
  64. CFBO* m_mainFBO;
  65. CFBO* m_subFBO;
  66. CFBO* m_currentMainFBO;
  67. CFBO* m_currentSubFBO;
  68. Core::Objects::CImage* m_image;
  69. std::vector<CEffect*> m_effects;
  70. Effects::CMaterial* m_material;
  71. Effects::CMaterial* m_colorBlendMaterial;
  72. std::vector <Effects::CPass*> m_passes;
  73. glm::vec4 m_pos;
  74. double m_animationTime;
  75. bool m_initialized;
  76. };
  77. }