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