From 03258f4c96c671bb6132e78a6ebcac434d72907b Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sat, 15 Oct 2022 22:50:32 +0200 Subject: [PATCH] LibGL: Add buffer API stubs No implemented functionality, but this makes it easier to see if software is using this family of functions. --- Userland/Libraries/LibGL/Buffer.cpp | 42 ++++++++++++++++++++++++ Userland/Libraries/LibGL/CMakeLists.txt | 1 + Userland/Libraries/LibGL/GL/gl.h | 6 +++- Userland/Libraries/LibGL/GL/glplatform.h | 2 ++ Userland/Libraries/LibGL/GLAPI.cpp | 25 ++++++++++++++ Userland/Libraries/LibGL/GLContext.h | 5 +++ 6 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 Userland/Libraries/LibGL/Buffer.cpp diff --git a/Userland/Libraries/LibGL/Buffer.cpp b/Userland/Libraries/LibGL/Buffer.cpp new file mode 100644 index 00000000000..c088830eea7 --- /dev/null +++ b/Userland/Libraries/LibGL/Buffer.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022, Jelle Raaijmakers + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +namespace GL { + +void GLContext::gl_bind_buffer(GLenum target, GLuint buffer) +{ + // FIXME: implement me + dbgln_if(GL_DEBUG, "{}({:#x}, {})): unimplemented", __FUNCTION__, target, buffer); +} + +void GLContext::gl_buffer_data(GLenum target, GLsizeiptr size, void const* data, GLenum usage) +{ + // FIXME: implement me + dbgln_if(GL_DEBUG, "{}({:#x}, {}, {:p}, {:#x}): unimplemented", __FUNCTION__, target, size, data, usage); +} + +void GLContext::gl_buffer_sub_data(GLenum target, GLintptr offset, GLsizeiptr size, void const* data) +{ + // FIXME: implement me + dbgln_if(GL_DEBUG, "{}({:#x}, {}, {}, {:p}): unimplemented", __FUNCTION__, target, offset, size, data); +} + +void GLContext::gl_delete_buffers(GLsizei n, GLuint const* buffers) +{ + // FIXME: implement me + dbgln_if(GL_DEBUG, "{}({}, {:p}): unimplemented", __FUNCTION__, n, buffers); +} + +void GLContext::gl_gen_buffers(GLsizei n, GLuint* buffers) +{ + // FIXME: implement me + dbgln_if(GL_DEBUG, "{}({}, {:p}): unimplemented", __FUNCTION__, n, buffers); +} + +} diff --git a/Userland/Libraries/LibGL/CMakeLists.txt b/Userland/Libraries/LibGL/CMakeLists.txt index bbaf8ab13b5..863ac2d0709 100644 --- a/Userland/Libraries/LibGL/CMakeLists.txt +++ b/Userland/Libraries/LibGL/CMakeLists.txt @@ -1,4 +1,5 @@ set(SOURCES + Buffer.cpp ClipPlane.cpp ContextParameter.cpp GLAPI.cpp diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index de5ec402cb3..74938b6c99c 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -718,7 +718,6 @@ GLAPI void glEnableClientState(GLenum cap); GLAPI void glDisableClientState(GLenum cap); GLAPI void glClientActiveTextureARB(GLenum target); GLAPI void glClientActiveTexture(GLenum target); - GLAPI void glVertexPointer(GLint size, GLenum type, GLsizei stride, void const* pointer); GLAPI void glColorPointer(GLint size, GLenum type, GLsizei stride, void const* pointer); GLAPI void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, void const* pointer); @@ -794,6 +793,11 @@ GLAPI void glClipPlane(GLenum plane, GLdouble const* equation); GLAPI void glGetClipPlane(GLenum plane, GLdouble* equation); GLAPI void glArrayElement(GLint i); GLAPI void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void glBindBuffer(GLenum target, GLuint buffer); +GLAPI void glBufferData(GLenum target, GLsizeiptr size, void const* data, GLenum usage); +GLAPI void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void const* data); +GLAPI void glDeleteBuffers(GLsizei n, GLuint const* buffers); +GLAPI void glGenBuffers(GLsizei n, GLuint* buffers); #ifdef __cplusplus } diff --git a/Userland/Libraries/LibGL/GL/glplatform.h b/Userland/Libraries/LibGL/GL/glplatform.h index c637b54348b..e57f6edd4c6 100644 --- a/Userland/Libraries/LibGL/GL/glplatform.h +++ b/Userland/Libraries/LibGL/GL/glplatform.h @@ -28,9 +28,11 @@ typedef unsigned char GLboolean; typedef short GLshort; typedef unsigned short GLushort; typedef int GLint; +typedef long GLintptr; typedef unsigned int GLuint; typedef int GLfixed; typedef int GLsizei; +typedef unsigned long GLsizeiptr; typedef void GLvoid; typedef float GLfloat; typedef double GLclampd; diff --git a/Userland/Libraries/LibGL/GLAPI.cpp b/Userland/Libraries/LibGL/GLAPI.cpp index 201a54454a7..6b978904e22 100644 --- a/Userland/Libraries/LibGL/GLAPI.cpp +++ b/Userland/Libraries/LibGL/GLAPI.cpp @@ -67,6 +67,11 @@ void glBegin(GLenum mode) g_gl_context->gl_begin(mode); } +void glBindBuffer(GLenum target, GLuint buffer) +{ + g_gl_context->gl_bind_buffer(target, buffer); +} + void glBindTexture(GLenum target, GLuint texture) { g_gl_context->gl_bind_texture(target, texture); @@ -82,6 +87,16 @@ void glBlendFunc(GLenum sfactor, GLenum dfactor) return g_gl_context->gl_blend_func(sfactor, dfactor); } +void glBufferData(GLenum target, GLsizeiptr size, void const* data, GLenum usage) +{ + g_gl_context->gl_buffer_data(target, size, data, usage); +} + +void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void const* data) +{ + g_gl_context->gl_buffer_sub_data(target, offset, size, data); +} + void glCallList(GLuint list) { return g_gl_context->gl_call_list(list); @@ -226,6 +241,11 @@ void glCullFace(GLenum mode) g_gl_context->gl_cull_face(mode); } +void glDeleteBuffers(GLsizei n, GLuint const* buffers) +{ + g_gl_context->gl_delete_buffers(n, buffers); +} + void glDepthFunc(GLenum func) { g_gl_context->gl_depth_func(func); @@ -384,6 +404,11 @@ void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLd g_gl_context->gl_frustum(left, right, bottom, top, nearVal, farVal); } +void glGenBuffers(GLsizei n, GLuint* buffers) +{ + g_gl_context->gl_gen_buffers(n, buffers); +} + GLuint glGenLists(GLsizei range) { return g_gl_context->gl_gen_lists(range); diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index e068094ba26..02c3bc52373 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -213,6 +213,11 @@ public: void gl_array_element(GLint i); void gl_copy_tex_sub_image_2d(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); void gl_point_size(GLfloat size); + void gl_bind_buffer(GLenum target, GLuint buffer); + void gl_buffer_data(GLenum target, GLsizeiptr size, void const* data, GLenum usage); + void gl_buffer_sub_data(GLenum target, GLintptr offset, GLsizeiptr size, void const* data); + void gl_delete_buffers(GLsizei n, GLuint const* buffers); + void gl_gen_buffers(GLsizei n, GLuint* buffers); private: void sync_device_config();