mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
4807d32139
This currently (obviously) doesn't support any actual 3D hardware, hence all calls are done via software rendering. Note that any modern constructs such as shaders are unsupported, as this driver only implements Fixed Function Pipeline functionality. The library is split into a base GLContext interface and a software based renderer implementation of said interface. The global glXXX functions serve as an OpenGL compatible c-style interface to the currently bound context instance. Co-authored-by: Stephan Unverwerth <s.unverwerth@gmx.de>
54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
/*
|
|
* 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;
|
|
};
|
|
|
|
}
|