-void CommandInterpreter::cmd_trace(const string &args)
-{
- Tracer &tracer = gldbg.get_tracer();
- if(args.empty() || args=="-")
- {
- tracer.set_output(IO::cout);
- IO::print("Tracing to stdout\n");
- }
- else if(args=="on")
- {
- tracer.enable();
- IO::print("Tracing enabled\n");
- }
- else if(args=="off")
- {
- tracer.disable();
- IO::print("Tracing disabled\n");
- }
- else if(args=="end")
- {
- tracer.set_output(0);
- IO::print("Tracing terminated\n");
- }
- else
- {
- tracer.set_output(new IO::File(args, IO::M_WRITE));
- IO::print("Tracing to %s\n", args);
- }
-}
-
-void CommandInterpreter::cmd_state(const string &args)
-{
- const GlState &glstate = gldbg.get_glstate();
- if(args=="vertex")
- {
- IO::print("Current vertex attributes:\n");
- const Vector4 &color = glstate.get_color();
- IO::print(" Color: [%05.3f, %05.3f, %05.3f, %05.3f]\n", color.r, color.g, color.b, color.a);
- for(unsigned i=0; i<8; ++i)
- {
- const Vector4 &texcoord = glstate.get_texcoord(i);
- IO::print(" TexCoord%d: [%05.3f, %05.3f, %05.3f, %05.3f]\n", i, texcoord.s, texcoord.t, texcoord.p, texcoord.q);
- }
- const Vector3 &normal = glstate.get_normal();
- IO::print(" Normal: [%05.3f, %05.3f, %05.3f]\n", normal.x, normal.y, normal.z);
- }
- else if(args=="bind")
- {
- IO::print("Current bindings:\n");
- for(unsigned i=0; i<8; ++i)
- {
- IO::print(" Texture unit %d:\n", i);
- const TexUnitState &unit = glstate.get_texture_unit(i);
- IO::print(" GL_TEXTURE_2D: %s\n", unit.describe_binding(GL_TEXTURE_2D));
- IO::print(" GL_TEXTURE_3D: %s\n", unit.describe_binding(GL_TEXTURE_3D));
- }
- IO::print(" Buffers:\n");
- const BufferState *buf = glstate.get_current_buffer(GL_ARRAY_BUFFER);
- IO::print(" GL_ARRAY_BUFFER: %d\n", (buf ? buf->id : 0));
- buf = glstate.get_current_buffer(GL_ELEMENT_ARRAY_BUFFER);
- IO::print(" GL_ELEMENT_ARRAY_BUFFER: %d\n", (buf ? buf->id : 0));
- }
- else
- throw InvalidParameterValue("Invalid or missing argument");
-}