summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2021-12-24 14:53:32 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-27 11:58:43 +0100
commitd83702cb920fe29bf5efaa48e229ad6a6d9bf90e (patch)
tree71a4f45fb55e37927f9dfc362cea62cca79f8541 /Userland/Libraries/LibGL
parent4a36d6b4390f9a45a75cbae68e2e0f0f20b76449 (diff)
downloadserenity-d83702cb920fe29bf5efaa48e229ad6a6d9bf90e.zip
LibGL: Implement `glRectf` and `glRecti`
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h2
-rw-r--r--Userland/Libraries/LibGL/GLContext.h1
-rw-r--r--Userland/Libraries/LibGL/GLVert.cpp10
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp13
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h5
5 files changed, 30 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index e492f8acea..e093315851 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -578,6 +578,8 @@ GLAPI void glPushAttrib(GLbitfield mask);
GLAPI void glPopAttrib();
GLAPI void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap);
GLAPI void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
+GLAPI void glRecti(GLint x1, GLint y1, GLint x2, GLint y2);
#ifdef __cplusplus
}
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index 386aa9421f..d52edd1216 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -116,6 +116,7 @@ public:
virtual void gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = 0;
virtual void gl_bitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap) = 0;
virtual void gl_copy_tex_image_2d(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = 0;
+ virtual void gl_rect(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) = 0;
virtual void present() = 0;
};
diff --git a/Userland/Libraries/LibGL/GLVert.cpp b/Userland/Libraries/LibGL/GLVert.cpp
index 453c28b788..31c82b5eb2 100644
--- a/Userland/Libraries/LibGL/GLVert.cpp
+++ b/Userland/Libraries/LibGL/GLVert.cpp
@@ -164,3 +164,13 @@ void glNormal3fv(GLfloat const* v)
{
g_gl_context->gl_normal(v[0], v[1], v[2]);
}
+
+void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+{
+ g_gl_context->gl_rect(x1, y1, x2, y2);
+}
+
+void glRecti(GLint x1, GLint y1, GLint x2, GLint y2)
+{
+ g_gl_context->gl_rect(x1, y1, x2, y2);
+}
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index d786b2f01d..66731b2fcc 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -2658,6 +2658,19 @@ void SoftwareGLContext::gl_copy_tex_image_2d(GLenum target, GLint level, GLenum
target, level, internalformat, x, y, width, height, border);
}
+void SoftwareGLContext::gl_rect(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
+{
+ APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_rect, x1, y1, x2, y2);
+ RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
+
+ gl_begin(GL_POLYGON);
+ gl_vertex(x1, y1, 0.0, 0.0);
+ gl_vertex(x2, y1, 0.0, 0.0);
+ gl_vertex(x2, y2, 0.0, 0.0);
+ gl_vertex(x1, y2, 0.0, 0.0);
+ gl_end();
+}
+
void SoftwareGLContext::present()
{
m_rasterizer.blit_to(*m_frontbuffer);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 042a491652..6baecd197c 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -129,6 +129,8 @@ public:
virtual void gl_light_model(GLenum pname, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override;
virtual void gl_bitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap) override;
virtual void gl_copy_tex_image_2d(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) override;
+ virtual void gl_rect(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) override;
+
virtual void present() override;
private:
@@ -312,7 +314,8 @@ private:
decltype(&SoftwareGLContext::gl_pop_attrib),
decltype(&SoftwareGLContext::gl_light_model),
decltype(&SoftwareGLContext::gl_bitmap),
- decltype(&SoftwareGLContext::gl_copy_tex_image_2d)>;
+ decltype(&SoftwareGLContext::gl_copy_tex_image_2d),
+ decltype(&SoftwareGLContext::gl_rect)>;
using ExtraSavedArguments = Variant<
FloatMatrix4x4>;