|
@@ -95,8 +95,16 @@ void GLContext::gl_delete_program(GLuint program)
|
|
|
|
|
|
void GLContext::gl_attach_shader(GLuint program, GLuint shader)
|
|
|
{
|
|
|
- dbgln("gl_attach_shader({}, {}) unimplemented ", program, shader);
|
|
|
- TODO();
|
|
|
+ auto program_it = m_allocated_programs.find(program);
|
|
|
+ auto shader_it = m_allocated_shaders.find(shader);
|
|
|
+ // FIXME: implement check "GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL."
|
|
|
+ RETURN_WITH_ERROR_IF(program_it == m_allocated_programs.end(), GL_INVALID_OPERATION);
|
|
|
+ RETURN_WITH_ERROR_IF(shader_it == m_allocated_shaders.end(), GL_INVALID_OPERATION);
|
|
|
+
|
|
|
+ // NOTE: attach_result is Error if the shader is already attached to this program
|
|
|
+ auto attach_result = program_it->value->attach_shader(*shader_it->value);
|
|
|
+ RETURN_WITH_ERROR_IF(attach_result.is_error() && attach_result.error().is_errno() && attach_result.error().code() == ENOMEM, GL_OUT_OF_MEMORY);
|
|
|
+ RETURN_WITH_ERROR_IF(attach_result.is_error(), GL_INVALID_OPERATION);
|
|
|
}
|
|
|
|
|
|
void GLContext::gl_link_program(GLuint program)
|