summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@serenityos.org>2022-08-28 10:57:07 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-17 22:39:09 -0700
commit962d088e4e3f03f137e527b75e27cb64d83d5040 (patch)
tree12ec41b8aa5c15bedd2a49413d668c2f956963be /Userland/Libraries/LibGL
parenta0adbfbf81688421998a342dbbc0236e724a570a (diff)
downloadserenity-962d088e4e3f03f137e527b75e27cb64d83d5040.zip
LibGL: Implement glCreateProgram and glDeleteProgram
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r--Userland/Libraries/LibGL/Shader.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGL/Shader.cpp b/Userland/Libraries/LibGL/Shader.cpp
index eb58a38a78..e3b1418040 100644
--- a/Userland/Libraries/LibGL/Shader.cpp
+++ b/Userland/Libraries/LibGL/Shader.cpp
@@ -52,15 +52,25 @@ void GLContext::gl_compile_shader(GLuint shader)
GLuint GLContext::gl_create_program()
{
- dbgln("gl_create_program() unimplemented ");
- TODO();
- return 0;
+ GLuint program_name;
+ m_program_name_allocator.allocate(1, &program_name);
+ auto program = Program::create();
+ m_allocated_programs.set(program_name, program);
+ return program_name;
}
void GLContext::gl_delete_program(GLuint program)
{
- dbgln("gl_delete_program({}) unimplemented ", program);
- TODO();
+ // "A value of 0 for program will be silently ignored." (https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDeleteProgram.xhtml)
+ if (program == 0)
+ return;
+
+ auto it = m_allocated_programs.find(program);
+ RETURN_WITH_ERROR_IF(it == m_allocated_programs.end(), GL_INVALID_VALUE);
+
+ // FIXME: According to the spec, we should only flag the program for deletion here and delete it once it is not used anymore.
+ m_allocated_programs.remove(it);
+ m_program_name_allocator.free(program);
}
void GLContext::gl_attach_shader(GLuint program, GLuint shader)