2021-01-06 22:58:01 +11:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
2021-05-29 12:38:28 +02:00
|
|
|
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
2021-01-06 22:58:01 +11:00
|
|
|
*
|
|
|
|
|
* 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();
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-24 22:43:42 +10:00
|
|
|
void glLoadMatrixf(const GLfloat* matrix)
|
|
|
|
|
{
|
2021-05-13 19:59:57 +02:00
|
|
|
// Transpose the matrix here because glLoadMatrix expects elements
|
|
|
|
|
// in column major order but out Matrix class stores elements in
|
|
|
|
|
// row major order.
|
2021-04-24 22:43:42 +10:00
|
|
|
FloatMatrix4x4 mat(
|
2021-05-13 19:59:57 +02:00
|
|
|
matrix[0], matrix[4], matrix[8], matrix[12],
|
|
|
|
|
matrix[1], matrix[5], matrix[9], matrix[13],
|
|
|
|
|
matrix[2], matrix[6], matrix[10], matrix[14],
|
|
|
|
|
matrix[3], matrix[7], matrix[11], matrix[15]);
|
2021-04-24 22:43:42 +10:00
|
|
|
|
|
|
|
|
g_gl_context->gl_load_matrix(mat);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-06 22:58:01 +11:00
|
|
|
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);
|
|
|
|
|
}
|
2021-04-24 17:40:15 +04:30
|
|
|
|
|
|
|
|
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal)
|
|
|
|
|
{
|
|
|
|
|
g_gl_context->gl_ortho(left, right, bottom, top, nearVal, farVal);
|
|
|
|
|
}
|