summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@serenityos.org>2021-08-13 13:16:00 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-14 12:49:29 +0200
commitf52f40925ce891cdaac7c78ecec122f1003d87fe (patch)
treee6bec311be9973abe56f3cc14b4578c8190d1227
parent07b9cba6e6aaa5baed9ae841890f477758a059f8 (diff)
downloadserenity-f52f40925ce891cdaac7c78ecec122f1003d87fe.zip
LibGL: Implement glColorPointer
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h1
-rw-r--r--Userland/Libraries/LibGL/GLContext.h1
-rw-r--r--Userland/Libraries/LibGL/GLVertexArrays.cpp5
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp24
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h2
5 files changed, 33 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 9c97c9849c..08f1b584ae 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -358,6 +358,7 @@ GLAPI void glDepthMask(GLboolean flag);
GLAPI void glEnableClientState(GLenum cap);
GLAPI void glDisableClientState(GLenum cap);
GLAPI void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);
+GLAPI void glColorPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);
#ifdef __cplusplus
}
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index 5bb1e3d1b3..b1563fcc24 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -67,6 +67,7 @@ public:
virtual void gl_enable_client_state(GLenum cap) = 0;
virtual void gl_disable_client_state(GLenum cap) = 0;
virtual void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;
+ virtual void gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;
virtual void present() = 0;
};
diff --git a/Userland/Libraries/LibGL/GLVertexArrays.cpp b/Userland/Libraries/LibGL/GLVertexArrays.cpp
index 2f322e1772..a34548b70d 100644
--- a/Userland/Libraries/LibGL/GLVertexArrays.cpp
+++ b/Userland/Libraries/LibGL/GLVertexArrays.cpp
@@ -13,3 +13,8 @@ void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointe
{
g_gl_context->gl_vertex_pointer(size, type, stride, pointer);
}
+
+void glColorPointer(GLint size, GLenum type, GLsizei stride, const void* pointer)
+{
+ g_gl_context->gl_color_pointer(size, type, stride, pointer);
+}
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index f9e0500a92..75bcbabddd 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -1461,6 +1461,30 @@ void SoftwareGLContext::gl_vertex_pointer(GLint size, GLenum type, GLsizei strid
m_client_vertex_pointer.pointer = pointer;
}
+void SoftwareGLContext::gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer)
+{
+ RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
+
+ RETURN_WITH_ERROR_IF(!(size == 3 || size == 4), GL_INVALID_VALUE);
+
+ RETURN_WITH_ERROR_IF(!(type == GL_BYTE
+ || type == GL_UNSIGNED_BYTE
+ || type == GL_SHORT
+ || type == GL_UNSIGNED_SHORT
+ || type == GL_INT
+ || type == GL_UNSIGNED_INT
+ || type == GL_FLOAT
+ || type == GL_DOUBLE),
+ GL_INVALID_ENUM);
+
+ RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE);
+
+ m_client_color_pointer.size = size;
+ m_client_color_pointer.type = type;
+ m_client_color_pointer.stride = stride;
+ m_client_color_pointer.pointer = pointer;
+}
+
void SoftwareGLContext::present()
{
m_rasterizer.blit_to(*m_frontbuffer);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 252dc86435..45c472b05e 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -77,6 +77,7 @@ public:
virtual void gl_enable_client_state(GLenum cap) override;
virtual void gl_disable_client_state(GLenum cap) override;
virtual void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;
+ virtual void gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;
virtual void present() override;
@@ -233,6 +234,7 @@ private:
};
VertexAttribPointer m_client_vertex_pointer;
+ VertexAttribPointer m_client_color_pointer;
};
}