Texure.cpp 728 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "Texture.h"
  2. #include "utility/Rect.h"
  3. #include "render/Pixel.h"
  4. #include "utility/misc.h"
  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. UNUSED(data);
  15. return nullptr;
  16. }
  17. }
  18. Texture::Texture(char *data) : data((texture_data_t) data)
  19. {
  20. }
  21. Texture::~Texture()
  22. {
  23. // Don't deallocate for now since we still hardcode the data
  24. // delete (data);
  25. }
  26. Rect Texture::get_dimensions()
  27. {
  28. return Rect(0, 0, data[0], data[1]);
  29. }
  30. const Pixel Texture::get_pixel(unsigned x, unsigned y)
  31. {
  32. return Pixel(data[2 + data[0] * y + x]);
  33. }