ProgramObjectPtr StandardPrograms::compile(const GraphicContextPtr &gc, const void *vertex_code, int vertex_code_size, const void *fragment_code, int fragment_code_size) { auto vertex_shader = ShaderObject::create(gc, ShaderType::vertex, vertex_code, vertex_code_size); if (!vertex_shader->try_compile()) throw Exception(string_format("Unable to compile standard vertex shader: %1", vertex_shader->info_log())); auto fragment_shader = ShaderObject::create(gc, ShaderType::fragment, fragment_code, fragment_code_size); if (!fragment_shader->try_compile()) throw Exception(string_format("Unable to compile standard fragment shader: %1", fragment_shader->info_log())); auto program = ProgramObject::create(gc); program->attach(vertex_shader); program->attach(fragment_shader); return program; }
void compile() { try_compile(); if (!compiled()) throw gl_error{"gl::compile_shader", "Unable to compile shader:\n" + log()}; }