ladybird/Userland/Libraries/LibSoftGPU/Clipper.h
RKBethke 0836912a6d LibGL+LibGPU+LibSoftGPU: Implement and expose glClipPlane
This commit implements glClipPlane and its supporting calls, backed
by new support for user-defined clip planes in the software GPU clipper.

This fixes some visual bugs seen in the Quake III port, in which mirrors
would only reflect correctly from close distances.
2022-05-11 23:09:47 +02:00

40 lines
882 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,
User, // Within view space
};
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);
void clip_triangle_against_user_defined(Vector<GPU::Vertex>& input_verts, Vector<FloatVector4>& user_planes);
private:
Vector<GPU::Vertex> m_vertex_buffer;
};
}