From f07a7f7b946852ab0df6201676501578c02ef133 Mon Sep 17 00:00:00 2001 From: Jesse Buhagiar Date: Sat, 24 Apr 2021 22:43:42 +1000 Subject: LibGL: Impement glLoadMatrixf and underlying function --- Userland/Libraries/LibGL/GL/gl.h | 1 + Userland/Libraries/LibGL/GLContext.h | 2 ++ Userland/Libraries/LibGL/GLMat.cpp | 11 +++++++++++ Userland/Libraries/LibGL/SoftwareGLContext.cpp | 17 +++++++++++++++++ Userland/Libraries/LibGL/SoftwareGLContext.h | 1 + 5 files changed, 32 insertions(+) (limited to 'Userland/Libraries/LibGL') diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index 9979f997cb..76f67d7005 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -79,6 +79,7 @@ GLAPI void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble to GLAPI GLenum glGetError(); GLAPI GLubyte* glGetString(GLenum name); GLAPI void glLoadIdentity(); +GLAPI void glLoadMatrixf(const GLfloat* matrix); GLAPI void glMatrixMode(GLenum mode); GLAPI void glPushMatrix(); GLAPI void glPopMatrix(); diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 48bc94d521..4d6f02a4a2 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -9,6 +9,7 @@ #include "GL/gl.h" #include +#include namespace GL { @@ -25,6 +26,7 @@ public: virtual GLenum gl_get_error() = 0; virtual GLubyte* gl_get_string(GLenum name) = 0; virtual void gl_load_identity() = 0; + virtual void gl_load_matrix(const FloatMatrix4x4& matrix) = 0; virtual void gl_matrix_mode(GLenum mode) = 0; virtual void gl_push_matrix() = 0; virtual void gl_pop_matrix() = 0; diff --git a/Userland/Libraries/LibGL/GLMat.cpp b/Userland/Libraries/LibGL/GLMat.cpp index 18d7b73570..7b0bde969f 100644 --- a/Userland/Libraries/LibGL/GLMat.cpp +++ b/Userland/Libraries/LibGL/GLMat.cpp @@ -35,6 +35,17 @@ void glPopMatrix() g_gl_context->gl_pop_matrix(); } +void glLoadMatrixf(const GLfloat* matrix) +{ + FloatMatrix4x4 mat( + matrix[0], matrix[1], matrix[2], matrix[3], + matrix[4], matrix[5], matrix[6], matrix[7], + matrix[8], matrix[9], matrix[10], matrix[11], + matrix[12], matrix[13], matrix[14], matrix[15]); + + g_gl_context->gl_load_matrix(mat); +} + void glLoadIdentity() { g_gl_context->gl_load_identity(); diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index 0b85ad1778..3dc67eb8cd 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -494,6 +494,23 @@ void SoftwareGLContext::gl_load_identity() m_error = GL_NO_ERROR; } +void SoftwareGLContext::gl_load_matrix(const FloatMatrix4x4& matrix) +{ + if (m_in_draw_state) { + m_error = GL_INVALID_OPERATION; + return; + } + + if (m_current_matrix_mode == GL_PROJECTION) + m_projection_matrix = matrix; + else if (m_current_matrix_mode == GL_MODELVIEW) + m_model_view_matrix = matrix; + else + VERIFY_NOT_REACHED(); + + m_error = GL_NO_ERROR; +} + void SoftwareGLContext::gl_matrix_mode(GLenum mode) { if (m_in_draw_state) { diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h index 33fa7b3feb..54a0cea7a8 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -25,6 +25,7 @@ public: virtual GLenum gl_get_error() override; virtual GLubyte* gl_get_string(GLenum name) override; virtual void gl_load_identity() override; + virtual void gl_load_matrix(const FloatMatrix4x4& matrix) override; virtual void gl_matrix_mode(GLenum mode) override; virtual void gl_push_matrix() override; virtual void gl_pop_matrix() override; -- cgit v1.2.3