framebuffer.hpp 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef IS_FRAMEBUFFER_H_
  2. #define IS_FRAMEBUFFER_H_
  3. #include <GL/glew.h>
  4. #include <GL/gl.h>
  5. #include <glm/glm.hpp>
  6. #include "x.hpp"
  7. #include "shader.hpp"
  8. #include "resource.hpp"
  9. namespace slop {
  10. class Framebuffer
  11. {
  12. public:
  13. enum buffers
  14. {
  15. color = 0x01,
  16. depth = 0x02,
  17. stencil = 0x04
  18. };
  19. Framebuffer();
  20. Framebuffer( unsigned int width, unsigned int height, unsigned char flags = color, std::string shader = "simple" );
  21. ~Framebuffer();
  22. void create( unsigned int width, unsigned int height, unsigned char flags = color, std::string shader = "simple" );
  23. void createFromTexture( unsigned int texture, std::string shader = "simple" );
  24. void setShader( std::string shader = "simple" );
  25. void clear( glm::vec4 color = glm::vec4( 0, 0, 0, 1 ), unsigned char flags = color | depth | stencil );
  26. void bind();
  27. void unbind();
  28. void draw( float time, unsigned int image );
  29. unsigned int m_texture;
  30. unsigned int m_depth;
  31. unsigned int m_stencil;
  32. slop::Shader* m_shader;
  33. private:
  34. unsigned int m_width;
  35. unsigned int m_height;
  36. void check();
  37. void generateBuffers();
  38. unsigned char m_flags;
  39. bool generatedBuffers;
  40. unsigned int m_frame;
  41. unsigned int m_buffers[2];
  42. };
  43. }
  44. #endif //IS_FRAMEBUFFER_H_