Framebuffer.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef FRAMEBUFFER_H
  2. #define FRAMEBUFFER_H
  3. #include <GL/glew.h>
  4. #include "client/rendering/WindowSize.h"
  5. #include "common/utils/Array.h"
  6. #include "common/utils/Types.h"
  7. class Framebuffer final {
  8. public:
  9. static const uint POSITION = 1;
  10. static const uint NORMAL = 2;
  11. static const uint COLOR = 4;
  12. static const uint RED = 8;
  13. static const uint TANGENT = 16;
  14. static const uint DEPTH = 32;
  15. Framebuffer(const WindowSize& size, uint mode, bool texCompare = false);
  16. ~Framebuffer();
  17. Framebuffer(const Framebuffer& other) = delete;
  18. Framebuffer(Framebuffer&& other) = delete;
  19. Framebuffer& operator=(const Framebuffer& other) = delete;
  20. Framebuffer& operator=(Framebuffer&& other) = delete;
  21. bool hasError() const;
  22. void bind() const;
  23. void resize(uint width, uint height) const;
  24. void bindPositionTexture(uint textureUnit) const;
  25. void bindNormalTexture(uint textureUnit) const;
  26. void bindColorTexture(uint textureUnit) const;
  27. void bindRedTexture(uint textureUnit) const;
  28. void bindTangentTexture(uint textureUnit) const;
  29. void bindDepthTexture(uint textureUnit) const;
  30. private:
  31. void genTexture(uint index, uint width, uint height);
  32. void setupTexture(uint index, uint width, uint height, GLuint* attachments, uint& counter);
  33. void bindTexture(uint textureUnit, GLuint texture) const;
  34. const char* getErrorString(GLenum error) const;
  35. uint mode;
  36. Array<GLuint, 6> textures;
  37. GLuint buffer;
  38. bool error;
  39. struct Data final {
  40. uint mask;
  41. GLint internalFormat;
  42. GLenum format;
  43. GLenum type;
  44. };
  45. Data data[6];
  46. };
  47. #endif