TextureLayoutRectangle.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "TextureLayoutRectangle.h"
  2. namespace Rml {
  3. TextureLayoutRectangle::TextureLayoutRectangle(const int _id, const Vector2i dimensions) : dimensions(dimensions), texture_position(0, 0)
  4. {
  5. id = _id;
  6. texture_index = -1;
  7. texture_data = nullptr;
  8. texture_stride = 0;
  9. }
  10. TextureLayoutRectangle::~TextureLayoutRectangle() {}
  11. int TextureLayoutRectangle::GetId() const
  12. {
  13. return id;
  14. }
  15. Vector2i TextureLayoutRectangle::GetPosition() const
  16. {
  17. return texture_position;
  18. }
  19. Vector2i TextureLayoutRectangle::GetDimensions() const
  20. {
  21. return dimensions;
  22. }
  23. void TextureLayoutRectangle::Place(const int _texture_index, const Vector2i position)
  24. {
  25. texture_index = _texture_index;
  26. texture_position = position;
  27. }
  28. void TextureLayoutRectangle::Unplace()
  29. {
  30. texture_index = -1;
  31. }
  32. bool TextureLayoutRectangle::IsPlaced() const
  33. {
  34. return texture_index > -1;
  35. }
  36. void TextureLayoutRectangle::Allocate(byte* _texture_data, int _texture_stride)
  37. {
  38. texture_data = _texture_data + ((texture_position.y * _texture_stride) + texture_position.x * 4);
  39. texture_stride = _texture_stride;
  40. }
  41. int TextureLayoutRectangle::GetTextureIndex()
  42. {
  43. return texture_index;
  44. }
  45. byte* TextureLayoutRectangle::GetTextureData()
  46. {
  47. return texture_data;
  48. }
  49. int TextureLayoutRectangle::GetTextureStride() const
  50. {
  51. return texture_stride;
  52. }
  53. } // namespace Rml