1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

LibGL: Implement glCreateShader and glDeleteShader

This commit is contained in:
Stephan Unverwerth 2022-08-28 10:51:37 +02:00 committed by Andrew Kaster
parent b975569a40
commit a0adbfbf81
3 changed files with 31 additions and 5 deletions

View file

@ -11,15 +11,31 @@ namespace GL {
GLuint GLContext::gl_create_shader(GLenum shader_type)
{
dbgln("gl_create_shader({}) unimplemented ", shader_type);
TODO();
return 0;
// FIXME: Add support for GL_COMPUTE_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER and GL_GEOMETRY_SHADER.
RETURN_VALUE_WITH_ERROR_IF(shader_type != GL_VERTEX_SHADER
&& shader_type != GL_FRAGMENT_SHADER,
GL_INVALID_ENUM,
0);
GLuint shader_name;
m_shader_name_allocator.allocate(1, &shader_name);
auto shader = Shader::create(shader_type);
m_allocated_shaders.set(shader_name, shader);
return shader_name;
}
void GLContext::gl_delete_shader(GLuint shader)
{
dbgln("gl_delete_shader({}) unimplemented ", shader);
TODO();
// "A value of 0 for shader will be silently ignored." (https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDeleteShader.xhtml)
if (shader == 0)
return;
auto it = m_allocated_shaders.find(shader);
RETURN_WITH_ERROR_IF(it == m_allocated_shaders.end(), GL_INVALID_VALUE);
// FIXME: According to the spec, we should only flag the shader for deletion here and delete it once it is detached from all programs.
m_allocated_shaders.remove(it);
m_shader_name_allocator.free(shader);
}
void GLContext::gl_shader_source(GLuint shader, GLsizei count, GLchar const** string, GLint const* length)