mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 12:35:08 +00:00

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.
37 lines
732 B
C++
37 lines
732 B
C++
/*
|
|
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Vector.h>
|
|
#include <LibGPU/Vertex.h>
|
|
#include <LibGfx/Vector4.h>
|
|
|
|
namespace SoftGPU {
|
|
|
|
class Clipper final {
|
|
public:
|
|
enum class ClipPlane : u8 {
|
|
LEFT = 0,
|
|
RIGHT,
|
|
TOP,
|
|
BOTTOM,
|
|
NEAR,
|
|
FAR
|
|
};
|
|
|
|
Clipper() = default;
|
|
|
|
void clip_points_against_frustum(Vector<GPU::Vertex>& vertices);
|
|
bool clip_line_against_frustum(GPU::Vertex& from, GPU::Vertex& to);
|
|
void clip_triangle_against_frustum(Vector<GPU::Vertex>& input_vecs);
|
|
|
|
private:
|
|
Vector<GPU::Vertex> m_vertex_buffer;
|
|
};
|
|
|
|
}
|