Integrate Perfetto with Godot-CPP

This change adds an example on how to integrate Perfetto
with Godot-CPP projects.
pull/830/head
Gergely Kis 2022-09-05 23:11:09 +02:00
parent 02333f8dae
commit bab94a5120
3 changed files with 11 additions and 0 deletions

View File

@ -179,6 +179,7 @@ opts.Add(
)
opts.Add(BoolVariable("build_library", "Build the godot-cpp library.", True))
opts.Add(PathVariable("perfetto", "Path to the perfetto include directory in the Godot Engine source", None, PathVariable.PathIsDir))
opts.Update(env)
Help(opts.GenerateHelpText(env))

View File

@ -6,6 +6,10 @@ env = SConscript("../SConstruct")
env.Append(CPPPATH=['src/'])
sources = Glob('src/*.cpp')
if env["perfetto"]:
env.Append(CPPDEFINES=["ENABLE_PERFETTO"])
env.Append(CPPPATH=[env["perfetto"]])
library = env.SharedLibrary(
"bin/libgdexample.{}.{}.{}{}".format(
env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"]

View File

@ -31,6 +31,8 @@
#include <Godot.hpp>
#include <Reference.hpp>
#include "godot_profiler.h"
using namespace godot;
class SimpleClass : public Reference {
@ -41,15 +43,18 @@ public:
/** `_init` must exist as it is called by Godot. */
void _init() {
TRACE_EVENT("app_main", "SimpleClass::_init");
_name = String("SimpleClass");
_value = 0;
}
void test_void_method() {
TRACE_EVENT("app_main", "SimpleClass::test_void_method");
Godot::print("This is test");
}
Variant method(Variant arg) {
TRACE_EVENT("app_main", "SimpleClass::method");
Variant ret;
ret = arg;
@ -57,6 +62,7 @@ public:
}
static void _register_methods() {
TRACE_EVENT("app_main", "_register_methods");
register_method("method", &SimpleClass::method);
/**