<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://cegui.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Granx</id>
		<title>CEGUI Wiki - Crazy Eddie's GUI System (Open Source) - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://cegui.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Granx"/>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/Special:Contributions/Granx"/>
		<updated>2026-09-18T01:39:18Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=1363</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=1363"/>
				<updated>2005-09-24T07:13:21Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; with Producer, basically make a Producer::RenderSurface and a Producer::KeyboardMouse.  Both of these classes are necessary for using CEGUI correctly.  Your job is just to create these so they can be used later.  There is no CEGUI code involved at this point.  So, here is some example viewer code:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
 Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
 {&lt;br /&gt;
   _rs = _camera-&amp;gt;getRenderSurface();  // a Camera creates a RenderSurface, grab it&lt;br /&gt;
   _kbm = new Producer::KeyboardMouse(_rs.get());  // make a new KeyboardMouse&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Initializing the Viewer in an Application ===&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
   _status(RUNNING), _viewer(new Viewer()), _sim(new TeapotSim()),&lt;br /&gt;
   _scheme_loader(&amp;quot;MouseArrow&amp;quot;), _layout_loader(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
 {&lt;br /&gt;
   // OpenGL context specific initializations&lt;br /&gt;
   Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
   rs-&amp;gt;addRealizeCallback(new InitGL() );&lt;br /&gt;
   rs-&amp;gt;addRealizeCallback(new InitCEGUI(fontfile,_script_module) );&lt;br /&gt;
   rs-&amp;gt;setWindowName( &amp;quot;Producer and CEGUI example&amp;quot; );&lt;br /&gt;
   rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
 &lt;br /&gt;
   // rendering stuff&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );   // draw the simulation graphics&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
 &lt;br /&gt;
   // device input stuff&lt;br /&gt;
   Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
   prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
   kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
   kbm-&amp;gt;startThread();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The InitGL and InitCEGUI functors are both specific to using CEGUI with Producer, and are quite important steps.  Much of these initializations are OpenGL specific, and therefore must occur within a thread with the right OpenGL context.  The Producer::RenderSurface can execute one-time initializations if you add them to be called upon window realization, with the Producer::RenderSurface::addRealizeCallback function which takes an instance to a class that derives from Producer::RenderSurface::Callback.  Both InitGL and InitCEGUI are classes which derive from this Callback.  I'll show what they need to do later in the tutorial.&lt;br /&gt;
&lt;br /&gt;
Actually, a lot (more) is happening in the Application's constructor.  Much of this is specific to using Producer.  I recommend reading the examples in Producer's distribution, but this example might sumarize some things for those of you new to using it.  The Producer::Camera class needs a 'SceneHandler' to perform draw calls.  This is the heart of the application's rendering.  I am showing an application that is named 'TeapotSim'.  It is just an example showing OpenGL's famous teapot spinning.  The SceneHandler instance must be set, and that is passed as a pointer to the Producer::Camera::addSceneHandler function.  The Camera instance will call the SceneHandler::draw function as part of the render loop.&lt;br /&gt;
&lt;br /&gt;
Another point in the render loop is the post-draw stage.  I used this stage to do more drawing, just like what my simulation would be doing, but in this stage I will be drawing the CEGUI, so that it will always be drawn last, and on top of the other graphics.&lt;br /&gt;
&lt;br /&gt;
=== Initializing CEGUI for Producer ===&lt;br /&gt;
Now, I want to show an example of initializing CEGUI:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;renderers/OpenGLGUIRenderer/openglrenderer.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;CEGUIScriptModule.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;CEGUIFontManager.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;InitCEGUI.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 InitCEGUI::InitCEGUI(const std::string&amp;amp; font, CEGUI::ScriptModule* s): _sm(s), _font(font)&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 InitCEGUI::~InitCEGUI()&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void InitCEGUI::operator ()(const Producer::RenderSurface&amp;amp; rs)&lt;br /&gt;
 {&lt;br /&gt;
   if( _sm )&lt;br /&gt;
     new CEGUI::System( new CEGUI::OpenGLRenderer(0), _sm );&lt;br /&gt;
   else&lt;br /&gt;
     new CEGUI::System( new CEGUI::OpenGLRenderer(0) );&lt;br /&gt;
 &lt;br /&gt;
   CEGUI::FontManager* fm = CEGUI::FontManager::getSingletonPtr();&lt;br /&gt;
   CEGUI::Font* f = fm-&amp;gt;createFont( _font );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Producer uses OpenGL for rendering, so that is the renderer we must choose.  Luckily, CEGUI provides this.  If you want your application to use a CEGUI::ScriptModule, you will need to provide a when initializing the CEGUI::System, but that is for another lesson.  A default font needs to be provided to the System, and during initialization is a good time to provide that, so my functor has required it.&lt;br /&gt;
&lt;br /&gt;
=== Rendering CEGUI with Producer ===&lt;br /&gt;
The application code showed a post draw callback being set.  Producer will execute this little callback at the right time, within the correct OpenGL context for OpenGL calls.  Here is what needs to happen for CEGUI to appear on your screen each frame:&lt;br /&gt;
&lt;br /&gt;
 void RenderCEGUI::operator ()(const Producer::Camera&amp;amp; c)&lt;br /&gt;
 {&lt;br /&gt;
   CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input to CEGUI via Producer ===&lt;br /&gt;
This is where the real magic happens.  You must inject inputs into CEGUI because it does not poll the operating system for you.  That is the job of a tool like Producer.  For the most part, the following code works.  There is a small bug that is only seen when resizing the Producer::RenderSurface (window).  However, I think it provides insight into how injections need to be done for CEGUI to react to user input:&lt;br /&gt;
&lt;br /&gt;
 /** \author John K. Grant&lt;br /&gt;
   * \date July, 14 2005.&lt;br /&gt;
   * This code is public domain, free for use, with the author having no responsibility or liability.&lt;br /&gt;
   */&lt;br /&gt;
 #include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;SpecialKeyMapFunctor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Injector.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 using namespace prce;&lt;br /&gt;
 &lt;br /&gt;
 Injector::Injector(Producer::KeyboardMouse* kbm): _kbm(kbm)&lt;br /&gt;
 {&lt;br /&gt;
   prce::SpecialKeyMapFunctor specials;&lt;br /&gt;
   _keys = specials();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 Injector::~Injector()&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /** changes from producer coordinates to normalized CE coordinates */&lt;br /&gt;
 void Injector::_producer_to_cegui(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
 {&lt;br /&gt;
    // --- horizontal math&lt;br /&gt;
    // ph = 1.0 - -1.0 = 2.0    // total horizontal distance in producer&lt;br /&gt;
    // ch = 1.0 -  0.0 = 1.0    // total horizontal distance in ce&lt;br /&gt;
 &lt;br /&gt;
    // --- vertical math&lt;br /&gt;
    // pv = 1.0 - -1.0 =  2.0   // total vertical distance in producer&lt;br /&gt;
    // cv = 0.0 -  1.0 = -1.0   // total vertical distance in ce&lt;br /&gt;
 &lt;br /&gt;
    // cex = cx + px * (ch/2 / ph/2) = 0.5 + px * ( 0.5/1.0) = 0.5 + px*0.5&lt;br /&gt;
    // cey = cy + py * (cv/2 / pv/2) = 0.5 + py * (-0.5/1.0) = 0.5 - py*0.5&lt;br /&gt;
    // where cx is the &amp;quot;center&amp;quot; x value in ce&lt;br /&gt;
    // and   cy is the &amp;quot;center&amp;quot; y value in ce&lt;br /&gt;
    float cex(0.5 + mx*0.5);&lt;br /&gt;
    float cey(0.5 - my*0.5);&lt;br /&gt;
    mx = cex;&lt;br /&gt;
    my = cey;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /** takes normalized CEGUI coordinates and converts&lt;br /&gt;
   * into pixel values for the screen.&lt;br /&gt;
   */&lt;br /&gt;
 void Injector::_convert_to_screen(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
 {&lt;br /&gt;
    unsigned int width(  _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowWidth()  );&lt;br /&gt;
    unsigned int height( _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowHeight() );&lt;br /&gt;
 &lt;br /&gt;
    // the above yields the same results as the code below&lt;br /&gt;
    //int wx(0), wy(0);&lt;br /&gt;
    //unsigned int width(0), height(0);&lt;br /&gt;
    //_kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowRectangle(wx,wy,width,height);&lt;br /&gt;
 &lt;br /&gt;
    float pixel_x = (float)width  * mx;&lt;br /&gt;
    float pixel_y = (float)height * my;&lt;br /&gt;
    mx = pixel_x;&lt;br /&gt;
    my = pixel_y;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::mouseMotion(float px,float py)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::passiveMouseMotion(float px,float py)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::buttonPress(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 &lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )  // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::buttonRelease(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 &lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )   // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::doubleButtonPress(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    /** currently is implemented to only inject a single press.&lt;br /&gt;
      * CEGUI handles its own detection of the double click via&lt;br /&gt;
      * the &amp;quot;time pulse&amp;quot;, which controls other things as well.&lt;br /&gt;
      */&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px,py);&lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )   // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::mouseScroll(enum Producer::KeyboardMouseCallback::ScrollingMotion motion)&lt;br /&gt;
 {&lt;br /&gt;
    switch( motion )&lt;br /&gt;
    {&lt;br /&gt;
    case Producer::KeyboardMouseCallback::ScrollDown:&lt;br /&gt;
       {&lt;br /&gt;
          CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
       } break;&lt;br /&gt;
 &lt;br /&gt;
    case Producer::KeyboardMouseCallback::ScrollUp:&lt;br /&gt;
       {&lt;br /&gt;
          CEGUI::System::getSingleton().injectMouseWheelChange( 1 );&lt;br /&gt;
       } break;&lt;br /&gt;
 &lt;br /&gt;
    default: // Producer::KeyboardMouseCallback::ScrollNone&lt;br /&gt;
       break;&lt;br /&gt;
    };&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::keyPress(Producer::KeyCharacter key)&lt;br /&gt;
 {&lt;br /&gt;
    CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
    CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( key ) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::keyRelease(Producer::KeyCharacter key)&lt;br /&gt;
 {&lt;br /&gt;
    CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::specialKeyPress(Producer::KeyCharacter prkey)&lt;br /&gt;
 {&lt;br /&gt;
    KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
    if( iter != _keys.end() )&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
       CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
    }&lt;br /&gt;
    CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( prkey ) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::specialKeyRelease(Producer::KeyCharacter prkey)&lt;br /&gt;
 {&lt;br /&gt;
    KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
    if( iter != _keys.end() )&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
       CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Using it all together ===&lt;br /&gt;
Here is what a simple main() will look like:&lt;br /&gt;
&lt;br /&gt;
 int main(unsigned int argc, char* argv[])&lt;br /&gt;
 {&lt;br /&gt;
   if( argc &amp;lt; 4 )&lt;br /&gt;
   {&lt;br /&gt;
     PrintUsage();&lt;br /&gt;
     return 1;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   Producer::ref_ptr&amp;lt;example::Application&amp;gt; app = new example::Application(argv[1]);&lt;br /&gt;
   app-&amp;gt;GetViewer()-&amp;gt;GetRenderSurface()-&amp;gt;realize();&lt;br /&gt;
 &lt;br /&gt;
   app-&amp;gt;LoadCEGUIScheme( argv[2] );&lt;br /&gt;
   app-&amp;gt;LoadCEGUILayout( argv[3] );&lt;br /&gt;
 &lt;br /&gt;
   while( !app-&amp;gt;IsFinished() )&lt;br /&gt;
   {&lt;br /&gt;
     app-&amp;gt;GetViewer()-&amp;gt;GetCamera()-&amp;gt;frame();&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   return 0;&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=199</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=199"/>
				<updated>2005-09-24T07:06:09Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: /* Initializing the Viewer in an Application */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; with Producer, basically make a Producer::RenderSurface and a Producer::KeyboardMouse.  Both of these classes are necessary for using CEGUI correctly.  Your job is just to create these so they can be used later.  There is no CEGUI code involved at this point.  So, here is some example viewer code:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
 Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
 {&lt;br /&gt;
   _rs = _camera-&amp;gt;getRenderSurface();  // a Camera creates a RenderSurface, grab it&lt;br /&gt;
   _kbm = new Producer::KeyboardMouse(_rs.get());  // make a new KeyboardMouse&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Initializing the Viewer in an Application ===&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
   _status(RUNNING), _viewer(new Viewer()), _sim(new TeapotSim()),&lt;br /&gt;
   _scheme_loader(&amp;quot;MouseArrow&amp;quot;), _layout_loader(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
 {&lt;br /&gt;
   // OpenGL context specific initializations&lt;br /&gt;
   Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
   rs-&amp;gt;addRealizeCallback(new InitGL() );&lt;br /&gt;
   rs-&amp;gt;addRealizeCallback(new InitCEGUI(fontfile,_script_module) );&lt;br /&gt;
   rs-&amp;gt;setWindowName( &amp;quot;Producer and CEGUI example&amp;quot; );&lt;br /&gt;
   rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
 &lt;br /&gt;
   // rendering stuff&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );   // draw the simulation graphics&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
 &lt;br /&gt;
   // device input stuff&lt;br /&gt;
   Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
   prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
   kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
   kbm-&amp;gt;startThread();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The InitGL and InitCEGUI functors are both specific to using CEGUI with Producer, and are quite important steps.  Much of these initializations are OpenGL specific, and therefore must occur within a thread with the right OpenGL context.  The Producer::RenderSurface can execute one-time initializations if you add them to be called upon window realization, with the Producer::RenderSurface::addRealizeCallback function which takes an instance to a class that derives from Producer::RenderSurface::Callback.  Both InitGL and InitCEGUI are classes which derive from this Callback.  I'll show what they need to do later in the tutorial.&lt;br /&gt;
&lt;br /&gt;
Actually, a lot (more) is happening in the Application's constructor.  Much of this is specific to using Producer.  I recommend reading the examples in Producer's distribution, but this example might sumarize some things for those of you new to using it.  The Producer::Camera class needs a 'SceneHandler' to perform draw calls.  This is the heart of the application's rendering.  I am showing an application that is named 'TeapotSim'.  It is just an example showing OpenGL's famous teapot spinning.  The SceneHandler instance must be set, and that is passed as a pointer to the Producer::Camera::addSceneHandler function.  The Camera instance will call the SceneHandler::draw function as part of the render loop.&lt;br /&gt;
&lt;br /&gt;
Another point in the render loop is the post-draw stage.  I used this stage to do more drawing, just like what my simulation would be doing, but in this stage I will be drawing the CEGUI, so that it will always be drawn last, and on top of the other graphics.&lt;br /&gt;
&lt;br /&gt;
The Camera's draw callbacks are very important, but first I want to show an example of initializing CEGUI:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;renderers/OpenGLGUIRenderer/openglrenderer.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;CEGUIScriptModule.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;CEGUIFontManager.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;InitCEGUI.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 InitCEGUI::InitCEGUI(const std::string&amp;amp; font, CEGUI::ScriptModule* s): _sm(s), _font(font)&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 InitCEGUI::~InitCEGUI()&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void InitCEGUI::operator ()(const Producer::RenderSurface&amp;amp; rs)&lt;br /&gt;
 {&lt;br /&gt;
   if( _sm )&lt;br /&gt;
     new CEGUI::System( new CEGUI::OpenGLRenderer(0), _sm );&lt;br /&gt;
   else&lt;br /&gt;
     new CEGUI::System( new CEGUI::OpenGLRenderer(0) );&lt;br /&gt;
 &lt;br /&gt;
   CEGUI::FontManager* fm = CEGUI::FontManager::getSingletonPtr();&lt;br /&gt;
   CEGUI::Font* f = fm-&amp;gt;createFont( _font );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Producer uses OpenGL for rendering, so that is the renderer we must choose.  Luckily, CEGUI provides this.  You will need to provide a CEGUI::ScriptModule when initializing the System, but that is for another lesson.  A default font needs to be provided to the System, and during initialization is a good time to provide that, so my functor has required it.&lt;br /&gt;
&lt;br /&gt;
=== Rendering CEGUI with Producer ===&lt;br /&gt;
The application code showed a post draw callback being set.  Producer will execute this little callback at the right time, within the correct OpenGL context for OpenGL calls.  Here is what needs to happen for CEGUI to appear on your screen each frame:&lt;br /&gt;
&lt;br /&gt;
 void RenderCEGUI::operator ()(const Producer::Camera&amp;amp; c)&lt;br /&gt;
 {&lt;br /&gt;
   CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input to CEGUI via Producer ===&lt;br /&gt;
This is where the real magic happens.  You must inject inputs into CEGUI because it does not poll the operating system for you.  That is the job of a tool like Producer.  For the most part, the following code works.  There is a small bug that is only seen when resizing the Producer::RenderSurface (window).  However, I think it provides insight into how injections need to be done for CEGUI to react to user input:&lt;br /&gt;
&lt;br /&gt;
 /** \author John K. Grant&lt;br /&gt;
   * \date July, 14 2005.&lt;br /&gt;
   * This code is public domain, free for use, with the author having no responsibility or liability.&lt;br /&gt;
   */&lt;br /&gt;
 #include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;SpecialKeyMapFunctor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Injector.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 using namespace prce;&lt;br /&gt;
 &lt;br /&gt;
 Injector::Injector(Producer::KeyboardMouse* kbm): _kbm(kbm)&lt;br /&gt;
 {&lt;br /&gt;
   prce::SpecialKeyMapFunctor specials;&lt;br /&gt;
   _keys = specials();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 Injector::~Injector()&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /** changes from producer coordinates to normalized CE coordinates */&lt;br /&gt;
 void Injector::_producer_to_cegui(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
 {&lt;br /&gt;
    // --- horizontal math&lt;br /&gt;
    // ph = 1.0 - -1.0 = 2.0    // total horizontal distance in producer&lt;br /&gt;
    // ch = 1.0 -  0.0 = 1.0    // total horizontal distance in ce&lt;br /&gt;
 &lt;br /&gt;
    // --- vertical math&lt;br /&gt;
    // pv = 1.0 - -1.0 =  2.0   // total vertical distance in producer&lt;br /&gt;
    // cv = 0.0 -  1.0 = -1.0   // total vertical distance in ce&lt;br /&gt;
 &lt;br /&gt;
    // cex = cx + px * (ch/2 / ph/2) = 0.5 + px * ( 0.5/1.0) = 0.5 + px*0.5&lt;br /&gt;
    // cey = cy + py * (cv/2 / pv/2) = 0.5 + py * (-0.5/1.0) = 0.5 - py*0.5&lt;br /&gt;
    // where cx is the &amp;quot;center&amp;quot; x value in ce&lt;br /&gt;
    // and   cy is the &amp;quot;center&amp;quot; y value in ce&lt;br /&gt;
    float cex(0.5 + mx*0.5);&lt;br /&gt;
    float cey(0.5 - my*0.5);&lt;br /&gt;
    mx = cex;&lt;br /&gt;
    my = cey;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /** takes normalized CEGUI coordinates and converts&lt;br /&gt;
   * into pixel values for the screen.&lt;br /&gt;
   */&lt;br /&gt;
 void Injector::_convert_to_screen(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
 {&lt;br /&gt;
    unsigned int width(  _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowWidth()  );&lt;br /&gt;
    unsigned int height( _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowHeight() );&lt;br /&gt;
 &lt;br /&gt;
    // the above yields the same results as the code below&lt;br /&gt;
    //int wx(0), wy(0);&lt;br /&gt;
    //unsigned int width(0), height(0);&lt;br /&gt;
    //_kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowRectangle(wx,wy,width,height);&lt;br /&gt;
 &lt;br /&gt;
    float pixel_x = (float)width  * mx;&lt;br /&gt;
    float pixel_y = (float)height * my;&lt;br /&gt;
    mx = pixel_x;&lt;br /&gt;
    my = pixel_y;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::mouseMotion(float px,float py)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::passiveMouseMotion(float px,float py)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::buttonPress(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 &lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )  // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::buttonRelease(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 &lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )   // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::doubleButtonPress(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    /** currently is implemented to only inject a single press.&lt;br /&gt;
      * CEGUI handles its own detection of the double click via&lt;br /&gt;
      * the &amp;quot;time pulse&amp;quot;, which controls other things as well.&lt;br /&gt;
      */&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px,py);&lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )   // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::mouseScroll(enum Producer::KeyboardMouseCallback::ScrollingMotion motion)&lt;br /&gt;
 {&lt;br /&gt;
    switch( motion )&lt;br /&gt;
    {&lt;br /&gt;
    case Producer::KeyboardMouseCallback::ScrollDown:&lt;br /&gt;
       {&lt;br /&gt;
          CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
       } break;&lt;br /&gt;
 &lt;br /&gt;
    case Producer::KeyboardMouseCallback::ScrollUp:&lt;br /&gt;
       {&lt;br /&gt;
          CEGUI::System::getSingleton().injectMouseWheelChange( 1 );&lt;br /&gt;
       } break;&lt;br /&gt;
 &lt;br /&gt;
    default: // Producer::KeyboardMouseCallback::ScrollNone&lt;br /&gt;
       break;&lt;br /&gt;
    };&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::keyPress(Producer::KeyCharacter key)&lt;br /&gt;
 {&lt;br /&gt;
    CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
    CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( key ) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::keyRelease(Producer::KeyCharacter key)&lt;br /&gt;
 {&lt;br /&gt;
    CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::specialKeyPress(Producer::KeyCharacter prkey)&lt;br /&gt;
 {&lt;br /&gt;
    KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
    if( iter != _keys.end() )&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
       CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
    }&lt;br /&gt;
    CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( prkey ) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::specialKeyRelease(Producer::KeyCharacter prkey)&lt;br /&gt;
 {&lt;br /&gt;
    KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
    if( iter != _keys.end() )&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
       CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Using it all together ===&lt;br /&gt;
Here is what a simple main() will look like:&lt;br /&gt;
&lt;br /&gt;
 int main(unsigned int argc, char* argv[])&lt;br /&gt;
 {&lt;br /&gt;
   if( argc &amp;lt; 4 )&lt;br /&gt;
   {&lt;br /&gt;
     PrintUsage();&lt;br /&gt;
     return 1;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   Producer::ref_ptr&amp;lt;example::Application&amp;gt; app = new example::Application(argv[1]);&lt;br /&gt;
   app-&amp;gt;GetViewer()-&amp;gt;GetRenderSurface()-&amp;gt;realize();&lt;br /&gt;
 &lt;br /&gt;
   app-&amp;gt;LoadCEGUIScheme( argv[2] );&lt;br /&gt;
   app-&amp;gt;LoadCEGUILayout( argv[3] );&lt;br /&gt;
 &lt;br /&gt;
   while( !app-&amp;gt;IsFinished() )&lt;br /&gt;
   {&lt;br /&gt;
     app-&amp;gt;GetViewer()-&amp;gt;GetCamera()-&amp;gt;frame();&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   return 0;&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=198</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=198"/>
				<updated>2005-09-24T06:46:29Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: /* Defining a Producer Viewer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; with Producer, basically make a Producer::RenderSurface and a Producer::KeyboardMouse.  Both of these classes are necessary for using CEGUI correctly.  Your job is just to create these so they can be used later.  There is no CEGUI code involved at this point.  So, here is some example viewer code:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
 Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
 {&lt;br /&gt;
   _rs = _camera-&amp;gt;getRenderSurface();  // a Camera creates a RenderSurface, grab it&lt;br /&gt;
   _kbm = new Producer::KeyboardMouse(_rs.get());  // make a new KeyboardMouse&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Using the viewer in an Application ===&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
   _status(RUNNING), _viewer(new general::Viewer()), _sim(new example::TeapotSim()),&lt;br /&gt;
   _scheme_loader_policy(&amp;quot;MouseArrow&amp;quot;), _layout_loader_policy(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
 {&lt;br /&gt;
   // OpenGL context specific initializations&lt;br /&gt;
   Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
   rs-&amp;gt;addRealizeCallback(new general::InitGL());&lt;br /&gt;
   rs-&amp;gt;addRealizeCallback(new prce::InitCEGUI(fontfile,_script_module));&lt;br /&gt;
   rs-&amp;gt;setWindowName(&amp;quot;Producer and CEGUI example&amp;quot;);&lt;br /&gt;
   rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
 &lt;br /&gt;
   // rendering stuff&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;addPreDrawCallback( new SimulationDrawContext(_sim.get()) );&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new prce::RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
 &lt;br /&gt;
   // device input stuff&lt;br /&gt;
   Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
   prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
   kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
   kbm-&amp;gt;startThread();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The general::InitGL functor and prce::InitCEGUI functor are quite important.  These initializations are OpenGL specific, and must occur within a thread with the right OpenGL context.  The Producer::RenderSurface can execute one-time initializations if you add them to be called upon window realization.  Actually, a lot is happening here in the Application's constructor.  You might be able to imagine how OpenGL is initialized, so I'll skip that for now.  The Camera's draw callbacks are very important, but first I want to show an example of initializing CEGUI:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;renderers/OpenGLGUIRenderer/openglrenderer.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;CEGUIScriptModule.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;CEGUIFontManager.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;InitCEGUI.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 using namespace prce;&lt;br /&gt;
 &lt;br /&gt;
 InitCEGUI::InitCEGUI(const std::string&amp;amp; font, CEGUI::ScriptModule* s): _sm(s), _font(font)&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 InitCEGUI::~InitCEGUI()&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void InitCEGUI::operator ()(const Producer::RenderSurface&amp;amp; rs)&lt;br /&gt;
 {&lt;br /&gt;
   if( _sm )&lt;br /&gt;
     new CEGUI::System( new CEGUI::OpenGLRenderer(0), _sm );&lt;br /&gt;
   else&lt;br /&gt;
     new CEGUI::System( new CEGUI::OpenGLRenderer(0) );&lt;br /&gt;
 &lt;br /&gt;
   CEGUI::FontManager* fm = CEGUI::FontManager::getSingletonPtr();&lt;br /&gt;
   CEGUI::Font* f = fm-&amp;gt;createFont( _font );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Producer uses OpenGL for rendering, so that is the renderer we must choose.  Luckily, CEGUI provides this.  You will need to provide a CEGUI::ScriptModule when initializing the System, but that is for another lesson.  A default font needs to be provided to the System, and during initialization is a good time to provide that, so my functor has required it.&lt;br /&gt;
&lt;br /&gt;
=== Rendering CEGUI with Producer ===&lt;br /&gt;
The application code showed a post draw callback being set.  Producer will execute this little callback at the right time, within the correct OpenGL context for OpenGL calls.  Here is what needs to happen for CEGUI to appear on your screen each frame:&lt;br /&gt;
&lt;br /&gt;
 void RenderCEGUI::operator ()(const Producer::Camera&amp;amp; c)&lt;br /&gt;
 {&lt;br /&gt;
   CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input to CEGUI via Producer ===&lt;br /&gt;
This is where the real magic happens.  You must inject inputs into CEGUI because it does not poll the operating system for you.  That is the job of a tool like Producer.  For the most part, the following code works.  There is a small bug that is only seen when resizing the Producer::RenderSurface (window).  However, I think it provides insight into how injections need to be done for CEGUI to react to user input:&lt;br /&gt;
&lt;br /&gt;
 /** \author John K. Grant&lt;br /&gt;
   * \date July, 14 2005.&lt;br /&gt;
   * This code is public domain, free for use, with the author having no responsibility or liability.&lt;br /&gt;
   */&lt;br /&gt;
 #include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;SpecialKeyMapFunctor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Injector.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 using namespace prce;&lt;br /&gt;
 &lt;br /&gt;
 Injector::Injector(Producer::KeyboardMouse* kbm): _kbm(kbm)&lt;br /&gt;
 {&lt;br /&gt;
   prce::SpecialKeyMapFunctor specials;&lt;br /&gt;
   _keys = specials();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 Injector::~Injector()&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /** changes from producer coordinates to normalized CE coordinates */&lt;br /&gt;
 void Injector::_producer_to_cegui(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
 {&lt;br /&gt;
    // --- horizontal math&lt;br /&gt;
    // ph = 1.0 - -1.0 = 2.0    // total horizontal distance in producer&lt;br /&gt;
    // ch = 1.0 -  0.0 = 1.0    // total horizontal distance in ce&lt;br /&gt;
 &lt;br /&gt;
    // --- vertical math&lt;br /&gt;
    // pv = 1.0 - -1.0 =  2.0   // total vertical distance in producer&lt;br /&gt;
    // cv = 0.0 -  1.0 = -1.0   // total vertical distance in ce&lt;br /&gt;
 &lt;br /&gt;
    // cex = cx + px * (ch/2 / ph/2) = 0.5 + px * ( 0.5/1.0) = 0.5 + px*0.5&lt;br /&gt;
    // cey = cy + py * (cv/2 / pv/2) = 0.5 + py * (-0.5/1.0) = 0.5 - py*0.5&lt;br /&gt;
    // where cx is the &amp;quot;center&amp;quot; x value in ce&lt;br /&gt;
    // and   cy is the &amp;quot;center&amp;quot; y value in ce&lt;br /&gt;
    float cex(0.5 + mx*0.5);&lt;br /&gt;
    float cey(0.5 - my*0.5);&lt;br /&gt;
    mx = cex;&lt;br /&gt;
    my = cey;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /** takes normalized CEGUI coordinates and converts&lt;br /&gt;
   * into pixel values for the screen.&lt;br /&gt;
   */&lt;br /&gt;
 void Injector::_convert_to_screen(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
 {&lt;br /&gt;
    unsigned int width(  _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowWidth()  );&lt;br /&gt;
    unsigned int height( _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowHeight() );&lt;br /&gt;
 &lt;br /&gt;
    // the above yields the same results as the code below&lt;br /&gt;
    //int wx(0), wy(0);&lt;br /&gt;
    //unsigned int width(0), height(0);&lt;br /&gt;
    //_kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowRectangle(wx,wy,width,height);&lt;br /&gt;
 &lt;br /&gt;
    float pixel_x = (float)width  * mx;&lt;br /&gt;
    float pixel_y = (float)height * my;&lt;br /&gt;
    mx = pixel_x;&lt;br /&gt;
    my = pixel_y;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::mouseMotion(float px,float py)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::passiveMouseMotion(float px,float py)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::buttonPress(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 &lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )  // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::buttonRelease(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 &lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )   // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::doubleButtonPress(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    /** currently is implemented to only inject a single press.&lt;br /&gt;
      * CEGUI handles its own detection of the double click via&lt;br /&gt;
      * the &amp;quot;time pulse&amp;quot;, which controls other things as well.&lt;br /&gt;
      */&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px,py);&lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )   // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::mouseScroll(enum Producer::KeyboardMouseCallback::ScrollingMotion motion)&lt;br /&gt;
 {&lt;br /&gt;
    switch( motion )&lt;br /&gt;
    {&lt;br /&gt;
    case Producer::KeyboardMouseCallback::ScrollDown:&lt;br /&gt;
       {&lt;br /&gt;
          CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
       } break;&lt;br /&gt;
 &lt;br /&gt;
    case Producer::KeyboardMouseCallback::ScrollUp:&lt;br /&gt;
       {&lt;br /&gt;
          CEGUI::System::getSingleton().injectMouseWheelChange( 1 );&lt;br /&gt;
       } break;&lt;br /&gt;
 &lt;br /&gt;
    default: // Producer::KeyboardMouseCallback::ScrollNone&lt;br /&gt;
       break;&lt;br /&gt;
    };&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::keyPress(Producer::KeyCharacter key)&lt;br /&gt;
 {&lt;br /&gt;
    CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
    CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( key ) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::keyRelease(Producer::KeyCharacter key)&lt;br /&gt;
 {&lt;br /&gt;
    CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::specialKeyPress(Producer::KeyCharacter prkey)&lt;br /&gt;
 {&lt;br /&gt;
    KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
    if( iter != _keys.end() )&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
       CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
    }&lt;br /&gt;
    CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( prkey ) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::specialKeyRelease(Producer::KeyCharacter prkey)&lt;br /&gt;
 {&lt;br /&gt;
    KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
    if( iter != _keys.end() )&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
       CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Using it all together ===&lt;br /&gt;
Here is what a simple main() will look like:&lt;br /&gt;
&lt;br /&gt;
 int main(unsigned int argc, char* argv[])&lt;br /&gt;
 {&lt;br /&gt;
   if( argc &amp;lt; 4 )&lt;br /&gt;
   {&lt;br /&gt;
     PrintUsage();&lt;br /&gt;
     return 1;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   Producer::ref_ptr&amp;lt;example::Application&amp;gt; app = new example::Application(argv[1]);&lt;br /&gt;
   app-&amp;gt;GetViewer()-&amp;gt;GetRenderSurface()-&amp;gt;realize();&lt;br /&gt;
 &lt;br /&gt;
   app-&amp;gt;LoadCEGUIScheme( argv[2] );&lt;br /&gt;
   app-&amp;gt;LoadCEGUILayout( argv[3] );&lt;br /&gt;
 &lt;br /&gt;
   while( !app-&amp;gt;IsFinished() )&lt;br /&gt;
   {&lt;br /&gt;
     app-&amp;gt;GetViewer()-&amp;gt;GetCamera()-&amp;gt;frame();&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   return 0;&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=197</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=197"/>
				<updated>2005-09-24T06:44:25Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: /* Defining a Producer Viewer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; with Producer, basically make a Producer::RenderSurface and a Producer::KeyboardMouse.  Both of these classes are necessary for using CEGUI correctly.  Your just is just to create these so they can be used later.  There is no CEGUI code involved at this point.  So, here is some example viewer code:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
 Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
 {&lt;br /&gt;
   _rs = _camera-&amp;gt;getRenderSurface();&lt;br /&gt;
   _kbm = new Producer::KeyboardMouse(_rs.get());&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 Viewer::~Viewer() {}&lt;br /&gt;
&lt;br /&gt;
=== Using the viewer in an Application ===&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
   _status(RUNNING), _viewer(new general::Viewer()), _sim(new example::TeapotSim()),&lt;br /&gt;
   _scheme_loader_policy(&amp;quot;MouseArrow&amp;quot;), _layout_loader_policy(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
 {&lt;br /&gt;
   // OpenGL context specific initializations&lt;br /&gt;
   Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
   rs-&amp;gt;addRealizeCallback(new general::InitGL());&lt;br /&gt;
   rs-&amp;gt;addRealizeCallback(new prce::InitCEGUI(fontfile,_script_module));&lt;br /&gt;
   rs-&amp;gt;setWindowName(&amp;quot;Producer and CEGUI example&amp;quot;);&lt;br /&gt;
   rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
 &lt;br /&gt;
   // rendering stuff&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;addPreDrawCallback( new SimulationDrawContext(_sim.get()) );&lt;br /&gt;
   _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new prce::RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
 &lt;br /&gt;
   // device input stuff&lt;br /&gt;
   Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
   prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
   kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
   kbm-&amp;gt;startThread();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The general::InitGL functor and prce::InitCEGUI functor are quite important.  These initializations are OpenGL specific, and must occur within a thread with the right OpenGL context.  The Producer::RenderSurface can execute one-time initializations if you add them to be called upon window realization.  Actually, a lot is happening here in the Application's constructor.  You might be able to imagine how OpenGL is initialized, so I'll skip that for now.  The Camera's draw callbacks are very important, but first I want to show an example of initializing CEGUI:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;renderers/OpenGLGUIRenderer/openglrenderer.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;CEGUIScriptModule.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;CEGUIFontManager.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;InitCEGUI.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 using namespace prce;&lt;br /&gt;
 &lt;br /&gt;
 InitCEGUI::InitCEGUI(const std::string&amp;amp; font, CEGUI::ScriptModule* s): _sm(s), _font(font)&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 InitCEGUI::~InitCEGUI()&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void InitCEGUI::operator ()(const Producer::RenderSurface&amp;amp; rs)&lt;br /&gt;
 {&lt;br /&gt;
   if( _sm )&lt;br /&gt;
     new CEGUI::System( new CEGUI::OpenGLRenderer(0), _sm );&lt;br /&gt;
   else&lt;br /&gt;
     new CEGUI::System( new CEGUI::OpenGLRenderer(0) );&lt;br /&gt;
 &lt;br /&gt;
   CEGUI::FontManager* fm = CEGUI::FontManager::getSingletonPtr();&lt;br /&gt;
   CEGUI::Font* f = fm-&amp;gt;createFont( _font );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Producer uses OpenGL for rendering, so that is the renderer we must choose.  Luckily, CEGUI provides this.  You will need to provide a CEGUI::ScriptModule when initializing the System, but that is for another lesson.  A default font needs to be provided to the System, and during initialization is a good time to provide that, so my functor has required it.&lt;br /&gt;
&lt;br /&gt;
=== Rendering CEGUI with Producer ===&lt;br /&gt;
The application code showed a post draw callback being set.  Producer will execute this little callback at the right time, within the correct OpenGL context for OpenGL calls.  Here is what needs to happen for CEGUI to appear on your screen each frame:&lt;br /&gt;
&lt;br /&gt;
 void RenderCEGUI::operator ()(const Producer::Camera&amp;amp; c)&lt;br /&gt;
 {&lt;br /&gt;
   CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input to CEGUI via Producer ===&lt;br /&gt;
This is where the real magic happens.  You must inject inputs into CEGUI because it does not poll the operating system for you.  That is the job of a tool like Producer.  For the most part, the following code works.  There is a small bug that is only seen when resizing the Producer::RenderSurface (window).  However, I think it provides insight into how injections need to be done for CEGUI to react to user input:&lt;br /&gt;
&lt;br /&gt;
 /** \author John K. Grant&lt;br /&gt;
   * \date July, 14 2005.&lt;br /&gt;
   * This code is public domain, free for use, with the author having no responsibility or liability.&lt;br /&gt;
   */&lt;br /&gt;
 #include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;SpecialKeyMapFunctor.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;Injector.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 using namespace prce;&lt;br /&gt;
 &lt;br /&gt;
 Injector::Injector(Producer::KeyboardMouse* kbm): _kbm(kbm)&lt;br /&gt;
 {&lt;br /&gt;
   prce::SpecialKeyMapFunctor specials;&lt;br /&gt;
   _keys = specials();&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 Injector::~Injector()&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /** changes from producer coordinates to normalized CE coordinates */&lt;br /&gt;
 void Injector::_producer_to_cegui(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
 {&lt;br /&gt;
    // --- horizontal math&lt;br /&gt;
    // ph = 1.0 - -1.0 = 2.0    // total horizontal distance in producer&lt;br /&gt;
    // ch = 1.0 -  0.0 = 1.0    // total horizontal distance in ce&lt;br /&gt;
 &lt;br /&gt;
    // --- vertical math&lt;br /&gt;
    // pv = 1.0 - -1.0 =  2.0   // total vertical distance in producer&lt;br /&gt;
    // cv = 0.0 -  1.0 = -1.0   // total vertical distance in ce&lt;br /&gt;
 &lt;br /&gt;
    // cex = cx + px * (ch/2 / ph/2) = 0.5 + px * ( 0.5/1.0) = 0.5 + px*0.5&lt;br /&gt;
    // cey = cy + py * (cv/2 / pv/2) = 0.5 + py * (-0.5/1.0) = 0.5 - py*0.5&lt;br /&gt;
    // where cx is the &amp;quot;center&amp;quot; x value in ce&lt;br /&gt;
    // and   cy is the &amp;quot;center&amp;quot; y value in ce&lt;br /&gt;
    float cex(0.5 + mx*0.5);&lt;br /&gt;
    float cey(0.5 - my*0.5);&lt;br /&gt;
    mx = cex;&lt;br /&gt;
    my = cey;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /** takes normalized CEGUI coordinates and converts&lt;br /&gt;
   * into pixel values for the screen.&lt;br /&gt;
   */&lt;br /&gt;
 void Injector::_convert_to_screen(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
 {&lt;br /&gt;
    unsigned int width(  _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowWidth()  );&lt;br /&gt;
    unsigned int height( _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowHeight() );&lt;br /&gt;
 &lt;br /&gt;
    // the above yields the same results as the code below&lt;br /&gt;
    //int wx(0), wy(0);&lt;br /&gt;
    //unsigned int width(0), height(0);&lt;br /&gt;
    //_kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowRectangle(wx,wy,width,height);&lt;br /&gt;
 &lt;br /&gt;
    float pixel_x = (float)width  * mx;&lt;br /&gt;
    float pixel_y = (float)height * my;&lt;br /&gt;
    mx = pixel_x;&lt;br /&gt;
    my = pixel_y;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::mouseMotion(float px,float py)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::passiveMouseMotion(float px,float py)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::buttonPress(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 &lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )  // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::buttonRelease(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
 &lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )   // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::doubleButtonPress(float px,float py,unsigned int button)&lt;br /&gt;
 {&lt;br /&gt;
    /** currently is implemented to only inject a single press.&lt;br /&gt;
      * CEGUI handles its own detection of the double click via&lt;br /&gt;
      * the &amp;quot;time pulse&amp;quot;, which controls other things as well.&lt;br /&gt;
      */&lt;br /&gt;
    _producer_to_cegui(px,py);&lt;br /&gt;
    _convert_to_screen(px,py);&lt;br /&gt;
    CEGUI::System::getSingleton().injectMousePosition(px,py);&lt;br /&gt;
    if( button == 1 )  // left&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 2 )  // middle&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
 &lt;br /&gt;
    else if( button == 3 )   // right&lt;br /&gt;
       CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::mouseScroll(enum Producer::KeyboardMouseCallback::ScrollingMotion motion)&lt;br /&gt;
 {&lt;br /&gt;
    switch( motion )&lt;br /&gt;
    {&lt;br /&gt;
    case Producer::KeyboardMouseCallback::ScrollDown:&lt;br /&gt;
       {&lt;br /&gt;
          CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
       } break;&lt;br /&gt;
 &lt;br /&gt;
    case Producer::KeyboardMouseCallback::ScrollUp:&lt;br /&gt;
       {&lt;br /&gt;
          CEGUI::System::getSingleton().injectMouseWheelChange( 1 );&lt;br /&gt;
       } break;&lt;br /&gt;
 &lt;br /&gt;
    default: // Producer::KeyboardMouseCallback::ScrollNone&lt;br /&gt;
       break;&lt;br /&gt;
    };&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::keyPress(Producer::KeyCharacter key)&lt;br /&gt;
 {&lt;br /&gt;
    CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
    CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( key ) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::keyRelease(Producer::KeyCharacter key)&lt;br /&gt;
 {&lt;br /&gt;
    CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::specialKeyPress(Producer::KeyCharacter prkey)&lt;br /&gt;
 {&lt;br /&gt;
    KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
    if( iter != _keys.end() )&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
       CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
    }&lt;br /&gt;
    CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( prkey ) );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void Injector::specialKeyRelease(Producer::KeyCharacter prkey)&lt;br /&gt;
 {&lt;br /&gt;
    KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
    if( iter != _keys.end() )&lt;br /&gt;
    {&lt;br /&gt;
       CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
       CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Using it all together ===&lt;br /&gt;
Here is what a simple main() will look like:&lt;br /&gt;
&lt;br /&gt;
 int main(unsigned int argc, char* argv[])&lt;br /&gt;
 {&lt;br /&gt;
   if( argc &amp;lt; 4 )&lt;br /&gt;
   {&lt;br /&gt;
     PrintUsage();&lt;br /&gt;
     return 1;&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   Producer::ref_ptr&amp;lt;example::Application&amp;gt; app = new example::Application(argv[1]);&lt;br /&gt;
   app-&amp;gt;GetViewer()-&amp;gt;GetRenderSurface()-&amp;gt;realize();&lt;br /&gt;
 &lt;br /&gt;
   app-&amp;gt;LoadCEGUIScheme( argv[2] );&lt;br /&gt;
   app-&amp;gt;LoadCEGUILayout( argv[3] );&lt;br /&gt;
 &lt;br /&gt;
   while( !app-&amp;gt;IsFinished() )&lt;br /&gt;
   {&lt;br /&gt;
     app-&amp;gt;GetViewer()-&amp;gt;GetCamera()-&amp;gt;frame();&lt;br /&gt;
   }&lt;br /&gt;
 &lt;br /&gt;
   return 0;&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=FAQ&amp;diff=178</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=FAQ&amp;diff=178"/>
				<updated>2005-09-09T21:08:29Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: /* Build Questions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Questions ==&lt;br /&gt;
=== What is CEGUI? ===&lt;br /&gt;
CEGUI is ''Crazy Eddie's Gui System''; a cross platform Gui/widget library for use in games and other multi-media projects where use of standard operating system Gui libraries is either not possible, or is very difficult.&lt;br /&gt;
&lt;br /&gt;
=== How is CEGUI licensed? ===&lt;br /&gt;
CEGUI is licensed under the LGPL (Lesser/Library General Public License). For details of this license, please visit the following web-site: http://www.gnu.org/copyleft/lesser.html.&lt;br /&gt;
&lt;br /&gt;
=== How much does CEGUI cost? ===&lt;br /&gt;
Nothing. The use of CEGUI is totally free within the bounds of the LGPL license as described above.&lt;br /&gt;
&lt;br /&gt;
=== I am developing a commercial, closed-source product. Since CEGUI is licensed under LGPL, this means that can't I use the library, right? ===&lt;br /&gt;
No, that's not right. So long as you link dynamically to CEGUI and associated libraries, then you do not have to release any of your own source or .o/.obj files, though do carefully check the LGPL, and the licenses for the third party libraries for full details of what is and is not permissible.&lt;br /&gt;
&lt;br /&gt;
=== I am not happy with the LGPL license, do you offer alternative licensing? ===&lt;br /&gt;
No. Alternative licensing is not available, nor is it planned.&lt;br /&gt;
&lt;br /&gt;
=== Does CEGUI rely upon any third party libraries? If so what are they? ===&lt;br /&gt;
CEGUI currently depends upon the following external libraries:&lt;br /&gt;
&lt;br /&gt;
    * FreeType2&lt;br /&gt;
    * Xerces-C++ (optional, built-in TinyXML parser is provided)&lt;br /&gt;
&lt;br /&gt;
You will also require a supported rendering system, and some form of input library.&lt;br /&gt;
=== Where can I get these third party libraries? ===&lt;br /&gt;
&lt;br /&gt;
    * FreeType2: http://www.freetype.org/&lt;br /&gt;
    * Xerces-C++: http://xml.apache.org/xerces-c/&lt;br /&gt;
&lt;br /&gt;
=== Do I have to compile the third part libraries myself? ===&lt;br /&gt;
It depends. Under Linux and similar systems, you will need to perform your own compilation. For Microsoft® Windows® users, we have supplied packages containing binary versions of the libraries for a selection of popular compiler configurations.&lt;br /&gt;
&lt;br /&gt;
=== You mentioned something about &amp;quot;supported rendering systems&amp;quot;, what's that all about and which systems are supported? ===&lt;br /&gt;
CEGUI can be used with various rendering systems. There are currently CEGUI renderer modules for Microsoft® DirectX® 8.1 and 9, OpenGL, the Ogre engine, and the Irrlicht engine.&lt;br /&gt;
&lt;br /&gt;
=== There is no renderer module for my rendering engine or API of choice, will other rendering system be supported? ===&lt;br /&gt;
It is likely that, over time, CEGUI will add support for other APIs and engines. Having said this, it is fairly simple to write your own renderer module for CEGUI, so you might consider taking that option if you do not want to wait.&lt;br /&gt;
&lt;br /&gt;
=== And what about input libraries? ===&lt;br /&gt;
CEGUI requires you to ''inject'' inputs into it, these inputs can come from any source that you choose. All you need to do is pass mouse movements, mouse button up and down events, and keyboard inputs to CEGUI.&lt;br /&gt;
&lt;br /&gt;
=== Why doesn't CEGUI collect its own inputs? Why do I need to inject the inputs myself? ===&lt;br /&gt;
CEGUI does not collect its own input so that the system can remain as flexible as possible. We didn't want to tie people down to one system or input library.&lt;br /&gt;
&lt;br /&gt;
=== I have seen mention of a Lua scripting module, how can I get this? ===&lt;br /&gt;
'''TODO'''&lt;br /&gt;
&lt;br /&gt;
=== I can't find many of the things you talk about in my crayzedsgui code, what's wrong? ===&lt;br /&gt;
You probably have one of the older Mk-1 alpha releases. Get the newer Mk-2 releases instead, the archive files for these generally have names with cegui_mk2 in them.&lt;br /&gt;
&lt;br /&gt;
=== Why are there two versions of the system? ===&lt;br /&gt;
The Mk-1 version was a Windows®/DirectX® only library and was really a dry run for what became the Mk-2 system. There was only ever 'alpha' versions of the Mk-1 code, so it was never anywhere near finished.&lt;br /&gt;
&lt;br /&gt;
=== Are the Mk-1 and Mk-2 systems interface compatible? ===&lt;br /&gt;
No. The interfaces of the two systems are totally different, although many of the general concepts have remained the same.&lt;br /&gt;
&lt;br /&gt;
=== The Mk-1 system is so much more lightweight than the Mk-2 system. Can I still use the Mk-1 code? Is the Mk-1 code still being developed and supported? ===&lt;br /&gt;
Short Answer: Not really.&lt;br /&gt;
&lt;br /&gt;
Long Answer: There were too many weak areas within the Mk-1 system and development on this version has ceased completely. There is no longer any support for the Mk-1 version; in general it would be better for everyone if they migrated to the Mk-2 version of the system.&lt;br /&gt;
&lt;br /&gt;
=== I am having major troubles integrating CEGUI with my project, will you do it for me? ===&lt;br /&gt;
No. The CEGUI developers have enough to do without writing users projects for them.&lt;br /&gt;
&lt;br /&gt;
=== I have (or think I have) found a bug. How should I proceed? ===&lt;br /&gt;
If you are certain that it's a bug and not, for example, a misunderstanding of what is happening, then the bug should be reported via the project bug tracking system. However, before submitting a bug to the tracker, it is asked that you first do a quick search to see if the bug has already been reported. If you are unsure whether something is a bug or not, then it may be discussed on the web site forums prior to submitting a bug report to the project bug tracker.&lt;br /&gt;
&lt;br /&gt;
=== I notice that feature/widget 'X' is missing. Will this be added to CEGUI? ===&lt;br /&gt;
Requests for new features and/or widgets are welcomed. You can discuss such things on the web site forums and then submit a feature request to the project feature request tracking system. Although it is asked that you first search to ensure that the feature has not already been requested; if the feature has already been requested feel free to add a note to the tracker item stating your support for the feature request. Note that no promises are made with regards to which features will and will not be added, or how long such things will take, but all requests will be seriously considered.&lt;br /&gt;
&lt;br /&gt;
=== How can I get involved with CEGUI development? ===&lt;br /&gt;
The best way to become involved is to visit the web site forums, state what your intentions are (to help in avoiding duplicated effort), and then start submitting some patches to the project patch tracking system.&lt;br /&gt;
&lt;br /&gt;
=== Is there managed code / Microsoft .Net support for the CEGUI library? ===&lt;br /&gt;
Yes, there is ''ceguisharp'' at http://realmforgewiki.castlegobs.nl/index.php/CEGUI This is a C# port of the library which uses the excellent Axiom rendering engine.&lt;br /&gt;
&lt;br /&gt;
=== This FAQ doesn't answer my question, what should I do now? ===&lt;br /&gt;
Feel free to post your question on the web site forums, somebody will gladly answer your question and/or offer further advice.&lt;br /&gt;
&lt;br /&gt;
== Build Questions ==&lt;br /&gt;
(A work in Progress)&lt;br /&gt;
CEGUI Build&lt;br /&gt;
# General Requirements&lt;br /&gt;
# Dependency installs&lt;br /&gt;
&lt;br /&gt;
# Building from CVS (unix systems)&lt;br /&gt;
# Configuring&lt;br /&gt;
Run cegui_mk2/bootstrap&lt;br /&gt;
# The build&lt;br /&gt;
Type 'make'&lt;br /&gt;
&lt;br /&gt;
CEGUI Layout Editor Build&lt;br /&gt;
# Dependency installs (for versions &amp;gt; 0.4.0)&lt;br /&gt;
Install wxWidgets&lt;br /&gt;
# Building&lt;br /&gt;
&lt;br /&gt;
== Usage Questions ==&lt;br /&gt;
=== What is the correct way to subscribe for an event? ===&lt;br /&gt;
Event notification is a vital aspect of GUI programming. CEGUI handles those using subscribers.&lt;br /&gt;
In order to subscribe a window for an event, you have to call the method 'Window::subscribeEvent', passing the function&lt;br /&gt;
to be called when the specified event occurs, and the instance on which the method is called.&lt;br /&gt;
&lt;br /&gt;
 class MyButtonHandler&lt;br /&gt;
 {&lt;br /&gt;
 private:&lt;br /&gt;
     PushButton* mButton;&lt;br /&gt;
 &lt;br /&gt;
 public:&lt;br /&gt;
     MyButtonHandler::MyButtonHandler(PushButton* btn) : mButton(btn)&lt;br /&gt;
     {&lt;br /&gt;
         btn-&amp;gt;subscribeEvent(PushButton::EventClicked, Event::Subscriber(MyButtonHandler::ButtonClicked,this));&lt;br /&gt;
     }&lt;br /&gt;
     &lt;br /&gt;
     MyButtonHandler::ButtonClicked()&lt;br /&gt;
     {&lt;br /&gt;
         //This function gets called when the button is clicked&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;Button clicked&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
The 'subscribeEvent' method returns an Event::Connection, which can be used later to unsubscribe for a registered event with&lt;br /&gt;
the 'disconnect' method.&lt;br /&gt;
&lt;br /&gt;
 Event::Connection myCon = btn-&amp;gt;subscribeEvent(...);&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 myCon-&amp;gt;disconnect();&lt;br /&gt;
&lt;br /&gt;
In order to totally remove the event itself, you have to call the 'removeEvent' function:&lt;br /&gt;
all the connections to the specified event will be disconnected. &lt;br /&gt;
There's also an Event::ScopedConnection, which can be used to auto-unsubscribe when the event goes out of scope.&lt;br /&gt;
&lt;br /&gt;
Similar way for the scripted events, which can be subscribed with the 'subscribeScriptedEvent' method.&lt;br /&gt;
In addition, you can do it in XML, using this syntax:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;Event Name=&amp;quot;Clicked&amp;quot; Function=&amp;quot;luabtn_clicked&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How can I make the ListBox highlight the selected item? ===&lt;br /&gt;
In order to highlight selected items you need to set selection brush image and the selection colours of that item. The selection image is modulated by the colours you set. Note, that the alpha component needs to be smaller than 1.0, for the content of the selected item to be seen.&lt;br /&gt;
 // set selection highlight to a half transparent blue to red gradient.&lt;br /&gt;
 colour blue(0.0, 0.0, 1.0, 0.5);&lt;br /&gt;
 colour red(1.0, 0.0, 0.0, 0.5);&lt;br /&gt;
 myListBoxItem-&amp;gt;setSelectionColours(blue, blue, red, red);&lt;br /&gt;
 // this default image is a simple white rectangle&lt;br /&gt;
 myListBoxItem-&amp;gt;setSelectionBrushImage(&amp;quot;TaharezLook&amp;quot;, &amp;quot;ListboxSelectionBrush&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
=== How can I remove the border of a StaticImage? ===&lt;br /&gt;
Either put the following property into the window definition:&lt;br /&gt;
 &amp;lt;Property Name=&amp;quot;FrameEnabled&amp;quot; Value=&amp;quot;false&amp;quot; /&amp;gt;&lt;br /&gt;
Or set it by code:&lt;br /&gt;
 myStaticImage-&amp;gt;setFrameEnabled(false);&lt;br /&gt;
&lt;br /&gt;
=== How can I set the background of a StaticImage? ===&lt;br /&gt;
The first thing you need in order to do this is an Imageset that defines the Image that you wish to use. When wanting to use an image file for this as you suggest, you basically have an imageset defined like this:&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;Imageset Name=&amp;quot;BackdropImageset&amp;quot; Imagefile=&amp;quot;backdrop.tga&amp;quot; NativeHorzRes=&amp;quot;1024&amp;quot; NativeVertRes=&amp;quot;768&amp;quot; AutoScaled=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
 	&amp;lt;Image Name=&amp;quot;Backdrop&amp;quot; XPos=&amp;quot;0&amp;quot; YPos=&amp;quot;0&amp;quot; Width=&amp;quot;1024&amp;quot; Height=&amp;quot;768&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/Imageset&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this does is define an Imageset using the backdrop.tga. A single image &amp;quot;Backdrop&amp;quot; is defined that starts at location (0,0) and is 1024 x 768 in size. You should be careful in that the source image file should have dimensions that are powers of two - this is because the image is loaded as a texture, and may be stretched if the powers-of-two requirement is not observed.&amp;lt;br&amp;gt;&lt;br /&gt;
Once you have your imageset defined, you can load it either by adding a reference to it in whichever scheme you are loading, or manually using the ImagesetManager:&lt;br /&gt;
 CEGUI::ImagesetManager::getSingleton().createImageset(&amp;quot;myImageset.imagset&amp;quot;);&lt;br /&gt;
Once the thing is loaded, you set the image into the StaticImage like so:&lt;br /&gt;
 myStaticImage-&amp;gt;setImage(&amp;quot;BackdropImageset&amp;quot;, &amp;quot;Backdrop&amp;quot;);&lt;br /&gt;
Notice that the names we specify here are the ones that were originally specified in the imageset XML file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What properties are available for use in XML layouts, and what format do I use for the value strings? ===&lt;br /&gt;
Each widget has its properties placed within an appropriately named C++ namespace, so all you need to do is look up the appropriate namespace within the [http://www.cegui.org.uk/api_reference/namespaces.html namespaces section of the API reference].&lt;br /&gt;
&lt;br /&gt;
Also, remember that properties are inherited.  So for example, when looking up properties for a PushButton, also check the properties for ButtonBase and Window too - since these properties are also available to you.&lt;br /&gt;
&lt;br /&gt;
=== I can't see the items I've added to my Combobox, how do I get the list to show when I press the button? ===&lt;br /&gt;
&lt;br /&gt;
The height you specify for the combobox widget includes the height of the drop down list; it's not just for the 'Editbox' portion of the widget (the height of which  is usually automatically determined based upon the font).  Ensure that when specifying the height for your combobox, you have provided sufficient space for the list to appear.&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=FAQ&amp;diff=177</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=FAQ&amp;diff=177"/>
				<updated>2005-09-09T21:03:41Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: /* Build Questions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Questions ==&lt;br /&gt;
=== What is CEGUI? ===&lt;br /&gt;
CEGUI is ''Crazy Eddie's Gui System''; a cross platform Gui/widget library for use in games and other multi-media projects where use of standard operating system Gui libraries is either not possible, or is very difficult.&lt;br /&gt;
&lt;br /&gt;
=== How is CEGUI licensed? ===&lt;br /&gt;
CEGUI is licensed under the LGPL (Lesser/Library General Public License). For details of this license, please visit the following web-site: http://www.gnu.org/copyleft/lesser.html.&lt;br /&gt;
&lt;br /&gt;
=== How much does CEGUI cost? ===&lt;br /&gt;
Nothing. The use of CEGUI is totally free within the bounds of the LGPL license as described above.&lt;br /&gt;
&lt;br /&gt;
=== I am developing a commercial, closed-source product. Since CEGUI is licensed under LGPL, this means that can't I use the library, right? ===&lt;br /&gt;
No, that's not right. So long as you link dynamically to CEGUI and associated libraries, then you do not have to release any of your own source or .o/.obj files, though do carefully check the LGPL, and the licenses for the third party libraries for full details of what is and is not permissible.&lt;br /&gt;
&lt;br /&gt;
=== I am not happy with the LGPL license, do you offer alternative licensing? ===&lt;br /&gt;
No. Alternative licensing is not available, nor is it planned.&lt;br /&gt;
&lt;br /&gt;
=== Does CEGUI rely upon any third party libraries? If so what are they? ===&lt;br /&gt;
CEGUI currently depends upon the following external libraries:&lt;br /&gt;
&lt;br /&gt;
    * FreeType2&lt;br /&gt;
    * Xerces-C++ (optional, built-in TinyXML parser is provided)&lt;br /&gt;
&lt;br /&gt;
You will also require a supported rendering system, and some form of input library.&lt;br /&gt;
=== Where can I get these third party libraries? ===&lt;br /&gt;
&lt;br /&gt;
    * FreeType2: http://www.freetype.org/&lt;br /&gt;
    * Xerces-C++: http://xml.apache.org/xerces-c/&lt;br /&gt;
&lt;br /&gt;
=== Do I have to compile the third part libraries myself? ===&lt;br /&gt;
It depends. Under Linux and similar systems, you will need to perform your own compilation. For Microsoft® Windows® users, we have supplied packages containing binary versions of the libraries for a selection of popular compiler configurations.&lt;br /&gt;
&lt;br /&gt;
=== You mentioned something about &amp;quot;supported rendering systems&amp;quot;, what's that all about and which systems are supported? ===&lt;br /&gt;
CEGUI can be used with various rendering systems. There are currently CEGUI renderer modules for Microsoft® DirectX® 8.1 and 9, OpenGL, the Ogre engine, and the Irrlicht engine.&lt;br /&gt;
&lt;br /&gt;
=== There is no renderer module for my rendering engine or API of choice, will other rendering system be supported? ===&lt;br /&gt;
It is likely that, over time, CEGUI will add support for other APIs and engines. Having said this, it is fairly simple to write your own renderer module for CEGUI, so you might consider taking that option if you do not want to wait.&lt;br /&gt;
&lt;br /&gt;
=== And what about input libraries? ===&lt;br /&gt;
CEGUI requires you to ''inject'' inputs into it, these inputs can come from any source that you choose. All you need to do is pass mouse movements, mouse button up and down events, and keyboard inputs to CEGUI.&lt;br /&gt;
&lt;br /&gt;
=== Why doesn't CEGUI collect its own inputs? Why do I need to inject the inputs myself? ===&lt;br /&gt;
CEGUI does not collect its own input so that the system can remain as flexible as possible. We didn't want to tie people down to one system or input library.&lt;br /&gt;
&lt;br /&gt;
=== I have seen mention of a Lua scripting module, how can I get this? ===&lt;br /&gt;
'''TODO'''&lt;br /&gt;
&lt;br /&gt;
=== I can't find many of the things you talk about in my crayzedsgui code, what's wrong? ===&lt;br /&gt;
You probably have one of the older Mk-1 alpha releases. Get the newer Mk-2 releases instead, the archive files for these generally have names with cegui_mk2 in them.&lt;br /&gt;
&lt;br /&gt;
=== Why are there two versions of the system? ===&lt;br /&gt;
The Mk-1 version was a Windows®/DirectX® only library and was really a dry run for what became the Mk-2 system. There was only ever 'alpha' versions of the Mk-1 code, so it was never anywhere near finished.&lt;br /&gt;
&lt;br /&gt;
=== Are the Mk-1 and Mk-2 systems interface compatible? ===&lt;br /&gt;
No. The interfaces of the two systems are totally different, although many of the general concepts have remained the same.&lt;br /&gt;
&lt;br /&gt;
=== The Mk-1 system is so much more lightweight than the Mk-2 system. Can I still use the Mk-1 code? Is the Mk-1 code still being developed and supported? ===&lt;br /&gt;
Short Answer: Not really.&lt;br /&gt;
&lt;br /&gt;
Long Answer: There were too many weak areas within the Mk-1 system and development on this version has ceased completely. There is no longer any support for the Mk-1 version; in general it would be better for everyone if they migrated to the Mk-2 version of the system.&lt;br /&gt;
&lt;br /&gt;
=== I am having major troubles integrating CEGUI with my project, will you do it for me? ===&lt;br /&gt;
No. The CEGUI developers have enough to do without writing users projects for them.&lt;br /&gt;
&lt;br /&gt;
=== I have (or think I have) found a bug. How should I proceed? ===&lt;br /&gt;
If you are certain that it's a bug and not, for example, a misunderstanding of what is happening, then the bug should be reported via the project bug tracking system. However, before submitting a bug to the tracker, it is asked that you first do a quick search to see if the bug has already been reported. If you are unsure whether something is a bug or not, then it may be discussed on the web site forums prior to submitting a bug report to the project bug tracker.&lt;br /&gt;
&lt;br /&gt;
=== I notice that feature/widget 'X' is missing. Will this be added to CEGUI? ===&lt;br /&gt;
Requests for new features and/or widgets are welcomed. You can discuss such things on the web site forums and then submit a feature request to the project feature request tracking system. Although it is asked that you first search to ensure that the feature has not already been requested; if the feature has already been requested feel free to add a note to the tracker item stating your support for the feature request. Note that no promises are made with regards to which features will and will not be added, or how long such things will take, but all requests will be seriously considered.&lt;br /&gt;
&lt;br /&gt;
=== How can I get involved with CEGUI development? ===&lt;br /&gt;
The best way to become involved is to visit the web site forums, state what your intentions are (to help in avoiding duplicated effort), and then start submitting some patches to the project patch tracking system.&lt;br /&gt;
&lt;br /&gt;
=== Is there managed code / Microsoft .Net support for the CEGUI library? ===&lt;br /&gt;
Yes, there is ''ceguisharp'' at http://realmforgewiki.castlegobs.nl/index.php/CEGUI This is a C# port of the library which uses the excellent Axiom rendering engine.&lt;br /&gt;
&lt;br /&gt;
=== This FAQ doesn't answer my question, what should I do now? ===&lt;br /&gt;
Feel free to post your question on the web site forums, somebody will gladly answer your question and/or offer further advice.&lt;br /&gt;
&lt;br /&gt;
== Build Questions ==&lt;br /&gt;
CEGUI Build&lt;br /&gt;
# General Requirements&lt;br /&gt;
# Dependency installs&lt;br /&gt;
&lt;br /&gt;
# Building from CVS (unix systems)&lt;br /&gt;
# Configuring&lt;br /&gt;
Run cegui_mk2/bootstrap&lt;br /&gt;
# The build&lt;br /&gt;
Type 'make'&lt;br /&gt;
&lt;br /&gt;
CEGUI Layout Editor Build&lt;br /&gt;
# Dependency installs (for versions &amp;gt; 0.4.0)&lt;br /&gt;
Install wxWidgets&lt;br /&gt;
# Building&lt;br /&gt;
&lt;br /&gt;
== Usage Questions ==&lt;br /&gt;
=== What is the correct way to subscribe for an event? ===&lt;br /&gt;
Event notification is a vital aspect of GUI programming. CEGUI handles those using subscribers.&lt;br /&gt;
In order to subscribe a window for an event, you have to call the method 'Window::subscribeEvent', passing the function&lt;br /&gt;
to be called when the specified event occurs, and the instance on which the method is called.&lt;br /&gt;
&lt;br /&gt;
 class MyButtonHandler&lt;br /&gt;
 {&lt;br /&gt;
 private:&lt;br /&gt;
     PushButton* mButton;&lt;br /&gt;
 &lt;br /&gt;
 public:&lt;br /&gt;
     MyButtonHandler::MyButtonHandler(PushButton* btn) : mButton(btn)&lt;br /&gt;
     {&lt;br /&gt;
         btn-&amp;gt;subscribeEvent(PushButton::EventClicked, Event::Subscriber(MyButtonHandler::ButtonClicked,this));&lt;br /&gt;
     }&lt;br /&gt;
     &lt;br /&gt;
     MyButtonHandler::ButtonClicked()&lt;br /&gt;
     {&lt;br /&gt;
         //This function gets called when the button is clicked&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;Button clicked&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
The 'subscribeEvent' method returns an Event::Connection, which can be used later to unsubscribe for a registered event with&lt;br /&gt;
the 'disconnect' method.&lt;br /&gt;
&lt;br /&gt;
 Event::Connection myCon = btn-&amp;gt;subscribeEvent(...);&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 myCon-&amp;gt;disconnect();&lt;br /&gt;
&lt;br /&gt;
In order to totally remove the event itself, you have to call the 'removeEvent' function:&lt;br /&gt;
all the connections to the specified event will be disconnected. &lt;br /&gt;
There's also an Event::ScopedConnection, which can be used to auto-unsubscribe when the event goes out of scope.&lt;br /&gt;
&lt;br /&gt;
Similar way for the scripted events, which can be subscribed with the 'subscribeScriptedEvent' method.&lt;br /&gt;
In addition, you can do it in XML, using this syntax:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;Event Name=&amp;quot;Clicked&amp;quot; Function=&amp;quot;luabtn_clicked&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How can I make the ListBox highlight the selected item? ===&lt;br /&gt;
In order to highlight selected items you need to set selection brush image and the selection colours of that item. The selection image is modulated by the colours you set. Note, that the alpha component needs to be smaller than 1.0, for the content of the selected item to be seen.&lt;br /&gt;
 // set selection highlight to a half transparent blue to red gradient.&lt;br /&gt;
 colour blue(0.0, 0.0, 1.0, 0.5);&lt;br /&gt;
 colour red(1.0, 0.0, 0.0, 0.5);&lt;br /&gt;
 myListBoxItem-&amp;gt;setSelectionColours(blue, blue, red, red);&lt;br /&gt;
 // this default image is a simple white rectangle&lt;br /&gt;
 myListBoxItem-&amp;gt;setSelectionBrushImage(&amp;quot;TaharezLook&amp;quot;, &amp;quot;ListboxSelectionBrush&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
=== How can I remove the border of a StaticImage? ===&lt;br /&gt;
Either put the following property into the window definition:&lt;br /&gt;
 &amp;lt;Property Name=&amp;quot;FrameEnabled&amp;quot; Value=&amp;quot;false&amp;quot; /&amp;gt;&lt;br /&gt;
Or set it by code:&lt;br /&gt;
 myStaticImage-&amp;gt;setFrameEnabled(false);&lt;br /&gt;
&lt;br /&gt;
=== How can I set the background of a StaticImage? ===&lt;br /&gt;
The first thing you need in order to do this is an Imageset that defines the Image that you wish to use. When wanting to use an image file for this as you suggest, you basically have an imageset defined like this:&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;Imageset Name=&amp;quot;BackdropImageset&amp;quot; Imagefile=&amp;quot;backdrop.tga&amp;quot; NativeHorzRes=&amp;quot;1024&amp;quot; NativeVertRes=&amp;quot;768&amp;quot; AutoScaled=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
 	&amp;lt;Image Name=&amp;quot;Backdrop&amp;quot; XPos=&amp;quot;0&amp;quot; YPos=&amp;quot;0&amp;quot; Width=&amp;quot;1024&amp;quot; Height=&amp;quot;768&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/Imageset&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this does is define an Imageset using the backdrop.tga. A single image &amp;quot;Backdrop&amp;quot; is defined that starts at location (0,0) and is 1024 x 768 in size. You should be careful in that the source image file should have dimensions that are powers of two - this is because the image is loaded as a texture, and may be stretched if the powers-of-two requirement is not observed.&amp;lt;br&amp;gt;&lt;br /&gt;
Once you have your imageset defined, you can load it either by adding a reference to it in whichever scheme you are loading, or manually using the ImagesetManager:&lt;br /&gt;
 CEGUI::ImagesetManager::getSingleton().createImageset(&amp;quot;myImageset.imagset&amp;quot;);&lt;br /&gt;
Once the thing is loaded, you set the image into the StaticImage like so:&lt;br /&gt;
 myStaticImage-&amp;gt;setImage(&amp;quot;BackdropImageset&amp;quot;, &amp;quot;Backdrop&amp;quot;);&lt;br /&gt;
Notice that the names we specify here are the ones that were originally specified in the imageset XML file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What properties are available for use in XML layouts, and what format do I use for the value strings? ===&lt;br /&gt;
Each widget has its properties placed within an appropriately named C++ namespace, so all you need to do is look up the appropriate namespace within the [http://www.cegui.org.uk/api_reference/namespaces.html namespaces section of the API reference].&lt;br /&gt;
&lt;br /&gt;
Also, remember that properties are inherited.  So for example, when looking up properties for a PushButton, also check the properties for ButtonBase and Window too - since these properties are also available to you.&lt;br /&gt;
&lt;br /&gt;
=== I can't see the items I've added to my Combobox, how do I get the list to show when I press the button? ===&lt;br /&gt;
&lt;br /&gt;
The height you specify for the combobox widget includes the height of the drop down list; it's not just for the 'Editbox' portion of the widget (the height of which  is usually automatically determined based upon the font).  Ensure that when specifying the height for your combobox, you have provided sufficient space for the list to appear.&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=159</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=159"/>
				<updated>2005-08-20T23:35:43Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: /* Using it all together */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; 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:&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
{&lt;br /&gt;
  _rs = _camera-&amp;gt;getRenderSurface();&lt;br /&gt;
  _kbm = new Producer::KeyboardMouse(_rs.get());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Viewer::~Viewer() {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the viewer in an Application ===&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
  _status(RUNNING), _viewer(new general::Viewer()), _sim(new example::TeapotSim()),&lt;br /&gt;
  _scheme_loader_policy(&amp;quot;MouseArrow&amp;quot;), _layout_loader_policy(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
{&lt;br /&gt;
  // OpenGL context specific initializations&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new general::InitGL());&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new prce::InitCEGUI(fontfile,_script_module));&lt;br /&gt;
  rs-&amp;gt;setWindowName(&amp;quot;Producer and CEGUI example&amp;quot;);&lt;br /&gt;
  rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
&lt;br /&gt;
  // rendering stuff&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPreDrawCallback( new SimulationDrawContext(_sim.get()) );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new prce::RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
&lt;br /&gt;
  // device input stuff&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
  prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
  kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
  kbm-&amp;gt;startThread();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The general::InitGL functor and prce::InitCEGUI functor are quite important.  These initializations are OpenGL specific, and must occur within a thread with the right OpenGL context.  The Producer::RenderSurface can execute one-time initializations if you add them to be called upon window realization.  Actually, a lot is happening here in the Application's constructor.  You might be able to imagine how OpenGL is initialized, so I'll skip that for now.  The Camera's draw callbacks are very important, but first I want to show an example of initializing CEGUI:&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
#include &amp;lt;renderers/OpenGLGUIRenderer/openglrenderer.h&amp;gt;&lt;br /&gt;
#include &amp;lt;CEGUIScriptModule.h&amp;gt;&lt;br /&gt;
#include &amp;lt;CEGUIFontManager.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;InitCEGUI.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace prce;&lt;br /&gt;
&lt;br /&gt;
InitCEGUI::InitCEGUI(const std::string&amp;amp; font, CEGUI::ScriptModule* s): _sm(s), _font(font)&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
InitCEGUI::~InitCEGUI()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void InitCEGUI::operator ()(const Producer::RenderSurface&amp;amp; rs)&lt;br /&gt;
{&lt;br /&gt;
  if( _sm )&lt;br /&gt;
    new CEGUI::System( new CEGUI::OpenGLRenderer(0), _sm );&lt;br /&gt;
  else&lt;br /&gt;
    new CEGUI::System( new CEGUI::OpenGLRenderer(0) );&lt;br /&gt;
&lt;br /&gt;
  CEGUI::FontManager* fm = CEGUI::FontManager::getSingletonPtr();&lt;br /&gt;
  CEGUI::Font* f = fm-&amp;gt;createFont( _font );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Producer uses OpenGL for rendering, so that is the renderer we must choose.  Luckily, CEGUI provides this.  You will need to provide a CEGUI::ScriptModule when initializing the System, but that is for another lesson.  A default font needs to be provided to the System, and during initialization is a good time to provide that, so my functor has required it.&lt;br /&gt;
&lt;br /&gt;
=== Rendering CEGUI with Producer ===&lt;br /&gt;
The application code showed a post draw callback being set.  Producer will execute this little callback at the right time, within the correct OpenGL context for OpenGL calls.  Here is what needs to happen for CEGUI to appear on your screen each frame:&lt;br /&gt;
&lt;br /&gt;
void RenderCEGUI::operator ()(const Producer::Camera&amp;amp; c)&lt;br /&gt;
{&lt;br /&gt;
  CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input to CEGUI via Producer ===&lt;br /&gt;
This is where the real magic happens.  You must inject inputs into CEGUI because it does not poll the operating system for you.  That is the job of a tool like Producer.  For the most part, the following code works.  There is a small bug that is only seen when resizing the Producer::RenderSurface (window).  However, I think it provides insight into how injections need to be done for CEGUI to react to user input:&lt;br /&gt;
&lt;br /&gt;
/** \author John K. Grant&lt;br /&gt;
  * \date July, 14 2005.&lt;br /&gt;
  * This code is public domain, free for use, with the author having no responsibility or liability.&lt;br /&gt;
  */&lt;br /&gt;
#include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
#include &amp;quot;SpecialKeyMapFunctor.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Injector.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace prce;&lt;br /&gt;
&lt;br /&gt;
Injector::Injector(Producer::KeyboardMouse* kbm): _kbm(kbm)&lt;br /&gt;
{&lt;br /&gt;
  prce::SpecialKeyMapFunctor specials;&lt;br /&gt;
  _keys = specials();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Injector::~Injector()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/** changes from producer coordinates to normalized CE coordinates */&lt;br /&gt;
void Injector::_producer_to_cegui(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
{&lt;br /&gt;
   // --- horizontal math&lt;br /&gt;
   // ph = 1.0 - -1.0 = 2.0    // total horizontal distance in producer&lt;br /&gt;
   // ch = 1.0 -  0.0 = 1.0    // total horizontal distance in ce&lt;br /&gt;
&lt;br /&gt;
   // --- vertical math&lt;br /&gt;
   // pv = 1.0 - -1.0 =  2.0   // total vertical distance in producer&lt;br /&gt;
   // cv = 0.0 -  1.0 = -1.0   // total vertical distance in ce&lt;br /&gt;
&lt;br /&gt;
   // cex = cx + px * (ch/2 / ph/2) = 0.5 + px * ( 0.5/1.0) = 0.5 + px*0.5&lt;br /&gt;
   // cey = cy + py * (cv/2 / pv/2) = 0.5 + py * (-0.5/1.0) = 0.5 - py*0.5&lt;br /&gt;
   // where cx is the &amp;quot;center&amp;quot; x value in ce&lt;br /&gt;
   // and   cy is the &amp;quot;center&amp;quot; y value in ce&lt;br /&gt;
   float cex(0.5 + mx*0.5);&lt;br /&gt;
   float cey(0.5 - my*0.5);&lt;br /&gt;
   mx = cex;&lt;br /&gt;
   my = cey;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/** takes normalized CEGUI coordinates and converts&lt;br /&gt;
  * into pixel values for the screen.&lt;br /&gt;
  */&lt;br /&gt;
void Injector::_convert_to_screen(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
{&lt;br /&gt;
   unsigned int width(  _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowWidth()  );&lt;br /&gt;
   unsigned int height( _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowHeight() );&lt;br /&gt;
&lt;br /&gt;
   // the above yields the same results as the code below&lt;br /&gt;
   //int wx(0), wy(0);&lt;br /&gt;
   //unsigned int width(0), height(0);&lt;br /&gt;
   //_kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowRectangle(wx,wy,width,height);&lt;br /&gt;
&lt;br /&gt;
   float pixel_x = (float)width  * mx;&lt;br /&gt;
   float pixel_y = (float)height * my;&lt;br /&gt;
   mx = pixel_x;&lt;br /&gt;
   my = pixel_y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::mouseMotion(float px,float py)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::passiveMouseMotion(float px,float py)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::buttonPress(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )  // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::buttonRelease(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )   // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::doubleButtonPress(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   /** currently is implemented to only inject a single press.&lt;br /&gt;
     * CEGUI handles its own detection of the double click via&lt;br /&gt;
     * the &amp;quot;time pulse&amp;quot;, which controls other things as well.&lt;br /&gt;
     */&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px,py);&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )   // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::mouseScroll(enum Producer::KeyboardMouseCallback::ScrollingMotion motion)&lt;br /&gt;
{&lt;br /&gt;
   switch( motion )&lt;br /&gt;
   {&lt;br /&gt;
   case Producer::KeyboardMouseCallback::ScrollDown:&lt;br /&gt;
      {&lt;br /&gt;
         CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
      } break;&lt;br /&gt;
&lt;br /&gt;
   case Producer::KeyboardMouseCallback::ScrollUp:&lt;br /&gt;
      {&lt;br /&gt;
         CEGUI::System::getSingleton().injectMouseWheelChange( 1 );&lt;br /&gt;
      } break;&lt;br /&gt;
&lt;br /&gt;
   default: // Producer::KeyboardMouseCallback::ScrollNone&lt;br /&gt;
      break;&lt;br /&gt;
   };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::keyPress(Producer::KeyCharacter key)&lt;br /&gt;
{&lt;br /&gt;
   CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
   CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( key ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::keyRelease(Producer::KeyCharacter key)&lt;br /&gt;
{&lt;br /&gt;
   CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::specialKeyPress(Producer::KeyCharacter prkey)&lt;br /&gt;
{&lt;br /&gt;
   KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
   if( iter != _keys.end() )&lt;br /&gt;
   {&lt;br /&gt;
      CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
      CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
   }&lt;br /&gt;
   CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( prkey ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::specialKeyRelease(Producer::KeyCharacter prkey)&lt;br /&gt;
{&lt;br /&gt;
   KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
   if( iter != _keys.end() )&lt;br /&gt;
   {&lt;br /&gt;
      CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
      CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
=== Using it all together ===&lt;br /&gt;
Here is what a simple main() will look like:&lt;br /&gt;
&lt;br /&gt;
int main(unsigned int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  if( argc &amp;lt; 4 )&lt;br /&gt;
  {&lt;br /&gt;
    PrintUsage();&lt;br /&gt;
    return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  Producer::ref_ptr&amp;lt;example::Application&amp;gt; app = new example::Application(argv[1]);&lt;br /&gt;
  app-&amp;gt;GetViewer()-&amp;gt;GetRenderSurface()-&amp;gt;realize();&lt;br /&gt;
&lt;br /&gt;
  app-&amp;gt;LoadCEGUIScheme( argv[2] );&lt;br /&gt;
  app-&amp;gt;LoadCEGUILayout( argv[3] );&lt;br /&gt;
&lt;br /&gt;
  while( !app-&amp;gt;IsFinished() )&lt;br /&gt;
  {&lt;br /&gt;
    app-&amp;gt;GetViewer()-&amp;gt;GetCamera()-&amp;gt;frame();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=141</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=141"/>
				<updated>2005-08-20T23:35:10Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; 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:&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
{&lt;br /&gt;
  _rs = _camera-&amp;gt;getRenderSurface();&lt;br /&gt;
  _kbm = new Producer::KeyboardMouse(_rs.get());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Viewer::~Viewer() {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the viewer in an Application ===&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
  _status(RUNNING), _viewer(new general::Viewer()), _sim(new example::TeapotSim()),&lt;br /&gt;
  _scheme_loader_policy(&amp;quot;MouseArrow&amp;quot;), _layout_loader_policy(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
{&lt;br /&gt;
  // OpenGL context specific initializations&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new general::InitGL());&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new prce::InitCEGUI(fontfile,_script_module));&lt;br /&gt;
  rs-&amp;gt;setWindowName(&amp;quot;Producer and CEGUI example&amp;quot;);&lt;br /&gt;
  rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
&lt;br /&gt;
  // rendering stuff&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPreDrawCallback( new SimulationDrawContext(_sim.get()) );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new prce::RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
&lt;br /&gt;
  // device input stuff&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
  prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
  kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
  kbm-&amp;gt;startThread();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The general::InitGL functor and prce::InitCEGUI functor are quite important.  These initializations are OpenGL specific, and must occur within a thread with the right OpenGL context.  The Producer::RenderSurface can execute one-time initializations if you add them to be called upon window realization.  Actually, a lot is happening here in the Application's constructor.  You might be able to imagine how OpenGL is initialized, so I'll skip that for now.  The Camera's draw callbacks are very important, but first I want to show an example of initializing CEGUI:&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
#include &amp;lt;renderers/OpenGLGUIRenderer/openglrenderer.h&amp;gt;&lt;br /&gt;
#include &amp;lt;CEGUIScriptModule.h&amp;gt;&lt;br /&gt;
#include &amp;lt;CEGUIFontManager.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;InitCEGUI.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace prce;&lt;br /&gt;
&lt;br /&gt;
InitCEGUI::InitCEGUI(const std::string&amp;amp; font, CEGUI::ScriptModule* s): _sm(s), _font(font)&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
InitCEGUI::~InitCEGUI()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void InitCEGUI::operator ()(const Producer::RenderSurface&amp;amp; rs)&lt;br /&gt;
{&lt;br /&gt;
  if( _sm )&lt;br /&gt;
    new CEGUI::System( new CEGUI::OpenGLRenderer(0), _sm );&lt;br /&gt;
  else&lt;br /&gt;
    new CEGUI::System( new CEGUI::OpenGLRenderer(0) );&lt;br /&gt;
&lt;br /&gt;
  CEGUI::FontManager* fm = CEGUI::FontManager::getSingletonPtr();&lt;br /&gt;
  CEGUI::Font* f = fm-&amp;gt;createFont( _font );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Producer uses OpenGL for rendering, so that is the renderer we must choose.  Luckily, CEGUI provides this.  You will need to provide a CEGUI::ScriptModule when initializing the System, but that is for another lesson.  A default font needs to be provided to the System, and during initialization is a good time to provide that, so my functor has required it.&lt;br /&gt;
&lt;br /&gt;
=== Rendering CEGUI with Producer ===&lt;br /&gt;
The application code showed a post draw callback being set.  Producer will execute this little callback at the right time, within the correct OpenGL context for OpenGL calls.  Here is what needs to happen for CEGUI to appear on your screen each frame:&lt;br /&gt;
&lt;br /&gt;
void RenderCEGUI::operator ()(const Producer::Camera&amp;amp; c)&lt;br /&gt;
{&lt;br /&gt;
  CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input to CEGUI via Producer ===&lt;br /&gt;
This is where the real magic happens.  You must inject inputs into CEGUI because it does not poll the operating system for you.  That is the job of a tool like Producer.  For the most part, the following code works.  There is a small bug that is only seen when resizing the Producer::RenderSurface (window).  However, I think it provides insight into how injections need to be done for CEGUI to react to user input:&lt;br /&gt;
&lt;br /&gt;
/** \author John K. Grant&lt;br /&gt;
  * \date July, 14 2005.&lt;br /&gt;
  * This code is public domain, free for use, with the author having no responsibility or liability.&lt;br /&gt;
  */&lt;br /&gt;
#include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
#include &amp;quot;SpecialKeyMapFunctor.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Injector.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace prce;&lt;br /&gt;
&lt;br /&gt;
Injector::Injector(Producer::KeyboardMouse* kbm): _kbm(kbm)&lt;br /&gt;
{&lt;br /&gt;
  prce::SpecialKeyMapFunctor specials;&lt;br /&gt;
  _keys = specials();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Injector::~Injector()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/** changes from producer coordinates to normalized CE coordinates */&lt;br /&gt;
void Injector::_producer_to_cegui(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
{&lt;br /&gt;
   // --- horizontal math&lt;br /&gt;
   // ph = 1.0 - -1.0 = 2.0    // total horizontal distance in producer&lt;br /&gt;
   // ch = 1.0 -  0.0 = 1.0    // total horizontal distance in ce&lt;br /&gt;
&lt;br /&gt;
   // --- vertical math&lt;br /&gt;
   // pv = 1.0 - -1.0 =  2.0   // total vertical distance in producer&lt;br /&gt;
   // cv = 0.0 -  1.0 = -1.0   // total vertical distance in ce&lt;br /&gt;
&lt;br /&gt;
   // cex = cx + px * (ch/2 / ph/2) = 0.5 + px * ( 0.5/1.0) = 0.5 + px*0.5&lt;br /&gt;
   // cey = cy + py * (cv/2 / pv/2) = 0.5 + py * (-0.5/1.0) = 0.5 - py*0.5&lt;br /&gt;
   // where cx is the &amp;quot;center&amp;quot; x value in ce&lt;br /&gt;
   // and   cy is the &amp;quot;center&amp;quot; y value in ce&lt;br /&gt;
   float cex(0.5 + mx*0.5);&lt;br /&gt;
   float cey(0.5 - my*0.5);&lt;br /&gt;
   mx = cex;&lt;br /&gt;
   my = cey;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/** takes normalized CEGUI coordinates and converts&lt;br /&gt;
  * into pixel values for the screen.&lt;br /&gt;
  */&lt;br /&gt;
void Injector::_convert_to_screen(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
{&lt;br /&gt;
   unsigned int width(  _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowWidth()  );&lt;br /&gt;
   unsigned int height( _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowHeight() );&lt;br /&gt;
&lt;br /&gt;
   // the above yields the same results as the code below&lt;br /&gt;
   //int wx(0), wy(0);&lt;br /&gt;
   //unsigned int width(0), height(0);&lt;br /&gt;
   //_kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowRectangle(wx,wy,width,height);&lt;br /&gt;
&lt;br /&gt;
   float pixel_x = (float)width  * mx;&lt;br /&gt;
   float pixel_y = (float)height * my;&lt;br /&gt;
   mx = pixel_x;&lt;br /&gt;
   my = pixel_y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::mouseMotion(float px,float py)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::passiveMouseMotion(float px,float py)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::buttonPress(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )  // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::buttonRelease(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )   // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::doubleButtonPress(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   /** currently is implemented to only inject a single press.&lt;br /&gt;
     * CEGUI handles its own detection of the double click via&lt;br /&gt;
     * the &amp;quot;time pulse&amp;quot;, which controls other things as well.&lt;br /&gt;
     */&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px,py);&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )   // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::mouseScroll(enum Producer::KeyboardMouseCallback::ScrollingMotion motion)&lt;br /&gt;
{&lt;br /&gt;
   switch( motion )&lt;br /&gt;
   {&lt;br /&gt;
   case Producer::KeyboardMouseCallback::ScrollDown:&lt;br /&gt;
      {&lt;br /&gt;
         CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
      } break;&lt;br /&gt;
&lt;br /&gt;
   case Producer::KeyboardMouseCallback::ScrollUp:&lt;br /&gt;
      {&lt;br /&gt;
         CEGUI::System::getSingleton().injectMouseWheelChange( 1 );&lt;br /&gt;
      } break;&lt;br /&gt;
&lt;br /&gt;
   default: // Producer::KeyboardMouseCallback::ScrollNone&lt;br /&gt;
      break;&lt;br /&gt;
   };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::keyPress(Producer::KeyCharacter key)&lt;br /&gt;
{&lt;br /&gt;
   CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
   CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( key ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::keyRelease(Producer::KeyCharacter key)&lt;br /&gt;
{&lt;br /&gt;
   CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::specialKeyPress(Producer::KeyCharacter prkey)&lt;br /&gt;
{&lt;br /&gt;
   KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
   if( iter != _keys.end() )&lt;br /&gt;
   {&lt;br /&gt;
      CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
      CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
   }&lt;br /&gt;
   CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( prkey ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::specialKeyRelease(Producer::KeyCharacter prkey)&lt;br /&gt;
{&lt;br /&gt;
   KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
   if( iter != _keys.end() )&lt;br /&gt;
   {&lt;br /&gt;
      CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
      CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
=== Using it all together ===&lt;br /&gt;
Here is what a simple main() will look like:&lt;br /&gt;
int main(unsigned int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  if( argc &amp;lt; 4 )&lt;br /&gt;
  {&lt;br /&gt;
    PrintUsage();&lt;br /&gt;
    return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  Producer::ref_ptr&amp;lt;example::Application&amp;gt; app = new example::Application(argv[1]);&lt;br /&gt;
  app-&amp;gt;GetViewer()-&amp;gt;GetRenderSurface()-&amp;gt;realize();&lt;br /&gt;
&lt;br /&gt;
  app-&amp;gt;LoadCEGUIScheme( argv[2] );&lt;br /&gt;
  app-&amp;gt;LoadCEGUILayout( argv[3] );&lt;br /&gt;
&lt;br /&gt;
  while( !app-&amp;gt;IsFinished() )&lt;br /&gt;
  {&lt;br /&gt;
    app-&amp;gt;GetViewer()-&amp;gt;GetCamera()-&amp;gt;frame();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=140</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=140"/>
				<updated>2005-08-20T23:32:46Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: Using CEGUI via Producer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; 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:&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
{&lt;br /&gt;
  _rs = _camera-&amp;gt;getRenderSurface();&lt;br /&gt;
  _kbm = new Producer::KeyboardMouse(_rs.get());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Viewer::~Viewer() {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the viewer in an Application ===&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
  _status(RUNNING), _viewer(new general::Viewer()), _sim(new example::TeapotSim()),&lt;br /&gt;
  _scheme_loader_policy(&amp;quot;MouseArrow&amp;quot;), _layout_loader_policy(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
{&lt;br /&gt;
  // OpenGL context specific initializations&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new general::InitGL());&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new prce::InitCEGUI(fontfile,_script_module));&lt;br /&gt;
  rs-&amp;gt;setWindowName(&amp;quot;Producer and CEGUI example&amp;quot;);&lt;br /&gt;
  rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
&lt;br /&gt;
  // rendering stuff&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPreDrawCallback( new SimulationDrawContext(_sim.get()) );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new prce::RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
&lt;br /&gt;
  // device input stuff&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
  prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
  kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
  kbm-&amp;gt;startThread();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The general::InitGL functor and prce::InitCEGUI functor are quite important.  These initializations are OpenGL specific, and must occur within a thread with the right OpenGL context.  The Producer::RenderSurface can execute one-time initializations if you add them to be called upon window realization.  Actually, a lot is happening here in the Application's constructor.  You might be able to imagine how OpenGL is initialized, so I'll skip that for now.  The Camera's draw callbacks are very important, but first I want to show an example of initializing CEGUI:&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
#include &amp;lt;renderers/OpenGLGUIRenderer/openglrenderer.h&amp;gt;&lt;br /&gt;
#include &amp;lt;CEGUIScriptModule.h&amp;gt;&lt;br /&gt;
#include &amp;lt;CEGUIFontManager.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;InitCEGUI.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace prce;&lt;br /&gt;
&lt;br /&gt;
InitCEGUI::InitCEGUI(const std::string&amp;amp; font, CEGUI::ScriptModule* s): _sm(s), _font(font)&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
InitCEGUI::~InitCEGUI()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void InitCEGUI::operator ()(const Producer::RenderSurface&amp;amp; rs)&lt;br /&gt;
{&lt;br /&gt;
  if( _sm )&lt;br /&gt;
    new CEGUI::System( new CEGUI::OpenGLRenderer(0), _sm );&lt;br /&gt;
  else&lt;br /&gt;
    new CEGUI::System( new CEGUI::OpenGLRenderer(0) );&lt;br /&gt;
&lt;br /&gt;
  CEGUI::FontManager* fm = CEGUI::FontManager::getSingletonPtr();&lt;br /&gt;
  CEGUI::Font* f = fm-&amp;gt;createFont( _font );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Producer uses OpenGL for rendering, so that is the renderer we must choose.  Luckily, CEGUI provides this.  You will need to provide a CEGUI::ScriptModule when initializing the System, but that is for another lesson.  A default font needs to be provided to the System, and during initialization is a good time to provide that, so my functor has required it.&lt;br /&gt;
&lt;br /&gt;
=== Rendering CEGUI with Producer ===&lt;br /&gt;
The application code showed a post draw callback being set.  Producer will execute this little callback at the right time, within the correct OpenGL context for OpenGL calls.  Here is what needs to happen for CEGUI to appear on your screen each frame:&lt;br /&gt;
&lt;br /&gt;
void RenderCEGUI::operator ()(const Producer::Camera&amp;amp; c)&lt;br /&gt;
{&lt;br /&gt;
  CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input to CEGUI via Producer ===&lt;br /&gt;
This is where the real magic happens.  You must inject inputs into CEGUI because it does not poll the operating system for you.  That is the job of a tool like Producer.  For the most part, the following code works.  There is a small bug that is only seen when resizing the Producer::RenderSurface (window).  However, I think it provides insight into how injections need to be done for CEGUI to react to user input:&lt;br /&gt;
&lt;br /&gt;
/** \author John K. Grant&lt;br /&gt;
  * \date July, 14 2005.&lt;br /&gt;
  * This code is public domain, free for use, with the author having no responsibility or liability.&lt;br /&gt;
  */&lt;br /&gt;
#include &amp;lt;CEGUISystem.h&amp;gt;&lt;br /&gt;
#include &amp;quot;SpecialKeyMapFunctor.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Injector.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace prce;&lt;br /&gt;
&lt;br /&gt;
Injector::Injector(Producer::KeyboardMouse* kbm): _kbm(kbm)&lt;br /&gt;
{&lt;br /&gt;
  prce::SpecialKeyMapFunctor specials;&lt;br /&gt;
  _keys = specials();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Injector::~Injector()&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/** changes from producer coordinates to normalized CE coordinates */&lt;br /&gt;
void Injector::_producer_to_cegui(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
{&lt;br /&gt;
   // --- horizontal math&lt;br /&gt;
   // ph = 1.0 - -1.0 = 2.0    // total horizontal distance in producer&lt;br /&gt;
   // ch = 1.0 -  0.0 = 1.0    // total horizontal distance in ce&lt;br /&gt;
&lt;br /&gt;
   // --- vertical math&lt;br /&gt;
   // pv = 1.0 - -1.0 =  2.0   // total vertical distance in producer&lt;br /&gt;
   // cv = 0.0 -  1.0 = -1.0   // total vertical distance in ce&lt;br /&gt;
&lt;br /&gt;
   // cex = cx + px * (ch/2 / ph/2) = 0.5 + px * ( 0.5/1.0) = 0.5 + px*0.5&lt;br /&gt;
   // cey = cy + py * (cv/2 / pv/2) = 0.5 + py * (-0.5/1.0) = 0.5 - py*0.5&lt;br /&gt;
   // where cx is the &amp;quot;center&amp;quot; x value in ce&lt;br /&gt;
   // and   cy is the &amp;quot;center&amp;quot; y value in ce&lt;br /&gt;
   float cex(0.5 + mx*0.5);&lt;br /&gt;
   float cey(0.5 - my*0.5);&lt;br /&gt;
   mx = cex;&lt;br /&gt;
   my = cey;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/** takes normalized CEGUI coordinates and converts&lt;br /&gt;
  * into pixel values for the screen.&lt;br /&gt;
  */&lt;br /&gt;
void Injector::_convert_to_screen(float&amp;amp; mx, float&amp;amp; my)&lt;br /&gt;
{&lt;br /&gt;
   unsigned int width(  _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowWidth()  );&lt;br /&gt;
   unsigned int height( _kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowHeight() );&lt;br /&gt;
&lt;br /&gt;
   // the above yields the same results as the code below&lt;br /&gt;
   //int wx(0), wy(0);&lt;br /&gt;
   //unsigned int width(0), height(0);&lt;br /&gt;
   //_kbm-&amp;gt;getRenderSurface()-&amp;gt;getWindowRectangle(wx,wy,width,height);&lt;br /&gt;
&lt;br /&gt;
   float pixel_x = (float)width  * mx;&lt;br /&gt;
   float pixel_y = (float)height * my;&lt;br /&gt;
   mx = pixel_x;&lt;br /&gt;
   my = pixel_y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::mouseMotion(float px,float py)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::passiveMouseMotion(float px,float py)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::buttonPress(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )  // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::buttonRelease(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px, py);&lt;br /&gt;
&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )   // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::doubleButtonPress(float px,float py,unsigned int button)&lt;br /&gt;
{&lt;br /&gt;
   /** currently is implemented to only inject a single press.&lt;br /&gt;
     * CEGUI handles its own detection of the double click via&lt;br /&gt;
     * the &amp;quot;time pulse&amp;quot;, which controls other things as well.&lt;br /&gt;
     */&lt;br /&gt;
   _producer_to_cegui(px,py);&lt;br /&gt;
   _convert_to_screen(px,py);&lt;br /&gt;
   CEGUI::System::getSingleton().injectMousePosition(px,py);&lt;br /&gt;
   if( button == 1 )  // left&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 2 )  // middle&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
&lt;br /&gt;
   else if( button == 3 )   // right&lt;br /&gt;
      CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::mouseScroll(enum Producer::KeyboardMouseCallback::ScrollingMotion motion)&lt;br /&gt;
{&lt;br /&gt;
   switch( motion )&lt;br /&gt;
   {&lt;br /&gt;
   case Producer::KeyboardMouseCallback::ScrollDown:&lt;br /&gt;
      {&lt;br /&gt;
         CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
      } break;&lt;br /&gt;
&lt;br /&gt;
   case Producer::KeyboardMouseCallback::ScrollUp:&lt;br /&gt;
      {&lt;br /&gt;
         CEGUI::System::getSingleton().injectMouseWheelChange( 1 );&lt;br /&gt;
      } break;&lt;br /&gt;
&lt;br /&gt;
   default: // Producer::KeyboardMouseCallback::ScrollNone&lt;br /&gt;
      break;&lt;br /&gt;
   };&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::keyPress(Producer::KeyCharacter key)&lt;br /&gt;
{&lt;br /&gt;
   CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
   CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( key ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::keyRelease(Producer::KeyCharacter key)&lt;br /&gt;
{&lt;br /&gt;
   CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(key) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::specialKeyPress(Producer::KeyCharacter prkey)&lt;br /&gt;
{&lt;br /&gt;
   KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
   if( iter != _keys.end() )&lt;br /&gt;
   {&lt;br /&gt;
      CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
      CEGUI::System::getSingleton().injectKeyDown( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
   }&lt;br /&gt;
   CEGUI::System::getSingleton().injectChar( static_cast&amp;lt;CEGUI::utf32&amp;gt;( prkey ) );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Injector::specialKeyRelease(Producer::KeyCharacter prkey)&lt;br /&gt;
{&lt;br /&gt;
   KeyMap::iterator iter = _keys.find( prkey );&lt;br /&gt;
   if( iter != _keys.end() )&lt;br /&gt;
   {&lt;br /&gt;
      CEGUI::Key::Scan cekey = (*iter).second;&lt;br /&gt;
      CEGUI::System::getSingleton().injectKeyUp( static_cast&amp;lt;CEGUI::uint&amp;gt;(cekey) );&lt;br /&gt;
   }&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=139</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=139"/>
				<updated>2005-08-20T23:06:38Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; 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:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
#include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
{&lt;br /&gt;
  _rs = _camera-&amp;gt;getRenderSurface();&lt;br /&gt;
  _kbm = new Producer::KeyboardMouse(_rs.get());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Viewer::~Viewer() {}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
=== Using the viewer in an Application ===&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
  _status(RUNNING), _viewer(new general::Viewer()), _sim(new example::TeapotSim()),&lt;br /&gt;
  _scheme_loader_policy(&amp;quot;MouseArrow&amp;quot;), _layout_loader_policy(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
{&lt;br /&gt;
  // OpenGL context specific initializations&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new general::InitGL());&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new prce::InitCEGUI(fontfile,_script_module));&lt;br /&gt;
  rs-&amp;gt;setWindowName(&amp;quot;Producer and CEGUI example&amp;quot;);&lt;br /&gt;
  rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
&lt;br /&gt;
  // rendering stuff&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPreDrawCallback( new SimulationDrawContext(_sim.get()) );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new prce::RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
&lt;br /&gt;
  // device input stuff&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
  prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
  kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
  kbm-&amp;gt;startThread();&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=138</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=138"/>
				<updated>2005-08-20T23:05:31Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; 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:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
#include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
{&lt;br /&gt;
  _rs = _camera-&amp;gt;getRenderSurface();&lt;br /&gt;
  _kbm = new Producer::KeyboardMouse(_rs.get());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Viewer::~Viewer() {}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
And an application might use this viewer, doing some important initializations:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
Application::Application(const std::string&amp;amp; fontfile):&lt;br /&gt;
  _status(RUNNING), _viewer(new general::Viewer()), _sim(new example::TeapotSim()),&lt;br /&gt;
  _scheme_loader_policy(&amp;quot;MouseArrow&amp;quot;), _layout_loader_policy(), _script_module(new ApplicationEventHandler())&lt;br /&gt;
{&lt;br /&gt;
  // OpenGL context specific initializations&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::RenderSurface&amp;gt; rs = _viewer-&amp;gt;GetRenderSurface();&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new general::InitGL());&lt;br /&gt;
  rs-&amp;gt;addRealizeCallback(new prce::InitCEGUI(fontfile,_script_module));&lt;br /&gt;
  rs-&amp;gt;setWindowName(&amp;quot;Producer and CEGUI example&amp;quot;);&lt;br /&gt;
  rs-&amp;gt;setWindowRectangle(20,50,800,600);&lt;br /&gt;
&lt;br /&gt;
  // rendering stuff&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;setSceneHandler( _sim.get() );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPreDrawCallback( new SimulationDrawContext(_sim.get()) );&lt;br /&gt;
  _viewer-&amp;gt;GetCamera()-&amp;gt;addPostDrawCallback(new prce::RenderCEGUI() ); // renders the GUI over scene&lt;br /&gt;
&lt;br /&gt;
  // device input stuff&lt;br /&gt;
  Producer::ref_ptr&amp;lt;Producer::KeyboardMouse&amp;gt; kbm = _viewer-&amp;gt;GetKeyboardMouse();&lt;br /&gt;
  prce::Injector* injector = new prce::Injector( kbm.get() );&lt;br /&gt;
  kbm-&amp;gt;setCallback( injector );&lt;br /&gt;
  kbm-&amp;gt;startThread();&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=137</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=137"/>
				<updated>2005-08-20T23:00:59Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: Using CEGUI via Producer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;br /&gt;
&lt;br /&gt;
=== Defining a Producer Viewer ===&lt;br /&gt;
The first step is to create some sort of &amp;quot;viewer&amp;quot; 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:&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Viewer.h&amp;quot;&lt;br /&gt;
Viewer::Viewer() : _camera(new Producer::Camera()), _rs(0), _kbm(0)&lt;br /&gt;
{&lt;br /&gt;
  _rs = _camera-&amp;gt;getRenderSurface();&lt;br /&gt;
  _kbm = new Producer::KeyboardMouse(_rs.get());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Viewer::~Viewer() {}&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=136</id>
		<title>Using CEGUI with Producer and OpenGL</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_Producer_and_OpenGL&amp;diff=136"/>
				<updated>2005-08-20T22:33:24Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.andesengineering.com/Producer/ 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.&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Tutorials&amp;diff=200</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Tutorials&amp;diff=200"/>
				<updated>2005-08-20T22:25:52Z</updated>
		
		<summary type="html">&lt;p&gt;Granx: /* Window System Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== CrazyEddie's Beginner Guides ===&lt;br /&gt;
* [[The Beginner Guide to Getting CEGUI Rendering]] - How to initialise CEGUI to render properly.&lt;br /&gt;
* [[The Beginner Guide to Loading Data Files and Initialisation]] - How to load some data files and perform basic system initialisation.&lt;br /&gt;
* [[The Beginner Guide to Creating a CEGUI Window]] - How to create a simple window and get it on screen.&lt;br /&gt;
* [[The Beginner Guide to Injecting Inputs]] - How to inject inputs into CEGUI and get interactive.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lua Scripting with CEGUI ===&lt;br /&gt;
* [[Getting Started with Lua and CEGUI]] - How to initialise CEGUI with a Lua script module and configuration file.&lt;br /&gt;
* [[Handling Events from Lua]] - How to load Lua script files and bind CEGUI events to Lua functions.&lt;br /&gt;
* [[Writing CEGUI scripts]] - Code snippets&lt;br /&gt;
* [[Adding LuaScriptModile to Sample_FirstWindow]] - Experience adding scripting to an existing sample.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Window System Examples ===&lt;br /&gt;
* [[Using CEGUI with SDL and OpenGL]] - Guidelines on how to get SDL, OpenGL and CEGUI running together.&lt;br /&gt;
* [[Using CEGUI with Producer and OpenGL]] - Guidelines on how to render and inject input to CEGUI from the Producer API.&lt;/div&gt;</summary>
		<author><name>Granx</name></author>	</entry>

	</feed>