Difference between revisions of "Using CEGUI with Producer and OpenGL"
m |
|||
Line 15: | Line 15: | ||
} | } | ||
+ | === Using the viewer in an Application === | ||
And an application might use this viewer, doing some important initializations: | And an application might use this viewer, doing some important initializations: | ||
Revision as of 23:06, 20 August 2005
Producer is a cross platform toolkit, best explained on its website. I use it for many things, but creating a window, or Render Surface, is the most fundamental task. CEGUI requires knowledge of the window, mouse, and keyboard interaction. I will show how you can do that with some example code.
Defining a Producer Viewer
The first step is to create some sort of "viewer" with Producer, basically make a Producer::RenderSurface and a Producer::KeyboardMouse. Both of these classes are necessary for using CEGUI correctly. So, here is some example viewer code:
{
- include "Viewer.h"
Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0) {
_rs = _camera->getRenderSurface(); _kbm = new Producer::KeyboardMouse(_rs.get());
}
Viewer::~Viewer() {} }
Using the viewer in an Application
And an application might use this viewer, doing some important initializations:
{ Application::Application(const std::string& fontfile):
_status(RUNNING), _viewer(new general::Viewer()), _sim(new example::TeapotSim()), _scheme_loader_policy("MouseArrow"), _layout_loader_policy(), _script_module(new ApplicationEventHandler())
{
// OpenGL context specific initializations Producer::ref_ptr<Producer::RenderSurface> rs = _viewer->GetRenderSurface(); rs->addRealizeCallback(new general::InitGL()); rs->addRealizeCallback(new prce::InitCEGUI(fontfile,_script_module)); rs->setWindowName("Producer and CEGUI example"); rs->setWindowRectangle(20,50,800,600);
// rendering stuff _viewer->GetCamera()->setSceneHandler( _sim.get() ); _viewer->GetCamera()->addPreDrawCallback( new SimulationDrawContext(_sim.get()) ); _viewer->GetCamera()->addPostDrawCallback(new prce::RenderCEGUI() ); // renders the GUI over scene
// device input stuff Producer::ref_ptr<Producer::KeyboardMouse> kbm = _viewer->GetKeyboardMouse(); prce::Injector* injector = new prce::Injector( kbm.get() ); kbm->setCallback( injector ); kbm->startThread();
} }