Crazy Eddie's GUI System
0.8.0
|
In order to get CEGUI initialised and rendering – regardless of your target API or engine – there are basically three steps that need to be performed:
Obviously you also need to load some data and perform other basic initialisation, which is covered in The Beginners Guide to resource loading with ResourceProviders and The Beginners Guide to Data Files and Defaults Initialisation. You'll also need to get your inputs into the system so that you can interact with the GUI elements, this is covered in The Beginners Guide to Injecting Inputs.
This section describes the quickest and easiest way to get CEGUI up and running, and that is to use the static 'bootstrap' helper functions that are available on the Renderer class for your chosen API or engine. Unless you're doing something advanced or otherwise unusual, these are the fuctions you'll want to use, since they enable the creation of all the initial CEGUI objects in a single call.
Note that the Renderers also have destroySystem functions for cleaning up afterwards.
The Ogre3D and Irrlicht engines each have their own intergrated file loading and image parsing functionality which CEGUI can seamlessly make use of via custom implementations of the CEGUI::ResourceProvider and CEGUI::ImageCodec interfaces. In order to make use of these implementations, the user would typically be required to create instances of these objects and pass them, along with the CEGUI::Renderer, to the System::create function. Since this over-complicates system construction for the majority of cases, the bootstrapSystem functions for those Renderers will create all the engine specific supporting objects automatically.
As stated above, when using the boostrapSystem functions, initialising CEGUI is as simple as a single function call:
If for some reason you don't want to use the bootstrapSystem functions, you can still, of course, create all the required objects manually. The following describes the creation of the Renderer and System objects via separate calls. Note that if you have already used the boostrapSystem function, you do not need to perform the following steps, and can instead skip to Call the function to render the GUI
This is fairly straight forward and should pose no major obstacles for any of the supported renderers. You must of course remember to include the header file for the renderer that you will be using.
The basic renderer creation code is:
Another extremely simple step. Just instantiate the CEGUI::System object by using the System::create function, passing in the reference to the CEGUI::Renderer that you created in the previous step. This will cause the core CEGUI system to initialise itself.
This is the only step that, depending upon your target engine, can be done differently. Basically what you need to do call the CEGUI::System::renderAllGUIContexts function at the end of your rendering loop. For users of the Ogre3D engine, this step is taken care of automatically. For everybody else, some simple example code can be seen below:
This is the most basic introduction to setting up CEGUI to render. There are things not covered here, such as using different rendering targets in Ogre and advanced options such as user specified resource providers, and so on.