]> git.tdb.fi Git - gldbg.git/blobdiff - source/commandinterpreter.cpp
Add a performance profiler
[gldbg.git] / source / commandinterpreter.cpp
index abc9dda60b07bc83d5125eac1612f8096d5e25eb..c684979bae2061b49f9fddd06a8cead8c381e9d6 100644 (file)
@@ -57,6 +57,11 @@ CommandInterpreter::CommandInterpreter(GlDbg &d):
                "trace end\n"
                "  Terminate trace, closing the file.\n");
 
+       commands["profile"] = Command(&CommandInterpreter::cmd_profile,
+               "Profiles GL usage and performance",
+               "profile {on|off}\n"
+               "  Enables or disables profiling\n");
+
        commands["state"] = Command(&CommandInterpreter::cmd_state,
                "Inspects general GL state",
                "state vertex\n"
@@ -202,6 +207,17 @@ void CommandInterpreter::cmd_trace(const string &args)
        }
 }
 
+void CommandInterpreter::cmd_profile(const string &args)
+{
+       Profiler &profiler = gldbg.get_profiler();
+       if(args.empty() || args=="on")
+               profiler.enable();
+       else if(args=="off")
+               profiler.disable();
+       else
+               throw InvalidParameterValue("Invalid argument");
+}
+
 void CommandInterpreter::cmd_state(const string &args)
 {
        const GlState &glstate = gldbg.get_glstate();