-
Notifications
You must be signed in to change notification settings - Fork 385
Description
Hello!
I am having some trouble integrating the debugger in my engine, and I have a few solutions but I'm unsure which one makes the most sense from the perspective of RmlUi's philosophy.
For starters, in my engine I can have one RmlUi context per camera, which means that at any given moment I could have no context at all, or multiple contexts at once. This does not seem to play well at all with the way the debugger works. The debugger can be initialized with a context, which will become its host context, and then it can either debug its own host context or any other context. However, as soon as the host context for the debugger is released, it seems impossible to make use of the debugger again, since Rml::Debugger::Initialise will fail because the plugin already exists, and Rml::Debugger::SetContext will only change the context to be debugged. In any case it ends up crashing when trying to use the debugger.
Here are the solutions I found (from more involved on my side to more involved on RmlUi's side):
- Create a completely separate context which is always live, specifically for the debugger. This seems pretty neat on the surface and it does play well with the singleton plugin architecture. However I'm unsure about how to treat input and rendering here. Do I feed input to both the debugger context and the debugged context? Wouldn't that mean that I could accidentally trigger things while clicking to select an element for instance? Maybe I could check if the debugger if visible and if so only feed input to the debugger context. And rendering seems strange because I would have to align the debugger context with the debugged context right? I have not tested this approach yet but if you tell me that this is the way it is intended to be then I'll give it a try. I'm mostly wary of this approach because it's not the way it's implemented in any of the samples as far as I know.
- Change the way I handle my contexts and cameras to have only a single context all the time, and use documents for each camera for instance (which would have to be aligned in some way in the context, via
SetContentBoxI suppose?). That seems fine to me ifSetContentBoxdoes what I think it does. Is it closer to the RmlUi phisolophy perhaps? - Allow the debugger to change host context via a new method (or remove the first test from
Rml::Debugger::Initialise). This is something I've tested locally and that seems to work. I added a methodRml::Debugger::SetHostContextthat can reinitialise the debugger with a new host context (see here: lut0pia@25d359b). It works fine for my use case, I'm not entirely sure that I'm not missing something but I can definitely jump from context to context without crashing, and input and rendering work like a charm because the debugger coexists nicely with the rest of the documents. If this approach seems good to you, I can create a PR with the new method (or with the modifiedRml::Debugger::Initialise). - Allow one debugger per context. This one I have neither tested nor investigated much, but to me it seems interesting. I'm guessing this is the furthest from the current RmlUi plugin philosophy. I'm including this idea however for completeness.
I would love to have your input on all of this. Thanks again for this wonderful library :)