diff options
author | Jesse Buhagiar <jooster669@gmail.com> | 2021-01-06 22:58:01 +1100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-08 10:13:22 +0200 |
commit | 4807d3213972725563304c5477c9b90d69e0b53b (patch) | |
tree | 640df271731a883312208b4e863f146a36c62283 /Userland/Libraries/LibGL/GLMat.cpp | |
parent | 1424c4651f9158f435f2985c51b965b6a755c5cd (diff) | |
download | serenity-4807d3213972725563304c5477c9b90d69e0b53b.zip |
LibGL: Implement a basic OpenGL 1.x compatible library
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>
Diffstat (limited to 'Userland/Libraries/LibGL/GLMat.cpp')
-rw-r--r-- | Userland/Libraries/LibGL/GLMat.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GLMat.cpp b/Userland/Libraries/LibGL/GLMat.cpp new file mode 100644 index 0000000000..18d7b73570 --- /dev/null +++ b/Userland/Libraries/LibGL/GLMat.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com> + * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@gmx.de> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "GL/gl.h" +#include "GLContext.h" + +extern GL::GLContext* g_gl_context; + +void glMatrixMode(GLenum mode) +{ + g_gl_context->gl_matrix_mode(mode); +} + +/* + * Push the current matrix (based on the current matrix mode) + * to its' corresponding matrix stack in the current OpenGL + * state context + */ +void glPushMatrix() +{ + g_gl_context->gl_push_matrix(); +} + +/* + * Pop a matrix from the corresponding matrix stack into the + * corresponding matrix in the state based on the current + * matrix mode + */ +void glPopMatrix() +{ + g_gl_context->gl_pop_matrix(); +} + +void glLoadIdentity() +{ + g_gl_context->gl_load_identity(); +} + +/** + * Create a viewing frustum (a.k.a a "Perspective Matrix") in the current matrix. This + * is usually done to the projection matrix. The current matrix is then multiplied + * by this viewing frustum matrix. + * + * https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glFrustum.xml + * + * + * FIXME: We need to check for some values that could result in a division by zero + */ +void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal) +{ + g_gl_context->gl_frustum(left, right, bottom, top, nearVal, farVal); +} |