CWallpaper.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #include <irrlicht/irrlicht.h>
  3. #include <GL/glew.h>
  4. #include <GLFW/glfw3.h>
  5. #include "WallpaperEngine/Core/CWallpaper.h"
  6. #include "WallpaperEngine/Core/CScene.h"
  7. #include "WallpaperEngine/Core/CVideo.h"
  8. #include "WallpaperEngine/Irrlicht/CContext.h"
  9. #include "WallpaperEngine/Assets/CContainer.h"
  10. using namespace WallpaperEngine::Assets;
  11. namespace WallpaperEngine::Irrlicht
  12. {
  13. class CContext;
  14. };
  15. namespace WallpaperEngine::Render
  16. {
  17. class CWallpaper
  18. {
  19. public:
  20. template<class T> const T* as () const { assert (is<T> ()); return (const T*) this; }
  21. template<class T> T* as () { assert (is<T> ()); return (T*) this; }
  22. template<class T> bool is () { return this->m_type == T::Type; }
  23. CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CContainer* container);
  24. ~CWallpaper ();
  25. /**
  26. * Performs a render pass of the wallpaper
  27. */
  28. virtual void render () = 0;
  29. /**
  30. * @return The container to resolve files for this wallpaper
  31. */
  32. CContainer* getContainer () const;
  33. /**
  34. * Performs a ping-pong on the available framebuffers to be able to continue rendering things to them
  35. *
  36. * @param drawTo The framebuffer to use
  37. * @param asInput The last texture used as output (if needed)
  38. */
  39. void pinpongFramebuffer (GLuint* drawTo, GLuint* inputTexture);
  40. protected:
  41. CContainer* m_container;
  42. Core::CWallpaper* m_wallpaperData;
  43. Core::CWallpaper* getWallpaperData ();
  44. /**
  45. * The main framebuffer
  46. */
  47. GLuint m_mainFramebuffer;
  48. /**
  49. * The sub framebuffer
  50. */
  51. GLuint m_subFramebuffer;
  52. /**
  53. * The main depth render buffer
  54. */
  55. GLuint m_mainDepthBuffer;
  56. /**
  57. * The sub depth render buffer
  58. */
  59. GLuint m_subDepthBuffer;
  60. /**
  61. * The main texture used on the framebuffer
  62. */
  63. GLuint m_mainTexture;
  64. /**
  65. * The sub texture used on the framebuffer
  66. */
  67. GLuint m_subTexture;
  68. /**
  69. * Setups OpenGL's framebuffers for ping-pong
  70. */
  71. void setupFramebuffers ();
  72. private:
  73. /**
  74. * The type of background this wallpaper is (used
  75. */
  76. std::string m_type;
  77. };
  78. }