summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
diff options
context:
space:
mode:
authorJesse Buhagiar <jooster669@gmail.com>2021-04-24 22:11:48 +1000
committerAndreas Kling <kling@serenityos.org>2021-05-08 10:13:22 +0200
commitea0df0b5da0247108bc7fe3c6a7c23f709802ef2 (patch)
treec8be0b1dfe54af95867a3ee02ec603e140f2fd58 /Userland/Libraries/LibGL
parent55b3ecfbd3b5d3dc363c3e72aeb3d9183b575b22 (diff)
downloadserenity-ea0df0b5da0247108bc7fe3c6a7c23f709802ef2.zip
LibGL: Implement glScalef
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h1
-rw-r--r--Userland/Libraries/LibGL/GLContext.h1
-rw-r--r--Userland/Libraries/LibGL/GLVert.cpp5
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp16
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h1
5 files changed, 24 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 9dfaefec82..9979f997cb 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -83,6 +83,7 @@ GLAPI void glMatrixMode(GLenum mode);
GLAPI void glPushMatrix();
GLAPI void glPopMatrix();
GLAPI void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void glScalef(GLfloat x, GLfloat y, GLfloat z);
GLAPI void glTranslatef(GLfloat x, GLfloat y, GLfloat z);
GLAPI void glVertex3f(GLfloat x, GLfloat y, GLfloat z);
GLAPI void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index 8e00018b25..48bc94d521 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -29,6 +29,7 @@ public:
virtual void gl_push_matrix() = 0;
virtual void gl_pop_matrix() = 0;
virtual void gl_rotate(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) = 0;
+ virtual void gl_scale(GLdouble x, GLdouble y, GLdouble z) = 0;
virtual void gl_translate(GLdouble x, GLdouble y, GLdouble z) = 0;
virtual void gl_vertex(GLdouble x, GLdouble y, GLdouble z, GLdouble w) = 0;
virtual void gl_viewport(GLint x, GLint y, GLsizei width, GLsizei height) = 0;
diff --git a/Userland/Libraries/LibGL/GLVert.cpp b/Userland/Libraries/LibGL/GLVert.cpp
index 394c39861f..e972741327 100644
--- a/Userland/Libraries/LibGL/GLVert.cpp
+++ b/Userland/Libraries/LibGL/GLVert.cpp
@@ -30,6 +30,11 @@ void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
g_gl_context->gl_rotate(angle, x, y, z);
}
+void glScalef(GLfloat x, GLfloat y, GLfloat z)
+{
+ g_gl_context->gl_scale(x, y, z);
+}
+
void glTranslatef(GLfloat x, GLfloat y, GLfloat z)
{
g_gl_context->gl_translate(x, y, z);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index c6b54c40ef..0b85ad1778 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -594,6 +594,22 @@ void SoftwareGLContext::gl_rotate(GLdouble angle, GLdouble x, GLdouble y, GLdoub
m_error = GL_NO_ERROR;
}
+void SoftwareGLContext::gl_scale(GLdouble x, GLdouble y, GLdouble z)
+{
+ if (m_in_draw_state) {
+ m_error = GL_INVALID_OPERATION;
+ return;
+ }
+
+ if (m_current_matrix_mode == GL_MODELVIEW) {
+ m_model_view_matrix = m_model_view_matrix * FloatMatrix4x4::scale({ static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) });
+ } else if (m_current_matrix_mode == GL_PROJECTION) {
+ m_projection_matrix = m_projection_matrix * FloatMatrix4x4::scale({ static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) });
+ }
+
+ m_error = GL_NO_ERROR;
+}
+
void SoftwareGLContext::gl_translate(GLdouble x, GLdouble y, GLdouble z)
{
if (m_in_draw_state) {
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 58bb859867..33fa7b3feb 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -29,6 +29,7 @@ public:
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_scale(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;