CWallpaper.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #pragma once
  2. #include <GL/glew.h>
  3. #include <GLFW/glfw3.h>
  4. #include "WallpaperEngine/Core/CWallpaper.h"
  5. #include "WallpaperEngine/Core/CScene.h"
  6. #include "WallpaperEngine/Core/CVideo.h"
  7. #include "WallpaperEngine/Assets/CContainer.h"
  8. using namespace WallpaperEngine::Assets;
  9. namespace WallpaperEngine::Irrlicht
  10. {
  11. class CContext;
  12. };
  13. namespace WallpaperEngine::Render
  14. {
  15. class CWallpaper
  16. {
  17. public:
  18. template<class T> const T* as () const { assert (is<T> ()); return (const T*) this; }
  19. template<class T> T* as () { assert (is<T> ()); return (T*) this; }
  20. template<class T> bool is () { return this->m_type == T::Type; }
  21. CWallpaper (Core::CWallpaper* wallpaperData, std::string type, CContainer* container);
  22. ~CWallpaper ();
  23. /**
  24. * Performs a render pass of the wallpaper
  25. */
  26. virtual void render ();
  27. /**
  28. * @return The container to resolve files for this wallpaper
  29. */
  30. CContainer* getContainer () const;
  31. /**
  32. * Performs a ping-pong on the available framebuffers to be able to continue rendering things to them
  33. *
  34. * @param drawTo The framebuffer to use
  35. * @param asInput The last texture used as output (if needed)
  36. */
  37. void pinpongFramebuffer (GLuint* drawTo, GLuint* inputTexture);
  38. /**
  39. * @return The scene's framebuffer
  40. */
  41. GLuint getWallpaperFramebuffer () const;
  42. /**
  43. * @return The scene's texture
  44. */
  45. GLuint getWallpaperTexture () const;
  46. protected:
  47. void createFramebuffer (GLuint* framebuffer, GLuint* depthbuffer, GLuint* texture);
  48. CContainer* m_container;
  49. Core::CWallpaper* m_wallpaperData;
  50. Core::CWallpaper* getWallpaperData ();
  51. /**
  52. * The main framebuffer
  53. */
  54. GLuint m_mainFramebuffer;
  55. /**
  56. * The sub framebuffer
  57. */
  58. GLuint m_subFramebuffer;
  59. /**
  60. * The main depth render buffer
  61. */
  62. GLuint m_mainDepthBuffer;
  63. /**
  64. * The sub depth render buffer
  65. */
  66. GLuint m_subDepthBuffer;
  67. /**
  68. * The main texture used on the framebuffer
  69. */
  70. GLuint m_mainTexture;
  71. /**
  72. * The sub texture used on the framebuffer
  73. */
  74. GLuint m_subTexture;
  75. /**
  76. * The framebuffer used for the scene output
  77. */
  78. GLuint m_sceneFramebuffer;
  79. /**
  80. * The depthbuffer used for the scene output
  81. */
  82. GLuint m_sceneDepthBuffer;
  83. /**
  84. * The texture used for the scene output
  85. */
  86. GLuint m_sceneTexture;
  87. GLuint m_texCoordBuffer;
  88. GLuint m_positionBuffer;
  89. GLuint m_shader;
  90. // shader variables
  91. GLint g_Texture0;
  92. GLint g_ModelViewProjectionMatrix;
  93. GLint a_Position;
  94. GLint a_TexCoord;
  95. /**
  96. * Setups OpenGL's framebuffers for ping-pong and scene rendering
  97. */
  98. void setupFramebuffers ();
  99. /**
  100. * Setups OpenGL's shaders for this wallpaper backbuffer
  101. */
  102. void setupShaders ();
  103. private:
  104. /**
  105. * The type of background this wallpaper is (used
  106. */
  107. std::string m_type;
  108. };
  109. }