Framebuffer.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 DEPTH = 16;
  14. Framebuffer(const WindowSize& size, uint mode, bool texCompare = false);
  15. ~Framebuffer();
  16. Framebuffer(const Framebuffer& other) = delete;
  17. Framebuffer(Framebuffer&& other) = delete;
  18. Framebuffer& operator=(const Framebuffer& other) = delete;
  19. Framebuffer& operator=(Framebuffer&& other) = delete;
  20. bool hasError() const;
  21. void bind() const;
  22. void resize(uint width, uint height) const;
  23. void bindPositionTexture(uint textureUnit) const;
  24. void bindNormalTexture(uint textureUnit) const;
  25. void bindColorTexture(uint textureUnit) const;
  26. void bindRedTexture(uint textureUnit) const;
  27. void bindDepthTexture(uint textureUnit) const;
  28. private:
  29. void genTexture(uint index, uint width, uint height);
  30. void setupTexture(uint index, uint width, uint height, GLuint* attachments, uint& counter);
  31. void bindTexture(uint textureUnit, GLuint texture) const;
  32. const char* getErrorString(GLenum error) const;
  33. uint mode;
  34. Array<GLuint, 5> textures;
  35. GLuint buffer;
  36. bool error;
  37. struct Data final {
  38. uint mask;
  39. GLint internalFormat;
  40. GLenum format;
  41. GLenum type;
  42. };
  43. Data data[5];
  44. };
  45. #endif