Texure.cpp 742 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. /*
  12. texture_data_t loadPNG(char *data)
  13. {
  14. // TODO : stuff
  15. UNUSED(data);
  16. return nullptr;
  17. }
  18. */
  19. }
  20. Texture::Texture(char *data) : data((texture_data_t) data)
  21. {
  22. }
  23. Texture::~Texture()
  24. {
  25. // Don't deallocate for now since we still hardcode the data
  26. // delete (data);
  27. }
  28. Rect Texture::get_dimensions()
  29. {
  30. return Rect(0, 0, data[0], data[1]);
  31. }
  32. const Pixel Texture::get_pixel(unsigned x, unsigned y)
  33. {
  34. return Pixel(data[2 + data[0] * y + x]);
  35. }