Quellcode durchsuchen

LibGL: Implement glLinkProgram

Stephan Unverwerth vor 2 Jahren
Ursprung
Commit
fdd76639d8

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

@@ -109,8 +109,13 @@ void GLContext::gl_attach_shader(GLuint program, GLuint shader)
 
 void GLContext::gl_link_program(GLuint program)
 {
-    dbgln("gl_link_program({}) unimplemented ", program);
-    TODO();
+    auto program_it = m_allocated_programs.find(program);
+    // FIXME: implement check "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."
+    RETURN_WITH_ERROR_IF(program_it == m_allocated_programs.end(), GL_INVALID_OPERATION);
+    // FIXME: implement check "GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active."
+
+    // NOTE: We are ignoring the link result since this is tracked inside the program object
+    (void)program_it->value->link();
 }
 
 }

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

@@ -21,8 +21,10 @@ public:
     bool is_shader_attached(Shader const&) const;
     ErrorOr<void> attach_shader(Shader&);
     ErrorOr<void> link();
+    bool link_status() const { return m_link_status; }
 
 private:
+    bool m_link_status { false };
     Vector<NonnullRefPtr<Shader>> m_vertex_shaders;
     Vector<NonnullRefPtr<Shader>> m_fragment_shaders;
 };