summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibGL/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h2
-rw-r--r--Userland/Libraries/LibGL/GLContext.h1
-rw-r--r--Userland/Libraries/LibGL/GLVertexArrays.cpp15
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp14
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h10
6 files changed, 43 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/CMakeLists.txt b/Userland/Libraries/LibGL/CMakeLists.txt
index 81021c2cb1..6cff68532c 100644
--- a/Userland/Libraries/LibGL/CMakeLists.txt
+++ b/Userland/Libraries/LibGL/CMakeLists.txt
@@ -13,6 +13,7 @@ set(SOURCES
GLTexture.cpp
GLUtils.cpp
GLVert.cpp
+ GLVertexArrays.cpp
SoftwareGLContext.cpp
SoftwareRasterizer.cpp
DepthBuffer.cpp
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 7205a63944..9c97c9849c 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -141,6 +141,7 @@ extern "C" {
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
+#define GL_DOUBLE 0x140A
// Format enums
#define GL_COLOR_INDEX 0x1900
@@ -356,6 +357,7 @@ GLAPI void glGetFloatv(GLenum pname, GLfloat* params);
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);
#ifdef __cplusplus
}
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index e542c50816..5bb1e3d1b3 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -66,6 +66,7 @@ public:
virtual void gl_depth_mask(GLboolean flag) = 0;
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 present() = 0;
};
diff --git a/Userland/Libraries/LibGL/GLVertexArrays.cpp b/Userland/Libraries/LibGL/GLVertexArrays.cpp
new file mode 100644
index 0000000000..2f322e1772
--- /dev/null
+++ b/Userland/Libraries/LibGL/GLVertexArrays.cpp
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include "GL/gl.h"
+#include "GLContext.h"
+
+extern GL::GLContext* g_gl_context;
+
+void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer)
+{
+ g_gl_context->gl_vertex_pointer(size, type, stride, pointer);
+}
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index c87e5016a2..f9e0500a92 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -1447,6 +1447,20 @@ void SoftwareGLContext::gl_disable_client_state(GLenum cap)
}
}
+void SoftwareGLContext::gl_vertex_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 == 1 || size == 2 || size == 4), GL_INVALID_VALUE);
+ RETURN_WITH_ERROR_IF(!(type == GL_SHORT || type == GL_INT || type == GL_FLOAT || type == GL_DOUBLE), GL_INVALID_ENUM);
+ RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE);
+
+ m_client_vertex_pointer.size = size;
+ m_client_vertex_pointer.type = type;
+ m_client_vertex_pointer.stride = stride;
+ m_client_vertex_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 b2a75fabd3..252dc86435 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -76,6 +76,7 @@ public:
virtual void gl_depth_mask(GLboolean flag) override;
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 present() override;
@@ -223,6 +224,15 @@ private:
GLenum mode { GL_COMPILE };
};
Optional<CurrentListing> m_current_listing_index;
+
+ struct VertexAttribPointer {
+ GLint size { 4 };
+ GLenum type { GL_FLOAT };
+ GLsizei stride { 0 };
+ const void* pointer { 0 };
+ };
+
+ VertexAttribPointer m_client_vertex_pointer;
};
}