Clipper.h 882 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/Vector.h>
  9. #include <LibGPU/Vertex.h>
  10. #include <LibGfx/Vector4.h>
  11. namespace SoftGPU {
  12. class Clipper final {
  13. public:
  14. enum class ClipPlane : u8 {
  15. Left = 0,
  16. Right,
  17. Top,
  18. Bottom,
  19. Near,
  20. Far,
  21. User, // Within view space
  22. };
  23. Clipper() = default;
  24. void clip_points_against_frustum(Vector<GPU::Vertex>& vertices);
  25. bool clip_line_against_frustum(GPU::Vertex& from, GPU::Vertex& to);
  26. void clip_triangle_against_frustum(Vector<GPU::Vertex>& input_vecs);
  27. void clip_triangle_against_user_defined(Vector<GPU::Vertex>& input_verts, Vector<FloatVector4>& user_planes);
  28. private:
  29. Vector<GPU::Vertex> m_vertex_buffer;
  30. };
  31. }