Beginner's Guide to Using cegui Rendering
From ceguiwiki
No matter which engine is used, there must be three steps to use cegui to render the GUI
- Create a cegui: Renderer base object.
- Create cegui: System Object.
- Call related methods to render the GUI
It is obvious that some basic files must be loaded before this, which will be described in the following loading data files and initialization. In addition, you must obtain system input, which will be introduced in the beginner's guide for inserting input.
1. Create a cegui: Renderer base object.
You must include the header file that you use the Renderer.
Basic creation code:
Direct3d 8.1
Cegui: directx81renderer * myrenderer =
New cegui: directx81renderer (myd3d8device );
Direct3d 9
Cegui: directx9renderer * myrenderer =
New cegui: directx9renderer (myd3d9device );
OpenGL
Cegui: openglrenderer * myrenderer =
New cegui: openglrenderer (0 );
Ogre3d
Cegui: ogreceguirenderer * myrenderer =
New cegui: ogreceguirenderer (myrenderwindow );
Irrlicht Engine
Cegui: irrlichtrenderer * myrenderer =
New cegui: irrlichtrenderer (myirrlichtdevice, true );
2. Create a cegui: System Object.
Pass a Renderer pointer just created
New cegui: System (myrenderer );
3. Call relevant methods to render the GUI
This is the only step related to your Renderer, so you need to call it separately as needed. You must call cegui: System: rendergui at the end of the rendering loop. Users of the ogre3d engine do not need to do this. Example:
Direct3d 8.1/9
// Start the scene
Myd3ddevice-> beginscene ();
// Clear display
Myd3ddevice-> clear (0, 0, d3dclear_target, d3dcolor_xrgb (0, 0, 0), 1.0f, 0 );
// User Function to draw 3D scene
Draw3dscene ();
// Draw Gui
Cegui: System: getsingleton (). rendergui ();
// End the scene
Myd3ddevice-> endscene ();
// Finally present the frame.
Myd3ddevice-> present (0, 0, 0, 0 );
OpenGL
// User Function to draw 3D scene
Draw3dscene ();
// Draw gui (shocould not be between glbegin/glend pair)
Cegui: System: getsingleton (). rendergui ();
Irrlicht
// Start the scene
Myirrlichtdriver-> beginscene (true, true, IRR: Video: scolor (150,50, 50,50 ));
// Draw main scene
Myirrlichtscenemanager-> drawall ();
// Draw Gui
Cegui: System: getsingleton (). rendergui ();
// End the scene
Myirrlichtdriver-> endscene ();
4 Conclusion
This is the most basic tutorial for cegui. Some topics are not described here, such as using different scenario managers in oger3d, and some advanced topics, such as user selection of resource providers.