瀏覽代碼

LibGL: Implement glCompileShader

Stephan Unverwerth 2 年之前
父節點
當前提交
42ef5c9e12
共有 2 個文件被更改,包括 8 次插入2 次删除
  1. 6 2
      Userland/Libraries/LibGL/Shader.cpp
  2. 2 0
      Userland/Libraries/LibGL/Shaders/Shader.h

+ 6 - 2
Userland/Libraries/LibGL/Shader.cpp

@@ -62,8 +62,12 @@ void GLContext::gl_shader_source(GLuint shader, GLsizei count, GLchar const** st
 
 
 void GLContext::gl_compile_shader(GLuint shader)
 void GLContext::gl_compile_shader(GLuint shader)
 {
 {
-    dbgln("gl_compile_shader({}) unimplemented ", shader);
-    TODO();
+    auto it = m_allocated_shaders.find(shader);
+    // FIXME: implement check "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."
+    RETURN_WITH_ERROR_IF(it == m_allocated_shaders.end(), GL_INVALID_OPERATION);
+
+    // NOTE: We are ignoring the compilation result here since it is tracked inside the shader object
+    (void)it->value->compile();
 }
 }
 
 
 GLuint GLContext::gl_create_program()
 GLuint GLContext::gl_create_program()

+ 2 - 0
Userland/Libraries/LibGL/Shaders/Shader.h

@@ -24,6 +24,7 @@ public:
     ErrorOr<void> add_source(StringView source_code);
     ErrorOr<void> add_source(StringView source_code);
     ErrorOr<void> compile();
     ErrorOr<void> compile();
     GLenum type() const { return m_type; }
     GLenum type() const { return m_type; }
+    bool compile_status() const { return m_compile_status; }
 
 
 private:
 private:
     explicit Shader(GLenum shader_type)
     explicit Shader(GLenum shader_type)
@@ -33,6 +34,7 @@ private:
 
 
     Vector<String> m_sources;
     Vector<String> m_sources;
     GLenum m_type;
     GLenum m_type;
+    bool m_compile_status { false };
 };
 };
 
 
 }
 }