Crazy Eddies GUI System
0.7.0
|
In order to get CEGUI to render - 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.
For Ogre3D and Irrlicht users, there are helper 'bootstrap' functions to create the renderer, system and other related objects in one go. These functions exist because those engines have additional supporting objects (engine specific ResourceProvider and ImageCodec implementations) that will be desired by most users, most of the time, so these helpers offer a simplified interface for getting the system up and running on those engines. As such Ogre3D and Irrlicht users can skip to Ogre3D and Irrlicht 'bootstrapSystem' functions.
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::renderGUI 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 section describes the Ogre3D and Irrlicht specific 'bootstrap' helper functions. Unless you're using one of these engines, you can probably skip to Conclusion.
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 even the most simplest of uses, the renderer for each of these engines provides one or more bootstrapSystem functions that creates all those supporting objects automatically (there are also destroySystem functions for cleaning up afterwards).
When using the boostrapSystem functions, starting up CEGUI is as simple as a single function call:
This is the most basic introduction to setting up CEGUI to render. There are things not covered here, such as using different scene managers in Ogre and advanced options such as user specified resource providers, and so on.