mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
LibGL+LibGPU+LibSoftGPU: Implement point and line drawing
Implement (anti)aliased point drawing and anti-aliased line drawing. Supported through LibGL's `GL_POINTS`, `GL_LINES`, `GL_LINE_LOOP` and `GL_LINE_STRIP`. In order to support this, `LibSoftGPU`s rasterization logic was reworked. Now, any primitive can be drawn by invoking `rasterize()` which takes care of the quad loop and fragment testing logic. Three callbacks need to be passed: * `set_coverage_mask`: the primitive needs to provide initial coverage mask information so fragments can be discarded early. * `set_quad_depth`: fragments survived stencil testing, so depth values need to be set so depth testing can take place. * `set_quad_attributes`: fragments survived depth testing, so fragment shading is going to take place. All attributes like color, tex coords and fog depth need to be set so alpha testing and eventually, fragment rasterization can take place. As of this commit, there are four instantiations of this function: * Triangle rasterization * Points - aliased * Points - anti-aliased * Lines - anti-aliased In order to standardize vertex processing for all primitive types, things like vertex transformation, lighting and tex coord generation are now taking place before clipping.
This commit is contained in:
parent
950ded7ab9
commit
a20bf80b05
13 changed files with 712 additions and 390 deletions
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
virtual GPU::DeviceInfo info() const override;
|
||||
|
||||
virtual void draw_primitives(GPU::PrimitiveType, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform, FloatMatrix4x4 const& texture_transform, Vector<GPU::Vertex> const& vertices, Vector<size_t> const& enabled_texture_units) override;
|
||||
virtual void draw_primitives(GPU::PrimitiveType, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform, FloatMatrix4x4 const& texture_transform, Vector<GPU::Vertex>& vertices, Vector<size_t> const& enabled_texture_units) override;
|
||||
virtual void resize(Gfx::IntSize const& min_size) override;
|
||||
virtual void clear_color(FloatVector4 const&) override;
|
||||
virtual void clear_depth(GPU::DepthType) override;
|
||||
|
@ -74,10 +74,22 @@ public:
|
|||
virtual void set_raster_position(FloatVector4 const& position, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform) override;
|
||||
|
||||
private:
|
||||
void calculate_vertex_lighting(GPU::Vertex& vertex) const;
|
||||
void draw_statistics_overlay(Gfx::Bitmap&);
|
||||
Gfx::IntRect get_rasterization_rect_of_size(Gfx::IntSize size) const;
|
||||
|
||||
void rasterize_triangle(Triangle const&);
|
||||
template<typename CB1, typename CB2, typename CB3>
|
||||
void rasterize(Gfx::IntRect& render_bounds, CB1 set_coverage_mask, CB2 set_quad_depth, CB3 set_quad_attributes);
|
||||
|
||||
void rasterize_line_aliased(GPU::Vertex&, GPU::Vertex&);
|
||||
void rasterize_line_antialiased(GPU::Vertex&, GPU::Vertex&);
|
||||
void rasterize_line(GPU::Vertex&, GPU::Vertex&);
|
||||
|
||||
void rasterize_point_aliased(GPU::Vertex&);
|
||||
void rasterize_point_antialiased(GPU::Vertex&);
|
||||
void rasterize_point(GPU::Vertex&);
|
||||
|
||||
void rasterize_triangle(Triangle&);
|
||||
void setup_blend_factors();
|
||||
void shade_fragments(PixelQuad&);
|
||||
bool test_alpha(PixelQuad&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue