1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:17:34 +00:00

LibGL: Implement glScalef

This commit is contained in:
Jesse Buhagiar 2021-04-24 22:11:48 +10:00 committed by Andreas Kling
parent 55b3ecfbd3
commit ea0df0b5da
5 changed files with 24 additions and 0 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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) {

View file

@ -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;