+
+void Inspector::cmd_shader(const string &args)
+{
+ if(args.empty())
+ {
+ const GlState::ShaderMap &shaders = state.get_shaders();
+ printf("%lu shader objects:\n", shaders.size());
+ for(GlState::ShaderMap::const_iterator i=shaders.begin(); i!=shaders.end(); ++i)
+ {
+ string descr = i->second.describe();
+ printf(" %d: %s\n", i->first, descr.c_str());
+ }
+ }
+ else
+ {
+ char *end = 0;
+ unsigned id = strtoul(args.c_str(), &end, 0);
+ if(end && *end)
+ throw runtime_error("Invalid shader id");
+
+ const ShaderState &shader = state.get_shader(id);
+ printf("Shader %d:\n", shader.id);
+ printf(" Type: %s\n", describe_enum(shader.type, ""));
+ unsigned n = 0;
+ for(vector<string>::const_iterator i=shader.source.begin(); i!=shader.source.end(); ++i, ++n)
+ {
+ printf(" Source string %d:\n", n);
+ print_indented(*i, 4);
+ }
+ if(shader.source_changed)
+ printf(" Source changed since last compile\n");
+ printf(" Compile status: %d\n", shader.compile_status);
+ if(shader.info_log.empty())
+ printf(" Info log is empty\n");
+ else
+ {
+ printf(" Info log:\n");
+ print_indented(shader.info_log, 4);
+ }
+ if(shader.pending_delete)
+ printf(" Pending deletion\n");
+ }
+}
+
+void Inspector::cmd_program(const std::string &args)
+{
+ if(args.empty())
+ {
+ const GlState::ProgramMap &programs = state.get_programs();
+ printf("%lu program objects:\n", programs.size());
+ for(GlState::ProgramMap::const_iterator i=programs.begin(); i!=programs.end(); ++i)
+ {
+ string descr = i->second.describe();
+ printf(" %d: %s\n", i->first, descr.c_str());
+ }
+ }
+ else
+ {
+ char *end = 0;
+ unsigned id = strtoul(args.c_str(), &end, 0);
+ if(end && *end)
+ throw runtime_error("Invalid program id");
+
+ const ProgramState &program = state.get_program(id);
+ printf("Program %d:\n", program.id);
+ printf(" Attached shaders:\n");
+ for(vector<ShaderState *>::const_iterator i=program.shaders.begin(); i!=program.shaders.end(); ++i)
+ {
+ string descr = (*i)->describe();
+ printf(" %d: %s\n", (*i)->id, descr.c_str());
+ }
+ if(program.shaders_changed)
+ printf(" Shaders changed since last compile\n");
+ printf(" Link status: %d\n", program.link_status);
+ if(program.info_log.empty())
+ printf(" Info log is empty\n");
+ else
+ {
+ printf(" Info log:\n");
+ print_indented(program.info_log, 4);
+ }
+ }
+}