CImage.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_modelMatrix;
  60. glm::mat4 m_viewProjectionMatrix;
  61. CFBO* m_mainFBO;
  62. CFBO* m_subFBO;
  63. CFBO* m_currentMainFBO;
  64. CFBO* m_currentSubFBO;
  65. Core::Objects::CImage* m_image;
  66. std::vector<CEffect*> m_effects;
  67. Effects::CMaterial* m_material;
  68. Effects::CMaterial* m_colorBlendMaterial;
  69. std::vector <Effects::CPass*> m_passes;
  70. glm::vec4 m_pos;
  71. double m_animationTime;
  72. bool m_initialized;
  73. };
  74. }