mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
LibGL: Implement glCreateShader and glDeleteShader
This commit is contained in:
parent
b975569a40
commit
a0adbfbf81
3 changed files with 31 additions and 5 deletions
|
@ -600,6 +600,9 @@ extern "C" {
|
|||
#define GL_DYNAMIC_DRAW 0x88e8
|
||||
#define GL_DYNAMIC_READ 0x88e9
|
||||
#define GL_DYNAMIC_COPY 0x88ea
|
||||
// Programmable pipeline
|
||||
#define GL_FRAGMENT_SHADER 0x8B30
|
||||
#define GL_VERTEX_SHADER 0x8B31
|
||||
|
||||
GLAPI void glBegin(GLenum mode);
|
||||
GLAPI void glClear(GLbitfield mask);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibGL/Buffer/Buffer.h>
|
||||
#include <LibGL/NameAllocator.h>
|
||||
#include <LibGL/Shaders/Program.h>
|
||||
#include <LibGL/Shaders/Shader.h>
|
||||
#include <LibGL/Tex/Texture.h>
|
||||
#include <LibGL/Tex/TextureUnit.h>
|
||||
#include <LibGPU/Device.h>
|
||||
|
@ -408,6 +410,11 @@ private:
|
|||
bool m_sampler_config_is_dirty { true };
|
||||
bool m_light_state_is_dirty { true };
|
||||
|
||||
NameAllocator m_shader_name_allocator;
|
||||
NameAllocator m_program_name_allocator;
|
||||
HashMap<GLuint, RefPtr<Shader>> m_allocated_shaders;
|
||||
HashMap<GLuint, RefPtr<Program>> m_allocated_programs;
|
||||
|
||||
struct Listing {
|
||||
|
||||
template<typename F>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue