primitive_assembly.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <functional>
  6. #include "video_core/pica.h"
  7. namespace Pica {
  8. /*
  9. * Utility class to build triangles from a series of vertices,
  10. * according to a given triangle topology.
  11. */
  12. template<typename VertexType>
  13. struct PrimitiveAssembler {
  14. using TriangleHandler = std::function<void(VertexType& v0,
  15. VertexType& v1,
  16. VertexType& v2)>;
  17. PrimitiveAssembler(Regs::TriangleTopology topology);
  18. /*
  19. * Queues a vertex, builds primitives from the vertex queue according to the given
  20. * triangle topology, and calls triangle_handler for each generated primitive.
  21. * NOTE: We could specify the triangle handler in the constructor, but this way we can
  22. * keep event and handler code next to each other.
  23. */
  24. void SubmitVertex(VertexType& vtx, TriangleHandler triangle_handler);
  25. private:
  26. Regs::TriangleTopology topology;
  27. int buffer_index;
  28. VertexType buffer[2];
  29. bool strip_ready = false;
  30. };
  31. } // namespace