cimg_fb.hpp 856 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #define cimg_display 0
  3. #include <CImg.h>
  4. #include <glm/glm.hpp>
  5. #include <string>
  6. /*
  7. * prototype: framebuffer
  8. * void set_pixel(glm::vec<4, int> pos, glm::vec<3, unsigned char> color);
  9. *
  10. */
  11. namespace gb
  12. {
  13. class cimg_framebuffer
  14. {
  15. public:
  16. explicit cimg_framebuffer(const char* filename, unsigned int x, unsigned int y);
  17. ~cimg_framebuffer(void);
  18. void set_pixel(const glm::vec<4, int>& pos, const glm::vec<3, unsigned char>& color);
  19. unsigned int dimx(void) const;
  20. unsigned int dimy(void) const;
  21. private:
  22. void save_image(void) const;
  23. private:
  24. explicit cimg_framebuffer(const cimg_framebuffer&);
  25. private:
  26. std::string m_filename;
  27. cimg_library::CImg<unsigned char> m_image;
  28. unsigned int m_dimx;
  29. unsigned int m_dimy;
  30. };
  31. }