object.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // object.cpp
  3. // graphics
  4. //
  5. // Created by Sam Jaffe on 7/5/16.
  6. //
  7. #include "game/graphics/object.hpp"
  8. #include "game/graphics/vertex.h"
  9. using namespace graphics;
  10. void vertices(std::vector<vertex> & out, object const & obj) {
  11. static const math::rgba CLEAR{{255, 255, 255, 255}};
  12. math::dim2::quad frame_quad = obj.frame;
  13. out.emplace_back(vertex{obj.points.ll, frame_quad.ll, CLEAR});
  14. out.emplace_back(vertex{obj.points.lr, frame_quad.lr, CLEAR});
  15. out.emplace_back(vertex{obj.points.ur, frame_quad.ur, CLEAR});
  16. out.emplace_back(vertex{obj.points.ll, frame_quad.ll, CLEAR});
  17. out.emplace_back(vertex{obj.points.ur, frame_quad.ur, CLEAR});
  18. out.emplace_back(vertex{obj.points.ul, frame_quad.ul, CLEAR});
  19. }
  20. void graphics::vertices(std::vector<vertex> & out, object const & obj) {
  21. out.reserve(out.size() + 6);
  22. ::vertices(out, obj);
  23. }
  24. void graphics::vertices(std::vector<vertex> & out,
  25. std::vector<object> const & objs) {
  26. out.reserve(out.size() + 6 * objs.size());
  27. for (object const & obj : objs) {
  28. ::vertices(out, obj);
  29. }
  30. }