SoftwareRasterizer.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@gmx.de>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "DepthBuffer.h"
  8. #include "GL/gl.h"
  9. #include "GLStruct.h"
  10. #include <AK/OwnPtr.h>
  11. #include <LibGfx/Bitmap.h>
  12. #include <LibGfx/Vector4.h>
  13. namespace GL {
  14. struct RasterizerOptions {
  15. bool shade_smooth { true };
  16. bool enable_depth_test { false };
  17. bool enable_blending { false };
  18. GLenum blend_source_factor { GL_ONE };
  19. GLenum blend_destination_factor { GL_ONE };
  20. };
  21. class SoftwareRasterizer final {
  22. public:
  23. SoftwareRasterizer(const Gfx::IntSize& min_size);
  24. void submit_triangle(const GLTriangle& triangle);
  25. void resize(const Gfx::IntSize& min_size);
  26. void clear_color(const FloatVector4&);
  27. void clear_depth(float);
  28. void blit_to(Gfx::Bitmap&);
  29. void wait_for_all_threads() const;
  30. void set_options(const RasterizerOptions&);
  31. RasterizerOptions options() const { return m_options; }
  32. private:
  33. RefPtr<Gfx::Bitmap> m_render_target;
  34. OwnPtr<DepthBuffer> m_depth_buffer;
  35. RasterizerOptions m_options;
  36. };
  37. }