Framebuffer.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. void setFactor(int factor);
  31. private:
  32. void genTexture(uint index, uint width, uint height);
  33. void setupTexture(uint index, uint width, uint height, GLuint* attachments, uint& counter);
  34. void bindTexture(uint textureUnit, GLuint texture) const;
  35. const char* getErrorString(GLenum error) const;
  36. const WindowSize& size;
  37. uint mode;
  38. Array<GLuint, 6> textures;
  39. GLuint buffer;
  40. bool error;
  41. int factor;
  42. struct Data final {
  43. uint mask;
  44. GLint internalFormat;
  45. GLenum format;
  46. GLenum type;
  47. };
  48. Data data[6];
  49. };
  50. #endif