Texure.cpp 623 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "Texture.h"
  2. #include "utility/Rect.h"
  3. #include "render/Pixel.h"
  4. #include <cstdint>
  5. using WalrusRPG::Graphics::Black;
  6. using WalrusRPG::Graphics::Pixel;
  7. using WalrusRPG::Graphics::Texture;
  8. using WalrusRPG::Utils::Rect;
  9. namespace
  10. {
  11. texture_data_t loadPNG(char *data)
  12. {
  13. // TODO : stuff
  14. return nullptr;
  15. }
  16. }
  17. Texture::Texture(char *data) : data(loadPNG(data))
  18. {
  19. }
  20. Texture::~Texture()
  21. {
  22. delete (data);
  23. }
  24. Rect Texture::get_dimensions()
  25. {
  26. return Rect(0, 0, data[0], data[1]);
  27. }
  28. const Pixel Texture::get_pixel(unsigned x, unsigned y)
  29. {
  30. return Pixel(data[2 + data[0] * y + x]);
  31. }