summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL/SoftwareGLContext.h
blob: a8c1d7df8bc382d2b8504f7236d4bbb5b224db93 (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
49
50
51
52
53
54
/*
 * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@gmx.de>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "GLContext.h"
#include "GLStruct.h"
#include <AK/Vector.h>
#include <LibGfx/Matrix4x4.h>
#include <LibGfx/Vector3.h>

namespace GL {

class SoftwareGLContext : public GLContext {
public:
    virtual void gl_begin(GLenum mode) override;
    virtual void gl_clear(GLbitfield mask) override;
    virtual void gl_clear_color(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override;
    virtual void gl_color(GLdouble r, GLdouble g, GLdouble b, GLdouble a) override;
    virtual void gl_end() override;
    virtual void gl_frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) override;
    virtual GLubyte* gl_get_string(GLenum name) override;
    virtual void gl_load_identity() override;
    virtual void gl_matrix_mode(GLenum mode) override;
    virtual void gl_push_matrix() override;
    virtual void gl_pop_matrix() override;
    virtual void gl_rotate(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) override;
    virtual void gl_translate(GLdouble x, GLdouble y, GLdouble z) override;
    virtual void gl_vertex(GLdouble x, GLdouble y, GLdouble z, GLdouble w) override;
    virtual void gl_viewport(GLint x, GLint y, GLsizei width, GLsizei height) override;

private:
    GLenum m_current_draw_mode;
    GLenum m_current_matrix_mode;
    FloatMatrix4x4 m_projection_matrix;
    FloatMatrix4x4 m_model_view_matrix;

    FloatMatrix4x4 m_current_matrix;

    Vector<FloatMatrix4x4> m_projection_matrix_stack;
    Vector<FloatMatrix4x4> m_model_view_matrix_stack;

    FloatVector4 m_clear_color = { 0.0f, 0.0f, 0.0f, 0.0f };
    FloatVector4 m_current_vertex_color = { 1.0f, 1.0f, 1.0f, 1.0f };

    Vector<GLVertex> vertex_list;
    Vector<GLTriangle> triangle_list;
    Vector<GLTriangle> processed_triangles;
};

}