- module = &mod;
-
- SL::Compiler compiler;
- compiler.set_source(module->get_prepared_source(), "<module>");
- compiler.specialize(spec_values);
- compiler.compile(SL::Compiler::PROGRAM);
-#ifdef DEBUG
- string diagnostics = compiler.get_diagnostics();
- if(!diagnostics.empty())
- IO::print("Program diagnostics:\n%s\n", diagnostics);
-#endif
-
- vector<SL::Stage::Type> stages = compiler.get_stages();
- for(vector<SL::Stage::Type>::const_iterator i=stages.begin(); i!=stages.end(); ++i)
- {
- GLenum type;
- switch(*i)
- {
- case SL::Stage::VERTEX:
- { static Require _req(ARB_vertex_shader); }
- type = GL_VERTEX_SHADER;
- break;
- case SL::Stage::GEOMETRY:
- { static Require _req(ARB_geometry_shader4); }
- type = GL_GEOMETRY_SHADER;
- break;
- case SL::Stage::FRAGMENT:
- { static Require _req(ARB_fragment_shader); }
- type = GL_FRAGMENT_SHADER;
- break;
- default:
- throw invalid_operation("Program::add_stages");
- }
-
- unsigned stage_id = glCreateShader(type);
- shader_ids.push_back(stage_id);
- glAttachShader(id, stage_id);
-
- string stage_src = compiler.get_stage_glsl(*i);
- const char *src_ptr = stage_src.data();
- int src_len = stage_src.size();
- glShaderSource(stage_id, 1, &src_ptr, &src_len);