+{
+ if(!stage_ids.empty())
+ throw invalid_operation("Program::add_stages");
+
+ switch(mod.get_format())
+ {
+ case Module::GLSL: return add_glsl_stages(static_cast<const GlslModule &>(mod), spec_values);
+ default: throw invalid_argument("Program::add_stages");
+ }
+}
+
+unsigned Program::add_stage(GLenum type)
+{
+ switch(type)
+ {
+ case GL_VERTEX_SHADER: { static Require _req(ARB_vertex_shader); } break;
+ case GL_GEOMETRY_SHADER: { static Require _req(ARB_geometry_shader4); } break;
+ case GL_FRAGMENT_SHADER: { static Require _req(ARB_fragment_shader); } break;
+ default: throw invalid_argument("Program::add_stage");
+ }
+
+ unsigned stage_id = glCreateShader(type);
+ stage_ids.push_back(stage_id);
+ glAttachShader(id, stage_id);
+
+ return stage_id;
+}
+
+void Program::add_glsl_stages(const GlslModule &mod, const map<string, int> &spec_values)