-
Notifications
You must be signed in to change notification settings - Fork 3
Creating your own renderer
If you're using a GUI toolkit for which a Renderer is not created by default, you may create your own and use it. Renderers are injected with events at every significant stage in the patching process. Creating a custom Renderer would be about:
- initialising your GUI toolkit resources and system
- create a main loop/event loop
- handling the injections
- provide and pass off user feedback to the Patcher/Launcher
The reason the main loop is allowed to be created by the Renderer is that most GUI toolkits like Qt, wxWidgets, or GTK require running in the main application thread (also known as the GUI thread) so Karazeh will not get in the way of that. When you create your own Renderer, you are responsible for creating a main loop (or letting the GUI toolkit do it) and calling the other components when needed.
The Vanilla renderer is a good place to start as it's very simple, all it does is dump to STDOUT and read from STDIN. You should also read the Renderer.h header file to learn about the injections.
The bulk of the patching/processing is done in a separate thread, and the Patcher component is what injects the Renderer with feedback. This creates a problem when rendering, because if you attempt to render directly within the injection handlers, it will be done from a different thread (the Patcher's) than the main thread (the GUI's). To get around that, you need to use your toolkit's event system to:
- fire off an event in your injection handler
- handle that event from within the GUI thread (ie, let the GUI itself pass it off)
An example of this case is the QtRenderer, you can take a look at it to see how it's done.
Now, in the case where the GUI toolkit you're using does not have an event loop of its own (very unlikely), you can use Karazeh's event manager which is used by the Ogre renderer. Please see the respective headers for pointers on how to use it.