-}
-
-void Program::compile_glsl_stage(unsigned stage_id)
-{
- glCompileShader(stage_id);
- bool compiled = get_shader_i(stage_id, GL_COMPILE_STATUS);
-
- GLsizei info_log_len = get_shader_i(stage_id, GL_INFO_LOG_LENGTH);
- string info_log(info_log_len+1, 0);
- glGetShaderInfoLog(stage_id, info_log_len+1, &info_log_len, &info_log[0]);
- info_log.erase(info_log_len);
- if(module && module->get_format()==Module::GLSL)
- info_log = static_cast<const GlslModule *>(module)->get_source_map().translate_errors(info_log);
-
- if(!compiled)
- throw compile_error(info_log);
-#ifdef DEBUG
- if(!info_log.empty())
- IO::print("Shader compile info log:\n%s", info_log);
-#endif
-}
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-void Program::attach_shader(Shader &shader)
-{
- unsigned shader_id = shader.steal_id();
- if(!shader_id)
- throw invalid_argument("Program::attach_shader");
- stage_ids.push_back(shader_id);
- compile_glsl_stage(shader_id);
-}
-
-void Program::attach_shader_owned(Shader *shader)
-{
- attach_shader(*shader);
- delete shader;
-}
-
-void Program::detach_shader(Shader &)
-{
-}
-
-const vector<Shader *> &Program::get_attached_shaders() const
-{
- static vector<Shader *> dummy;
- return dummy;
-}
-
-void Program::bind_attribute(unsigned index, const string &name)
-{
- static Require _req(ARB_vertex_shader);
- glBindAttribLocation(id, index, name.c_str());
-}
-
-void Program::bind_attribute(VertexAttribute attr, const string &name)
-{
- bind_attribute(get_attribute_semantic(attr), name);
-}
-
-void Program::bind_fragment_data(unsigned index, const string &name)
-{
- static Require _req(EXT_gpu_shader4);
- glBindFragDataLocation(id, index, name.c_str());
-}
-#pragma GCC diagnostic pop
-
-void Program::link()
-{
- if(stage_ids.empty())
- throw invalid_operation("Program::link");
-
- uniforms.clear();
-
- glLinkProgram(id);
- linked = get_program_i(id, GL_LINK_STATUS);
-
- GLsizei info_log_len = get_program_i(id, GL_INFO_LOG_LENGTH);
- string info_log(info_log_len+1, 0);
- glGetProgramInfoLog(id, info_log_len+1, &info_log_len, &info_log[0]);
- info_log.erase(info_log_len);
- if(module && module->get_format()==Module::GLSL)
- info_log = static_cast<const GlslModule *>(module)->get_source_map().translate_errors(info_log);
-
- if(!linked)
- throw compile_error(info_log);
-#ifdef DEBUG
- if(!info_log.empty())
- IO::print("Program link info log:\n%s", info_log);
-#endif
-
- query_uniforms();
- query_attributes();
-
- for(UniformMap::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
- require_type(i->second.type);
- for(AttributeMap::const_iterator i=attributes.begin(); i!=attributes.end(); ++i)
- require_type(i->second.type);
-}
-
-void Program::query_uniforms()
-{
- unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS);
- vector<UniformInfo *> uniforms_by_index(count);
- for(unsigned i=0; i<count; ++i)