surface_batch.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SuperTux
  2. // Copyright (C) 2018 Ingo Ruhnke <grumbel@gmail.com>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #include "video/surface_batch.hpp"
  17. #include "math/rectf.hpp"
  18. #include "video/surface.hpp"
  19. SurfaceBatch::SurfaceBatch(const SurfacePtr& surface, const Color& color) :
  20. m_surface(surface),
  21. m_color(color),
  22. m_srcrects(),
  23. m_dstrects(),
  24. m_angles()
  25. {
  26. }
  27. void
  28. SurfaceBatch::draw(const Vector& pos, float angle)
  29. {
  30. m_srcrects.emplace_back(Rectf(0, 0,
  31. static_cast<float>(m_surface->get_width()),
  32. static_cast<float>(m_surface->get_height())));
  33. m_dstrects.emplace_back(Rectf(pos,
  34. Sizef(static_cast<float>(m_surface->get_width()),
  35. static_cast<float>(m_surface->get_height()))));
  36. m_angles.emplace_back(angle);
  37. }
  38. void
  39. SurfaceBatch::draw(const Rectf& dstrect, float angle)
  40. {
  41. m_srcrects.emplace_back(Rectf(0, 0,
  42. static_cast<float>(m_surface->get_width()),
  43. static_cast<float>(m_surface->get_height())));
  44. m_dstrects.emplace_back(dstrect);
  45. m_angles.emplace_back(angle);
  46. }
  47. void
  48. SurfaceBatch::draw(const Rectf& srcrect, const Rectf& dstrect, float angle)
  49. {
  50. m_srcrects.emplace_back(srcrect);
  51. m_dstrects.emplace_back(dstrect);
  52. m_angles.emplace_back(angle);
  53. }
  54. /* EOF */