<?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=Dermont</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=Dermont"/>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/Special:Contributions/Dermont"/>
		<updated>2026-06-23T14:14:01Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Wiki_Cache_problem&amp;diff=5674</id>
		<title>Wiki Cache problem</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Wiki_Cache_problem&amp;diff=5674"/>
				<updated>2015-04-06T00:09:44Z</updated>
		
		<summary type="html">&lt;p&gt;Dermont: Test Problem with Wiki Cache&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Testing Problem with Wiki Cache.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Dermont</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_SDL_and_OpenGL_(0.7)&amp;diff=5673</id>
		<title>Using CEGUI with SDL and OpenGL (0.7)</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_SDL_and_OpenGL_(0.7)&amp;diff=5673"/>
				<updated>2015-04-06T00:05:11Z</updated>
		
		<summary type="html">&lt;p&gt;Dermont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.7}}&lt;br /&gt;
&lt;br /&gt;
TESTING WIKI CACHE PROBLEM EDIT II.&lt;br /&gt;
&lt;br /&gt;
TESTING WIKI CACHE PROBLEM.&lt;br /&gt;
&lt;br /&gt;
[http://www.libsdl.org SDL (Simple DirectMedia Layer)] is an excellent library for writing portable games and other multimedia applications, but as it is a low-level library, it has no native support for GUI interfaces.&lt;br /&gt;
&lt;br /&gt;
When using [http://www.opengl.org OpenGL] for rendering, using CEGUI with SDL is not hard.&lt;br /&gt;
&lt;br /&gt;
I'll assume that you've read the imbiciles tutorials, and have used SDL with OpenGL.&lt;br /&gt;
And know C / C++ ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Initialisation ===&lt;br /&gt;
Before we can do anything, we need to initialise our libraries.&lt;br /&gt;
First SDL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
if (SDL_Init(SDL_INIT_VIDEO)&amp;lt;0)&lt;br /&gt;
{&lt;br /&gt;
  fprintf(stderr, &amp;quot;Unable to initialise SDL: %s&amp;quot;, SDL_GetError());&lt;br /&gt;
  exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we initialise SDL with video support. We need this for CEGUI.&lt;br /&gt;
O.K. now SDL is ready to go. So let's fire up OpenGL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
if (SDL_SetVideoMode(800,600,0,SDL_OPENGL)==NULL)&lt;br /&gt;
{&lt;br /&gt;
  fprintf(stderr, &amp;quot;Unable to set OpenGL videomode: %s&amp;quot;, SDL_GetError());&lt;br /&gt;
  SDL_Quit();&lt;br /&gt;
  exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now OpenGL is ready. But we still need to set a decent configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
glEnable(GL_CULL_FACE);&lt;br /&gt;
glDisable(GL_FOG);&lt;br /&gt;
glClearColor(0.0f,0.0f,0.0f,1.0f);&lt;br /&gt;
glViewport(0,0, 800,600);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The OpenGL renderer that comes with CEGUI sets the matrices itself, so if you're using CEGUI for all your rendering needs this would be fine. Normally you would want the normal perspective projection setup though:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
glMatrixMode(GL_PROJECTION);&lt;br /&gt;
glLoadIdentity();&lt;br /&gt;
gluPerspective(45.0, 800.0/600.0, 0.1,100.0);&lt;br /&gt;
glMatrixMode(GL_MODELVIEW);&lt;br /&gt;
glLoadIdentity();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SDL and OpenGL are now both ready for action. So it's time to initialise CEGUI.&lt;br /&gt;
This new &amp;quot;bootstrap&amp;quot; method in 0.7 is much simpler than the previous methods, it is one simple call&lt;br /&gt;
&lt;br /&gt;
First we need the include (Usually everything you need can be found in &amp;lt;CEGUI/CEGUI.h&amp;gt; but for initialising a specific subsystem you need to do this&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;CEGUI/RendererModules/OpenGL/CEGUIOpenGLRenderer.h&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the call to initialise everything&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::OpenGLRenderer::bootstrapSystem();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that you have to load a widget set, set the mouse cursor and a default font before CEGUI is completely ready. This is described in the other tutorials.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the SDL cursor is displayed, so we'll remove that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
SDL_ShowCursor(SDL_DISABLE);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As keypress characters needs to be injected into CEGUI, we activate unicode translation for SDL key events:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
SDL_EnableUNICODE(1);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it alot easier as we don't have to worry about modifier keys and keyboard layouts ourselves. More about this later on...&lt;br /&gt;
&lt;br /&gt;
Key repeat is a nice feature for the text input widgets in CEGUI, so we use SDL to generate them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Everything is ready now, and we can start the main loop :)&lt;br /&gt;
&lt;br /&gt;
=== The Main Loop ===&lt;br /&gt;
To make it all happen, we use a simple main loop that just keeps pushing on those frames:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void main_loop()&lt;br /&gt;
{&lt;br /&gt;
  bool must_quit = false;&lt;br /&gt;
  &lt;br /&gt;
  // get &amp;quot;run-time&amp;quot; in seconds&lt;br /&gt;
  double last_time_pulse = 0.001*static_cast&amp;lt;double&amp;gt;(SDL_GetTicks());&lt;br /&gt;
  &lt;br /&gt;
  while (!must_quit)&lt;br /&gt;
  {&lt;br /&gt;
    inject_input(must_quit);&lt;br /&gt;
    inject_time_pulse(last_time_pulse);&lt;br /&gt;
    render_gui();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function will run the main loop until the ''bool'' value ''must_quit'' becomes ''true''. In this tutorial this will happen when the user clicks the close button provided by the window manager.&lt;br /&gt;
&lt;br /&gt;
The ''double'' value ''last_time_pulse'' holds the time of the latest time pulse injection. More about this later.&lt;br /&gt;
&lt;br /&gt;
Each function in the ''while'' loop will be described below.&lt;br /&gt;
&lt;br /&gt;
There are endless ways of making your main loop. I took a simple approach to ease writing this tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input and injecting change of window size ===&lt;br /&gt;
When the user press or release keyboard or mouse buttons, we need to tell CEGUI about it, for this we use the injection functions of ''CEGUI::System''. We also have to tell &lt;br /&gt;
&lt;br /&gt;
Here is what our inject_input function looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void inject_input(bool&amp;amp; must_quit)&lt;br /&gt;
{&lt;br /&gt;
  SDL_Event e;&lt;br /&gt;
  &lt;br /&gt;
  // go through all available events&lt;br /&gt;
  while (SDL_PollEvent(&amp;amp;e))&lt;br /&gt;
  {&lt;br /&gt;
    // we use a switch to determine the event type&lt;br /&gt;
    switch (e.type)&lt;br /&gt;
    {&lt;br /&gt;
      // mouse motion handler&lt;br /&gt;
      case SDL_MOUSEMOTION:&lt;br /&gt;
        // we inject the mouse position directly.&lt;br /&gt;
        CEGUI::System::getSingleton().injectMousePosition(&lt;br /&gt;
          static_cast&amp;lt;float&amp;gt;(e.motion.x),&lt;br /&gt;
          static_cast&amp;lt;float&amp;gt;(e.motion.y)&lt;br /&gt;
        );&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
      // mouse down handler&lt;br /&gt;
      case SDL_MOUSEBUTTONDOWN:&lt;br /&gt;
        // let a special function handle the mouse button down event&lt;br /&gt;
        handle_mouse_down(e.button.button);&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
      // mouse up handler&lt;br /&gt;
      case SDL_MOUSEBUTTONUP:&lt;br /&gt;
        // let a special function handle the mouse button up event&lt;br /&gt;
        handle_mouse_up(e.button.button);&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      // key down&lt;br /&gt;
      case SDL_KEYDOWN:&lt;br /&gt;
        // to tell CEGUI that a key was pressed, we inject the scancode.&lt;br /&gt;
        CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);&lt;br /&gt;
        &lt;br /&gt;
        // as for the character it's a litte more complicated. we'll use for translated unicode value.&lt;br /&gt;
        // this is described in more detail below.&lt;br /&gt;
        if ((e.key.keysym.unicode != 0)&lt;br /&gt;
        {&lt;br /&gt;
          CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode);&lt;br /&gt;
        }&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
      // key up&lt;br /&gt;
      case SDL_KEYUP:&lt;br /&gt;
        // like before we inject the scancode directly.&lt;br /&gt;
        CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      // WM quit event occured&lt;br /&gt;
      case SDL_QUIT:&lt;br /&gt;
        must_quit = true;&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First I'll explain the events that get handled directly in the ''inject_input'' function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mouse Motion''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// we inject the mouse position directly.&lt;br /&gt;
CEGUI::System::getSingleton().injectMousePosition(&lt;br /&gt;
  static_cast&amp;lt;float&amp;gt;(e.motion.x),&lt;br /&gt;
  static_cast&amp;lt;float&amp;gt;(e.motion.y)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is nothing special here. Like stated in the comment the mouse position is just injected directly.&lt;br /&gt;
&lt;br /&gt;
There are two ways of injecting mouse motion. One where you inject how much the cursor moved, and one where you inject the mouse cursor position. The last one is failsafe.&lt;br /&gt;
Then first one only works correctly in fullscreen mode, or with input grabbed. The reason for this is that in regular windowed mode, the mouse can be moved outside the application window, and during this time no mouse motion event are generated. So if we enter the window at another position, the real mousecursor and CEGUI's mouse cursor will be offset, which will break mouse usage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key Down'''&amp;lt;br /&amp;gt;&lt;br /&gt;
This event takes a little more work. CEGUI requires that key characters (the printable character the key represents) are injected alongside key codes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// to tell CEGUI that a key was pressed, we inject the scancode.&lt;br /&gt;
CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Luckily the key code is just the SDL scancode, so we inject that directly. (This only seems to be true on windows. On other platforms you will need to use a translation function. One can be found here [[SDL to CEGUI keytable]])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// as for the character it's a litte more complicated. we'll use for translated unicode value.&lt;br /&gt;
// this is described in more detail below.&lt;br /&gt;
if (e.key.keysym.unicode != 0)&lt;br /&gt;
{&lt;br /&gt;
  CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of formatting the keypress ourselves, we let SDL do it for us. We could check if we actually got a valid ASCII code, but we want support for local characters as well, so we won't do that. For more information, take a look at the SDL documentation for this feature. [http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fkeysym SDL_keysym].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key Up'''&amp;lt;br /&amp;gt;&lt;br /&gt;
This one is simple. Only the keycode need to injected. So we just use the scancode directly (As with KeyDown you will need to use a translation function for non Windows platforms. Check KeyDown above for more info):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// like before we inject the scancode directly.&lt;br /&gt;
CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mouse Button Down and Mouse Wheel'''&amp;lt;br /&amp;gt;&lt;br /&gt;
CEGUI and SDL are a little different when it comes to mouse button and mouse wheel events. So a little conversion is necessary. Here's the ''handle_mouse_down'' function that gets called when a mouse button down event occurs in SDL. It takes one parameter, a ''Uint8'' describing the mouse button that was pressed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void handle_mouse_down(Uint8 button)&lt;br /&gt;
	{&lt;br /&gt;
	switch ( button )&lt;br /&gt;
		{&lt;br /&gt;
		// handle real mouse buttons&lt;br /&gt;
		case SDL_BUTTON_LEFT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_MIDDLE:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_RIGHT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
			break;&lt;br /&gt;
		&lt;br /&gt;
		// handle the mouse wheel&lt;br /&gt;
		case SDL_BUTTON_WHEELDOWN:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_WHEELUP:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseWheelChange( +1 );&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I chose a very &amp;quot;manual&amp;quot; conversion, but it works fine. Everything should be pretty self-explainatory.&lt;br /&gt;
As you can see mouse wheel events are emitted as mouse button down events in SDL.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mouse Button Up'''&amp;lt;br /&amp;gt;&lt;br /&gt;
The mouse button up event is handled very much like the mouse button down event, except there are no mousewheel release events.&lt;br /&gt;
Like ''handle_mouse_down'' it takes one parameter, a ''Uint8'' describing the mouse button that was released:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void handle_mouse_up(Uint8 button)&lt;br /&gt;
	{&lt;br /&gt;
	switch ( button )&lt;br /&gt;
		{&lt;br /&gt;
		case SDL_BUTTON_LEFT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_MIDDLE:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_RIGHT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Time Pulses ===&lt;br /&gt;
SDL has a built-in millisecond counter which we will use for this example. There are other ways to use timers with SDL, but I chose this approach as it is simple to use, and provides decent precision.&lt;br /&gt;
&lt;br /&gt;
Remember in the main loop where we stored the current &amp;quot;run-time&amp;quot; in seconds ? This value will be passed as a reference to ''inject_time_pulse'' function which in turn will set a new value to it.&lt;br /&gt;
&lt;br /&gt;
CEGUI's interface for injecting time pulses requires that you pass the time in seconds that has passed since the last time pulse injection. Let's take a look at the function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void inject_time_pulse(double&amp;amp; last_time_pulse)&lt;br /&gt;
{&lt;br /&gt;
	// get current &amp;quot;run-time&amp;quot; in seconds&lt;br /&gt;
	double t = 0.001*SDL_GetTicks();&lt;br /&gt;
&lt;br /&gt;
	// inject the time that passed since the last call &lt;br /&gt;
	CEGUI::System::getSingleton().injectTimePulse( float(t-last_time_pulse) );&lt;br /&gt;
&lt;br /&gt;
	// store the new time as the last time&lt;br /&gt;
	last_time_pulse = t;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The first line gets the actual &amp;quot;run-time&amp;quot; when called.&lt;br /&gt;
* The second line injects the time pulse as the difference between the current time and the last time.&lt;br /&gt;
* The third line stores the current time as the last time a time pulse was injected.&lt;br /&gt;
&lt;br /&gt;
This will work for about 47 days... After that the counter wraps to zero and it breaks (a single insanely invalid timepulse will be injected).&lt;br /&gt;
I'll leave it up to you to fix that if it's a problem.&lt;br /&gt;
&lt;br /&gt;
=== Change of window size ===&lt;br /&gt;
If the window size changes (e.g. switching to fullscreen mode), we have to tell the openGlRenderer what's the new window size. Otherwise e.g. the Fonts aren't scaled properly. Therefore we add an SDL Event Handler for SDL_VIDEORESIZE and submit the new window size to the openGlRenderer of CEGUI.&lt;br /&gt;
If you have used previous versions you will know that you have to do some stuff here to stop textures from being skewed, but that is no longer an issue&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
      case SDL_VIDEORESIZE:&lt;br /&gt;
            //your resize code here, including the SDL_SetVideoMode call&lt;br /&gt;
            CEGUI::System::getSingleton().getRenderer()-&amp;gt;setDisplaySize(CEGUI::Size(event.resize.w, event.resize.h));&lt;br /&gt;
            break;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rendering ===&lt;br /&gt;
Now all that's left is renderingthe GUI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void render_gui()&lt;br /&gt;
{&lt;br /&gt;
	// clear the colour buffer&lt;br /&gt;
	glClear( GL_COLOR_BUFFER_BIT );&lt;br /&gt;
&lt;br /&gt;
	// render the GUI :)&lt;br /&gt;
	CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
&lt;br /&gt;
	// Update the screen&lt;br /&gt;
	SDL_GL_SwapBuffers();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
does all the CEGUI magic and sets OpenGL state itself. As long as the viewport is setup, it will render the GUI.&lt;br /&gt;
&lt;br /&gt;
=== Error Handling ===&lt;br /&gt;
The neat C++ architecture of CEGUI suggests that C++ exceptions are used for error handling. This is completely true.&lt;br /&gt;
Whenever an error occurs, a sub-class of ''CEGUI::Exception'' is thrown.&lt;br /&gt;
&lt;br /&gt;
There are many scenarios where an exception can be thrown. And whether or not these should be considered fatal depends on the application. To make sure you catch the CEGUI exceptions a regular ''try'' block is used. Like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
	// do some cegui code&lt;br /&gt;
}&lt;br /&gt;
catch (CEGUI::Exception&amp;amp; e)&lt;br /&gt;
{&lt;br /&gt;
	fprintf(stderr,&amp;quot;CEGUI Exception occured: %s&amp;quot;, e.getMessage().c_str());&lt;br /&gt;
	// you could quit here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should provide you with the basic steps needed to get interactive with CEGUI in your SDL application.&lt;br /&gt;
Have fun.&lt;br /&gt;
&lt;br /&gt;
=== The Code ===&lt;br /&gt;
To compile under linux:&lt;br /&gt;
&amp;lt;code&amp;gt;g++ teste.cpp -I/usr/include/CEGUI/ -lSDL -lGL -lGLU -lCEGUIBase -lCEGUIOpenGLRenderer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Adapted by: Johnny Souza - johnnysouza.js@gmail.com&lt;br /&gt;
 * Date: 19/01/07 17:00&lt;br /&gt;
 * Description: Using CEGUI with SDL and OpenGL&lt;br /&gt;
 */&lt;br /&gt;
  &lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;CEGUI.h&amp;gt;&lt;br /&gt;
#include &amp;lt;RendererModules/OpenGL/CEGUIOpenGLRenderer.h&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
#include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;GL/glu.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void handle_mouse_down(Uint8 button)&lt;br /&gt;
{&lt;br /&gt;
	switch ( button ) {&lt;br /&gt;
		case SDL_BUTTON_LEFT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_MIDDLE:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_RIGHT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
			break;&lt;br /&gt;
&lt;br /&gt;
		case SDL_BUTTON_WHEELDOWN:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_WHEELUP:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseWheelChange( +1 );&lt;br /&gt;
			break;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void handle_mouse_up(Uint8 button)&lt;br /&gt;
{&lt;br /&gt;
	switch ( button )&lt;br /&gt;
	{&lt;br /&gt;
		case SDL_BUTTON_LEFT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_MIDDLE:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_RIGHT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
			break;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void inject_input (bool &amp;amp; must_quit) &lt;br /&gt;
{&lt;br /&gt;
	SDL_Event e;&lt;br /&gt;
	/* go through all available events */&lt;br /&gt;
	while (SDL_PollEvent(&amp;amp;e)) {&lt;br /&gt;
		/* we use a switch to determine the event type */&lt;br /&gt;
		switch (e.type) {&lt;br /&gt;
			/* mouse motion handler */&lt;br /&gt;
			case SDL_MOUSEMOTION:&lt;br /&gt;
				/* we inject the mouse position directly. */&lt;br /&gt;
				CEGUI::System::getSingleton().injectMousePosition(static_cast&amp;lt;float&amp;gt;(e.motion.x),static_cast&amp;lt;float&amp;gt;(e.motion.y));&lt;br /&gt;
				break;&lt;br /&gt;
	 &lt;br /&gt;
			/* mouse down handler */&lt;br /&gt;
			case SDL_MOUSEBUTTONDOWN:&lt;br /&gt;
				/* let a special function handle the mouse button down event */&lt;br /&gt;
				handle_mouse_down (e.button.button);&lt;br /&gt;
				break;&lt;br /&gt;
&lt;br /&gt;
			/* mouse up handler */&lt;br /&gt;
			case SDL_MOUSEBUTTONUP:&lt;br /&gt;
				/* let a special function handle the mouse button up event */&lt;br /&gt;
				handle_mouse_up (e.button.button);&lt;br /&gt;
				break;&lt;br /&gt;
&lt;br /&gt;
			/* key down */&lt;br /&gt;
			case SDL_KEYDOWN:&lt;br /&gt;
				/* to tell CEGUI that a key was pressed, we inject the scancode. */&lt;br /&gt;
				CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);&lt;br /&gt;
				/* as for the character it's a litte more complicated.&lt;br /&gt;
				 * we'll use for translated unicode value.&lt;br /&gt;
				 * this is described in more detail below.&lt;br /&gt;
				 */&lt;br /&gt;
				if ((e.key.keysym.unicode &amp;amp; 0xFF80) == 0) {&lt;br /&gt;
					CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode &amp;amp; 0x7F);&lt;br /&gt;
				}&lt;br /&gt;
				break;&lt;br /&gt;
	 &lt;br /&gt;
			/* key up */&lt;br /&gt;
			case SDL_KEYUP:&lt;br /&gt;
				/* like before we inject the scancode directly. */&lt;br /&gt;
				CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);&lt;br /&gt;
				break;&lt;br /&gt;
	 &lt;br /&gt;
			/* WM quit event occured */&lt;br /&gt;
			case SDL_QUIT:&lt;br /&gt;
				must_quit = true;&lt;br /&gt;
				break;&lt;br /&gt;
&lt;br /&gt;
			case SDL_VIDEORESIZE:&lt;br /&gt;
				CEGUI::System::getSingleton().notifyDisplaySizeChanged(CEGUI::Size(e.resize.w,e.resize.h));&lt;br /&gt;
				break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void inject_time_pulse(double&amp;amp; last_time_pulse)&lt;br /&gt;
{&lt;br /&gt;
	/* get current &amp;quot;run-time&amp;quot; in seconds */&lt;br /&gt;
	double t = 0.001*SDL_GetTicks();&lt;br /&gt;
	/* inject the time that passed since the last call */&lt;br /&gt;
	CEGUI::System::getSingleton().injectTimePulse( float(t-last_time_pulse) );&lt;br /&gt;
	/* store the new time as the last time */&lt;br /&gt;
	last_time_pulse = t;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void render_gui()&lt;br /&gt;
{&lt;br /&gt;
	/* clear the colour buffer */&lt;br /&gt;
	glClear( GL_COLOR_BUFFER_BIT );&lt;br /&gt;
	/* render the GUI :) */&lt;br /&gt;
	CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
	/* Update the screen */&lt;br /&gt;
	SDL_GL_SwapBuffers();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void main_loop () &lt;br /&gt;
{&lt;br /&gt;
	bool must_quit = false;&lt;br /&gt;
	/* get &amp;quot;run-time&amp;quot; in seconds */&lt;br /&gt;
	double last_time_pulse = 0.001*static_cast&amp;lt;double&amp;gt;(SDL_GetTicks());&lt;br /&gt;
	while (!must_quit) {&lt;br /&gt;
		inject_input (must_quit);&lt;br /&gt;
		inject_time_pulse (last_time_pulse);&lt;br /&gt;
		render_gui ();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main (int argc, char **argv) &lt;br /&gt;
{&lt;br /&gt;
	SDL_Surface * screen;&lt;br /&gt;
	atexit (SDL_Quit);&lt;br /&gt;
	SDL_Init (SDL_INIT_VIDEO);&lt;br /&gt;
	screen = SDL_SetVideoMode (600, 480, 0, SDL_OPENGL);&lt;br /&gt;
	if (screen == NULL) {&lt;br /&gt;
		/* Se ainda não der, desiste! */ &lt;br /&gt;
		fprintf (stderr, &amp;quot;Impossível ajustar ao vídeo: %s\n&amp;quot;, SDL_GetError ());&lt;br /&gt;
		exit (1);&lt;br /&gt;
	}&lt;br /&gt;
        CEGUI::OpenGLRenderer::bootstrapSystem();&lt;br /&gt;
	SDL_ShowCursor (SDL_DISABLE);&lt;br /&gt;
	SDL_EnableUNICODE (1);&lt;br /&gt;
	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);&lt;br /&gt;
	main_loop();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Lindquist]] 16:21, 8 May 2005 (BST)&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Dermont</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_CEGUI_with_SDL_and_OpenGL_(0.7)&amp;diff=5672</id>
		<title>Using CEGUI with SDL and OpenGL (0.7)</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_CEGUI_with_SDL_and_OpenGL_(0.7)&amp;diff=5672"/>
				<updated>2015-04-05T23:58:03Z</updated>
		
		<summary type="html">&lt;p&gt;Dermont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.7}}&lt;br /&gt;
&lt;br /&gt;
TESTING WIKI CACHE PROBLEM.&lt;br /&gt;
&lt;br /&gt;
[http://www.libsdl.org SDL (Simple DirectMedia Layer)] is an excellent library for writing portable games and other multimedia applications, but as it is a low-level library, it has no native support for GUI interfaces.&lt;br /&gt;
&lt;br /&gt;
When using [http://www.opengl.org OpenGL] for rendering, using CEGUI with SDL is not hard.&lt;br /&gt;
&lt;br /&gt;
I'll assume that you've read the imbiciles tutorials, and have used SDL with OpenGL.&lt;br /&gt;
And know C / C++ ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Initialisation ===&lt;br /&gt;
Before we can do anything, we need to initialise our libraries.&lt;br /&gt;
First SDL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
if (SDL_Init(SDL_INIT_VIDEO)&amp;lt;0)&lt;br /&gt;
{&lt;br /&gt;
  fprintf(stderr, &amp;quot;Unable to initialise SDL: %s&amp;quot;, SDL_GetError());&lt;br /&gt;
  exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we initialise SDL with video support. We need this for CEGUI.&lt;br /&gt;
O.K. now SDL is ready to go. So let's fire up OpenGL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
if (SDL_SetVideoMode(800,600,0,SDL_OPENGL)==NULL)&lt;br /&gt;
{&lt;br /&gt;
  fprintf(stderr, &amp;quot;Unable to set OpenGL videomode: %s&amp;quot;, SDL_GetError());&lt;br /&gt;
  SDL_Quit();&lt;br /&gt;
  exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now OpenGL is ready. But we still need to set a decent configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
glEnable(GL_CULL_FACE);&lt;br /&gt;
glDisable(GL_FOG);&lt;br /&gt;
glClearColor(0.0f,0.0f,0.0f,1.0f);&lt;br /&gt;
glViewport(0,0, 800,600);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The OpenGL renderer that comes with CEGUI sets the matrices itself, so if you're using CEGUI for all your rendering needs this would be fine. Normally you would want the normal perspective projection setup though:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
glMatrixMode(GL_PROJECTION);&lt;br /&gt;
glLoadIdentity();&lt;br /&gt;
gluPerspective(45.0, 800.0/600.0, 0.1,100.0);&lt;br /&gt;
glMatrixMode(GL_MODELVIEW);&lt;br /&gt;
glLoadIdentity();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SDL and OpenGL are now both ready for action. So it's time to initialise CEGUI.&lt;br /&gt;
This new &amp;quot;bootstrap&amp;quot; method in 0.7 is much simpler than the previous methods, it is one simple call&lt;br /&gt;
&lt;br /&gt;
First we need the include (Usually everything you need can be found in &amp;lt;CEGUI/CEGUI.h&amp;gt; but for initialising a specific subsystem you need to do this&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;CEGUI/RendererModules/OpenGL/CEGUIOpenGLRenderer.h&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the call to initialise everything&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::OpenGLRenderer::bootstrapSystem();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that you have to load a widget set, set the mouse cursor and a default font before CEGUI is completely ready. This is described in the other tutorials.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the SDL cursor is displayed, so we'll remove that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
SDL_ShowCursor(SDL_DISABLE);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As keypress characters needs to be injected into CEGUI, we activate unicode translation for SDL key events:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
SDL_EnableUNICODE(1);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it alot easier as we don't have to worry about modifier keys and keyboard layouts ourselves. More about this later on...&lt;br /&gt;
&lt;br /&gt;
Key repeat is a nice feature for the text input widgets in CEGUI, so we use SDL to generate them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Everything is ready now, and we can start the main loop :)&lt;br /&gt;
&lt;br /&gt;
=== The Main Loop ===&lt;br /&gt;
To make it all happen, we use a simple main loop that just keeps pushing on those frames:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void main_loop()&lt;br /&gt;
{&lt;br /&gt;
  bool must_quit = false;&lt;br /&gt;
  &lt;br /&gt;
  // get &amp;quot;run-time&amp;quot; in seconds&lt;br /&gt;
  double last_time_pulse = 0.001*static_cast&amp;lt;double&amp;gt;(SDL_GetTicks());&lt;br /&gt;
  &lt;br /&gt;
  while (!must_quit)&lt;br /&gt;
  {&lt;br /&gt;
    inject_input(must_quit);&lt;br /&gt;
    inject_time_pulse(last_time_pulse);&lt;br /&gt;
    render_gui();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function will run the main loop until the ''bool'' value ''must_quit'' becomes ''true''. In this tutorial this will happen when the user clicks the close button provided by the window manager.&lt;br /&gt;
&lt;br /&gt;
The ''double'' value ''last_time_pulse'' holds the time of the latest time pulse injection. More about this later.&lt;br /&gt;
&lt;br /&gt;
Each function in the ''while'' loop will be described below.&lt;br /&gt;
&lt;br /&gt;
There are endless ways of making your main loop. I took a simple approach to ease writing this tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Injecting Input and injecting change of window size ===&lt;br /&gt;
When the user press or release keyboard or mouse buttons, we need to tell CEGUI about it, for this we use the injection functions of ''CEGUI::System''. We also have to tell &lt;br /&gt;
&lt;br /&gt;
Here is what our inject_input function looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void inject_input(bool&amp;amp; must_quit)&lt;br /&gt;
{&lt;br /&gt;
  SDL_Event e;&lt;br /&gt;
  &lt;br /&gt;
  // go through all available events&lt;br /&gt;
  while (SDL_PollEvent(&amp;amp;e))&lt;br /&gt;
  {&lt;br /&gt;
    // we use a switch to determine the event type&lt;br /&gt;
    switch (e.type)&lt;br /&gt;
    {&lt;br /&gt;
      // mouse motion handler&lt;br /&gt;
      case SDL_MOUSEMOTION:&lt;br /&gt;
        // we inject the mouse position directly.&lt;br /&gt;
        CEGUI::System::getSingleton().injectMousePosition(&lt;br /&gt;
          static_cast&amp;lt;float&amp;gt;(e.motion.x),&lt;br /&gt;
          static_cast&amp;lt;float&amp;gt;(e.motion.y)&lt;br /&gt;
        );&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
      // mouse down handler&lt;br /&gt;
      case SDL_MOUSEBUTTONDOWN:&lt;br /&gt;
        // let a special function handle the mouse button down event&lt;br /&gt;
        handle_mouse_down(e.button.button);&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
      // mouse up handler&lt;br /&gt;
      case SDL_MOUSEBUTTONUP:&lt;br /&gt;
        // let a special function handle the mouse button up event&lt;br /&gt;
        handle_mouse_up(e.button.button);&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      // key down&lt;br /&gt;
      case SDL_KEYDOWN:&lt;br /&gt;
        // to tell CEGUI that a key was pressed, we inject the scancode.&lt;br /&gt;
        CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);&lt;br /&gt;
        &lt;br /&gt;
        // as for the character it's a litte more complicated. we'll use for translated unicode value.&lt;br /&gt;
        // this is described in more detail below.&lt;br /&gt;
        if ((e.key.keysym.unicode != 0)&lt;br /&gt;
        {&lt;br /&gt;
          CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode);&lt;br /&gt;
        }&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
      // key up&lt;br /&gt;
      case SDL_KEYUP:&lt;br /&gt;
        // like before we inject the scancode directly.&lt;br /&gt;
        CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
      // WM quit event occured&lt;br /&gt;
      case SDL_QUIT:&lt;br /&gt;
        must_quit = true;&lt;br /&gt;
        break;&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First I'll explain the events that get handled directly in the ''inject_input'' function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mouse Motion''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// we inject the mouse position directly.&lt;br /&gt;
CEGUI::System::getSingleton().injectMousePosition(&lt;br /&gt;
  static_cast&amp;lt;float&amp;gt;(e.motion.x),&lt;br /&gt;
  static_cast&amp;lt;float&amp;gt;(e.motion.y)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is nothing special here. Like stated in the comment the mouse position is just injected directly.&lt;br /&gt;
&lt;br /&gt;
There are two ways of injecting mouse motion. One where you inject how much the cursor moved, and one where you inject the mouse cursor position. The last one is failsafe.&lt;br /&gt;
Then first one only works correctly in fullscreen mode, or with input grabbed. The reason for this is that in regular windowed mode, the mouse can be moved outside the application window, and during this time no mouse motion event are generated. So if we enter the window at another position, the real mousecursor and CEGUI's mouse cursor will be offset, which will break mouse usage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key Down'''&amp;lt;br /&amp;gt;&lt;br /&gt;
This event takes a little more work. CEGUI requires that key characters (the printable character the key represents) are injected alongside key codes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// to tell CEGUI that a key was pressed, we inject the scancode.&lt;br /&gt;
CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Luckily the key code is just the SDL scancode, so we inject that directly. (This only seems to be true on windows. On other platforms you will need to use a translation function. One can be found here [[SDL to CEGUI keytable]])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// as for the character it's a litte more complicated. we'll use for translated unicode value.&lt;br /&gt;
// this is described in more detail below.&lt;br /&gt;
if (e.key.keysym.unicode != 0)&lt;br /&gt;
{&lt;br /&gt;
  CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of formatting the keypress ourselves, we let SDL do it for us. We could check if we actually got a valid ASCII code, but we want support for local characters as well, so we won't do that. For more information, take a look at the SDL documentation for this feature. [http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fkeysym SDL_keysym].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key Up'''&amp;lt;br /&amp;gt;&lt;br /&gt;
This one is simple. Only the keycode need to injected. So we just use the scancode directly (As with KeyDown you will need to use a translation function for non Windows platforms. Check KeyDown above for more info):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// like before we inject the scancode directly.&lt;br /&gt;
CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mouse Button Down and Mouse Wheel'''&amp;lt;br /&amp;gt;&lt;br /&gt;
CEGUI and SDL are a little different when it comes to mouse button and mouse wheel events. So a little conversion is necessary. Here's the ''handle_mouse_down'' function that gets called when a mouse button down event occurs in SDL. It takes one parameter, a ''Uint8'' describing the mouse button that was pressed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void handle_mouse_down(Uint8 button)&lt;br /&gt;
	{&lt;br /&gt;
	switch ( button )&lt;br /&gt;
		{&lt;br /&gt;
		// handle real mouse buttons&lt;br /&gt;
		case SDL_BUTTON_LEFT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_MIDDLE:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_RIGHT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
			break;&lt;br /&gt;
		&lt;br /&gt;
		// handle the mouse wheel&lt;br /&gt;
		case SDL_BUTTON_WHEELDOWN:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_WHEELUP:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseWheelChange( +1 );&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I chose a very &amp;quot;manual&amp;quot; conversion, but it works fine. Everything should be pretty self-explainatory.&lt;br /&gt;
As you can see mouse wheel events are emitted as mouse button down events in SDL.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mouse Button Up'''&amp;lt;br /&amp;gt;&lt;br /&gt;
The mouse button up event is handled very much like the mouse button down event, except there are no mousewheel release events.&lt;br /&gt;
Like ''handle_mouse_down'' it takes one parameter, a ''Uint8'' describing the mouse button that was released:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void handle_mouse_up(Uint8 button)&lt;br /&gt;
	{&lt;br /&gt;
	switch ( button )&lt;br /&gt;
		{&lt;br /&gt;
		case SDL_BUTTON_LEFT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_MIDDLE:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_RIGHT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
			break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Time Pulses ===&lt;br /&gt;
SDL has a built-in millisecond counter which we will use for this example. There are other ways to use timers with SDL, but I chose this approach as it is simple to use, and provides decent precision.&lt;br /&gt;
&lt;br /&gt;
Remember in the main loop where we stored the current &amp;quot;run-time&amp;quot; in seconds ? This value will be passed as a reference to ''inject_time_pulse'' function which in turn will set a new value to it.&lt;br /&gt;
&lt;br /&gt;
CEGUI's interface for injecting time pulses requires that you pass the time in seconds that has passed since the last time pulse injection. Let's take a look at the function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void inject_time_pulse(double&amp;amp; last_time_pulse)&lt;br /&gt;
{&lt;br /&gt;
	// get current &amp;quot;run-time&amp;quot; in seconds&lt;br /&gt;
	double t = 0.001*SDL_GetTicks();&lt;br /&gt;
&lt;br /&gt;
	// inject the time that passed since the last call &lt;br /&gt;
	CEGUI::System::getSingleton().injectTimePulse( float(t-last_time_pulse) );&lt;br /&gt;
&lt;br /&gt;
	// store the new time as the last time&lt;br /&gt;
	last_time_pulse = t;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The first line gets the actual &amp;quot;run-time&amp;quot; when called.&lt;br /&gt;
* The second line injects the time pulse as the difference between the current time and the last time.&lt;br /&gt;
* The third line stores the current time as the last time a time pulse was injected.&lt;br /&gt;
&lt;br /&gt;
This will work for about 47 days... After that the counter wraps to zero and it breaks (a single insanely invalid timepulse will be injected).&lt;br /&gt;
I'll leave it up to you to fix that if it's a problem.&lt;br /&gt;
&lt;br /&gt;
=== Change of window size ===&lt;br /&gt;
If the window size changes (e.g. switching to fullscreen mode), we have to tell the openGlRenderer what's the new window size. Otherwise e.g. the Fonts aren't scaled properly. Therefore we add an SDL Event Handler for SDL_VIDEORESIZE and submit the new window size to the openGlRenderer of CEGUI.&lt;br /&gt;
If you have used previous versions you will know that you have to do some stuff here to stop textures from being skewed, but that is no longer an issue&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
      case SDL_VIDEORESIZE:&lt;br /&gt;
            //your resize code here, including the SDL_SetVideoMode call&lt;br /&gt;
            CEGUI::System::getSingleton().getRenderer()-&amp;gt;setDisplaySize(CEGUI::Size(event.resize.w, event.resize.h));&lt;br /&gt;
            break;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rendering ===&lt;br /&gt;
Now all that's left is renderingthe GUI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void render_gui()&lt;br /&gt;
{&lt;br /&gt;
	// clear the colour buffer&lt;br /&gt;
	glClear( GL_COLOR_BUFFER_BIT );&lt;br /&gt;
&lt;br /&gt;
	// render the GUI :)&lt;br /&gt;
	CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
&lt;br /&gt;
	// Update the screen&lt;br /&gt;
	SDL_GL_SwapBuffers();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
does all the CEGUI magic and sets OpenGL state itself. As long as the viewport is setup, it will render the GUI.&lt;br /&gt;
&lt;br /&gt;
=== Error Handling ===&lt;br /&gt;
The neat C++ architecture of CEGUI suggests that C++ exceptions are used for error handling. This is completely true.&lt;br /&gt;
Whenever an error occurs, a sub-class of ''CEGUI::Exception'' is thrown.&lt;br /&gt;
&lt;br /&gt;
There are many scenarios where an exception can be thrown. And whether or not these should be considered fatal depends on the application. To make sure you catch the CEGUI exceptions a regular ''try'' block is used. Like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
	// do some cegui code&lt;br /&gt;
}&lt;br /&gt;
catch (CEGUI::Exception&amp;amp; e)&lt;br /&gt;
{&lt;br /&gt;
	fprintf(stderr,&amp;quot;CEGUI Exception occured: %s&amp;quot;, e.getMessage().c_str());&lt;br /&gt;
	// you could quit here&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should provide you with the basic steps needed to get interactive with CEGUI in your SDL application.&lt;br /&gt;
Have fun.&lt;br /&gt;
&lt;br /&gt;
=== The Code ===&lt;br /&gt;
To compile under linux:&lt;br /&gt;
&amp;lt;code&amp;gt;g++ teste.cpp -I/usr/include/CEGUI/ -lSDL -lGL -lGLU -lCEGUIBase -lCEGUIOpenGLRenderer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Adapted by: Johnny Souza - johnnysouza.js@gmail.com&lt;br /&gt;
 * Date: 19/01/07 17:00&lt;br /&gt;
 * Description: Using CEGUI with SDL and OpenGL&lt;br /&gt;
 */&lt;br /&gt;
  &lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
#include &amp;lt;SDL/SDL.h&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;CEGUI.h&amp;gt;&lt;br /&gt;
#include &amp;lt;RendererModules/OpenGL/CEGUIOpenGLRenderer.h&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
#include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;GL/glu.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void handle_mouse_down(Uint8 button)&lt;br /&gt;
{&lt;br /&gt;
	switch ( button ) {&lt;br /&gt;
		case SDL_BUTTON_LEFT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_MIDDLE:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_RIGHT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);&lt;br /&gt;
			break;&lt;br /&gt;
&lt;br /&gt;
		case SDL_BUTTON_WHEELDOWN:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseWheelChange( -1 );&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_WHEELUP:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseWheelChange( +1 );&lt;br /&gt;
			break;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void handle_mouse_up(Uint8 button)&lt;br /&gt;
{&lt;br /&gt;
	switch ( button )&lt;br /&gt;
	{&lt;br /&gt;
		case SDL_BUTTON_LEFT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_MIDDLE:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);&lt;br /&gt;
			break;&lt;br /&gt;
		case SDL_BUTTON_RIGHT:&lt;br /&gt;
			CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);&lt;br /&gt;
			break;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void inject_input (bool &amp;amp; must_quit) &lt;br /&gt;
{&lt;br /&gt;
	SDL_Event e;&lt;br /&gt;
	/* go through all available events */&lt;br /&gt;
	while (SDL_PollEvent(&amp;amp;e)) {&lt;br /&gt;
		/* we use a switch to determine the event type */&lt;br /&gt;
		switch (e.type) {&lt;br /&gt;
			/* mouse motion handler */&lt;br /&gt;
			case SDL_MOUSEMOTION:&lt;br /&gt;
				/* we inject the mouse position directly. */&lt;br /&gt;
				CEGUI::System::getSingleton().injectMousePosition(static_cast&amp;lt;float&amp;gt;(e.motion.x),static_cast&amp;lt;float&amp;gt;(e.motion.y));&lt;br /&gt;
				break;&lt;br /&gt;
	 &lt;br /&gt;
			/* mouse down handler */&lt;br /&gt;
			case SDL_MOUSEBUTTONDOWN:&lt;br /&gt;
				/* let a special function handle the mouse button down event */&lt;br /&gt;
				handle_mouse_down (e.button.button);&lt;br /&gt;
				break;&lt;br /&gt;
&lt;br /&gt;
			/* mouse up handler */&lt;br /&gt;
			case SDL_MOUSEBUTTONUP:&lt;br /&gt;
				/* let a special function handle the mouse button up event */&lt;br /&gt;
				handle_mouse_up (e.button.button);&lt;br /&gt;
				break;&lt;br /&gt;
&lt;br /&gt;
			/* key down */&lt;br /&gt;
			case SDL_KEYDOWN:&lt;br /&gt;
				/* to tell CEGUI that a key was pressed, we inject the scancode. */&lt;br /&gt;
				CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);&lt;br /&gt;
				/* as for the character it's a litte more complicated.&lt;br /&gt;
				 * we'll use for translated unicode value.&lt;br /&gt;
				 * this is described in more detail below.&lt;br /&gt;
				 */&lt;br /&gt;
				if ((e.key.keysym.unicode &amp;amp; 0xFF80) == 0) {&lt;br /&gt;
					CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode &amp;amp; 0x7F);&lt;br /&gt;
				}&lt;br /&gt;
				break;&lt;br /&gt;
	 &lt;br /&gt;
			/* key up */&lt;br /&gt;
			case SDL_KEYUP:&lt;br /&gt;
				/* like before we inject the scancode directly. */&lt;br /&gt;
				CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);&lt;br /&gt;
				break;&lt;br /&gt;
	 &lt;br /&gt;
			/* WM quit event occured */&lt;br /&gt;
			case SDL_QUIT:&lt;br /&gt;
				must_quit = true;&lt;br /&gt;
				break;&lt;br /&gt;
&lt;br /&gt;
			case SDL_VIDEORESIZE:&lt;br /&gt;
				CEGUI::System::getSingleton().notifyDisplaySizeChanged(CEGUI::Size(e.resize.w,e.resize.h));&lt;br /&gt;
				break;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void inject_time_pulse(double&amp;amp; last_time_pulse)&lt;br /&gt;
{&lt;br /&gt;
	/* get current &amp;quot;run-time&amp;quot; in seconds */&lt;br /&gt;
	double t = 0.001*SDL_GetTicks();&lt;br /&gt;
	/* inject the time that passed since the last call */&lt;br /&gt;
	CEGUI::System::getSingleton().injectTimePulse( float(t-last_time_pulse) );&lt;br /&gt;
	/* store the new time as the last time */&lt;br /&gt;
	last_time_pulse = t;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void render_gui()&lt;br /&gt;
{&lt;br /&gt;
	/* clear the colour buffer */&lt;br /&gt;
	glClear( GL_COLOR_BUFFER_BIT );&lt;br /&gt;
	/* render the GUI :) */&lt;br /&gt;
	CEGUI::System::getSingleton().renderGUI();&lt;br /&gt;
	/* Update the screen */&lt;br /&gt;
	SDL_GL_SwapBuffers();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void main_loop () &lt;br /&gt;
{&lt;br /&gt;
	bool must_quit = false;&lt;br /&gt;
	/* get &amp;quot;run-time&amp;quot; in seconds */&lt;br /&gt;
	double last_time_pulse = 0.001*static_cast&amp;lt;double&amp;gt;(SDL_GetTicks());&lt;br /&gt;
	while (!must_quit) {&lt;br /&gt;
		inject_input (must_quit);&lt;br /&gt;
		inject_time_pulse (last_time_pulse);&lt;br /&gt;
		render_gui ();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main (int argc, char **argv) &lt;br /&gt;
{&lt;br /&gt;
	SDL_Surface * screen;&lt;br /&gt;
	atexit (SDL_Quit);&lt;br /&gt;
	SDL_Init (SDL_INIT_VIDEO);&lt;br /&gt;
	screen = SDL_SetVideoMode (600, 480, 0, SDL_OPENGL);&lt;br /&gt;
	if (screen == NULL) {&lt;br /&gt;
		/* Se ainda não der, desiste! */ &lt;br /&gt;
		fprintf (stderr, &amp;quot;Impossível ajustar ao vídeo: %s\n&amp;quot;, SDL_GetError ());&lt;br /&gt;
		exit (1);&lt;br /&gt;
	}&lt;br /&gt;
        CEGUI::OpenGLRenderer::bootstrapSystem();&lt;br /&gt;
	SDL_ShowCursor (SDL_DISABLE);&lt;br /&gt;
	SDL_EnableUNICODE (1);&lt;br /&gt;
	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);&lt;br /&gt;
	main_loop();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Lindquist]] 16:21, 8 May 2005 (BST)&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Dermont</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_PyCEGUI_with_glfw3_and_PyOpenGL_(0.8)&amp;diff=5647</id>
		<title>Using PyCEGUI with glfw3 and PyOpenGL (0.8)</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_PyCEGUI_with_glfw3_and_PyOpenGL_(0.8)&amp;diff=5647"/>
				<updated>2015-03-27T13:15:03Z</updated>
		
		<summary type="html">&lt;p&gt;Dermont: /* Demo Source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.8}}&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
For this example it is assumed that  [http://www.glfw.org/download.html glfw3] and [http://www.opengl.org OpenGL] are already installed. &lt;br /&gt;
We will be using the bindings for [https://github.com/rougier/pyglfw.git python glfw3] from Nicolas P. Rougier. Download from git clone https://github.com/rougier/pyglfw.git and copy the file glfw.py to the directory you are running the demo from.&lt;br /&gt;
&lt;br /&gt;
== Importing Modules ==&lt;br /&gt;
If you have trouble importing the PyCEGUI libraries you can update your python path to point to the location of the modules. For Linux you can simply point to your CEGUI build_dir/lib.&lt;br /&gt;
&lt;br /&gt;
    for _path in [os.path.join(s,'cegui-0.8') for s in site.getsitepackages()]:&lt;br /&gt;
        print _path&lt;br /&gt;
        sys.path.insert(0, _path)&lt;br /&gt;
    #sys.path.insert(0, &amp;quot;/media/sdb5/python-ogre-cegui/cegui-0.8/lib&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Setting Data Path ==&lt;br /&gt;
Set your path to the CEGUI media dir.&lt;br /&gt;
&lt;br /&gt;
    CEGUI_PATH = &amp;quot;/media/sdb5/Libraries/OGRE/sdk/v1-9/share/cegui-0/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mouse/KeyBoard Mappings==&lt;br /&gt;
&lt;br /&gt;
    def ConvertMouseButton(button):&lt;br /&gt;
        ##Convert Mouse Buttons to CEGUI&lt;br /&gt;
        if (button == glfw.GLFW_MOUSE_BUTTON_RIGHT):&lt;br /&gt;
            return PyCEGUI.RightButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_LEFT):&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_MIDDLE):&lt;br /&gt;
            return PyCEGUI.MiddleButton&lt;br /&gt;
        else:&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
&lt;br /&gt;
Copy the following keyboard mappings to keymappings_glfw3.py in same directory as the demo.&lt;br /&gt;
&lt;br /&gt;
    import sys&lt;br /&gt;
    import glfw&lt;br /&gt;
    import PyCEGUI&lt;br /&gt;
    KEYMAPPINGS = {&lt;br /&gt;
        glfw.GLFW_KEY_UNKNOWN       : PyCEGUI.Key.Unknown, &lt;br /&gt;
        glfw.GLFW_KEY_SPACE         : PyCEGUI.Key.Space,&lt;br /&gt;
        glfw.GLFW_KEY_APOSTROPHE    : PyCEGUI.Key.Apostrophe,&lt;br /&gt;
        glfw.GLFW_KEY_COMMA         : PyCEGUI.Key.Comma,&lt;br /&gt;
        glfw.GLFW_KEY_MINUS         : PyCEGUI.Key.Minus,&lt;br /&gt;
        glfw.GLFW_KEY_PERIOD        : PyCEGUI.Key.Period,&lt;br /&gt;
        glfw.GLFW_KEY_SLASH         : PyCEGUI.Key.Slash,&lt;br /&gt;
        glfw.GLFW_KEY_0             : PyCEGUI.Key.Zero,&lt;br /&gt;
        glfw.GLFW_KEY_1             : PyCEGUI.Key.One,&lt;br /&gt;
        glfw.GLFW_KEY_2             : PyCEGUI.Key.Two,&lt;br /&gt;
        glfw.GLFW_KEY_3             : PyCEGUI.Key.Three,&lt;br /&gt;
        glfw.GLFW_KEY_4             : PyCEGUI.Key.Four,&lt;br /&gt;
        glfw.GLFW_KEY_5             : PyCEGUI.Key.Five,&lt;br /&gt;
        glfw.GLFW_KEY_6             : PyCEGUI.Key.Six,&lt;br /&gt;
        glfw.GLFW_KEY_7             : PyCEGUI.Key.Seven,&lt;br /&gt;
        glfw.GLFW_KEY_8             : PyCEGUI.Key.Eight,&lt;br /&gt;
        glfw.GLFW_KEY_9             : PyCEGUI.Key.Nine,&lt;br /&gt;
        glfw.GLFW_KEY_SEMICOLON     : PyCEGUI.Key.Semicolon,&lt;br /&gt;
        glfw.GLFW_KEY_EQUAL         : PyCEGUI.Key.Equals,&lt;br /&gt;
        glfw.GLFW_KEY_A             : PyCEGUI.Key.A,&lt;br /&gt;
        glfw.GLFW_KEY_B             : PyCEGUI.Key.B,&lt;br /&gt;
        glfw.GLFW_KEY_C             : PyCEGUI.Key.C,&lt;br /&gt;
        glfw.GLFW_KEY_D             : PyCEGUI.Key.D,&lt;br /&gt;
        glfw.GLFW_KEY_E             : PyCEGUI.Key.E,&lt;br /&gt;
        glfw.GLFW_KEY_F             : PyCEGUI.Key.F,&lt;br /&gt;
        glfw.GLFW_KEY_G             : PyCEGUI.Key.G,&lt;br /&gt;
        glfw.GLFW_KEY_H             : PyCEGUI.Key.H,&lt;br /&gt;
        glfw.GLFW_KEY_I             : PyCEGUI.Key.I,&lt;br /&gt;
        glfw.GLFW_KEY_J             : PyCEGUI.Key.J,&lt;br /&gt;
        glfw.GLFW_KEY_K             : PyCEGUI.Key.K,&lt;br /&gt;
        glfw.GLFW_KEY_L             : PyCEGUI.Key.L,&lt;br /&gt;
        glfw.GLFW_KEY_M             : PyCEGUI.Key.M,&lt;br /&gt;
        glfw.GLFW_KEY_N             : PyCEGUI.Key.N,&lt;br /&gt;
        glfw.GLFW_KEY_O             : PyCEGUI.Key.O,&lt;br /&gt;
        glfw.GLFW_KEY_P             : PyCEGUI.Key.P,&lt;br /&gt;
        glfw.GLFW_KEY_Q             : PyCEGUI.Key.Q,&lt;br /&gt;
        glfw.GLFW_KEY_R             : PyCEGUI.Key.R,&lt;br /&gt;
        glfw.GLFW_KEY_S             : PyCEGUI.Key.S,&lt;br /&gt;
        glfw.GLFW_KEY_T             : PyCEGUI.Key.T,&lt;br /&gt;
        glfw.GLFW_KEY_U             : PyCEGUI.Key.U,&lt;br /&gt;
        glfw.GLFW_KEY_V             : PyCEGUI.Key.V,&lt;br /&gt;
        glfw.GLFW_KEY_W             : PyCEGUI.Key.W,&lt;br /&gt;
        glfw.GLFW_KEY_X             : PyCEGUI.Key.X,&lt;br /&gt;
        glfw.GLFW_KEY_Y             : PyCEGUI.Key.Y,&lt;br /&gt;
        glfw.GLFW_KEY_Z             : PyCEGUI.Key.Z,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_BRACKET  : PyCEGUI.Key.LeftBracket,&lt;br /&gt;
        glfw.GLFW_KEY_BACKSLASH     : PyCEGUI.Key.Backslash,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_BRACKET : PyCEGUI.Key.RightBracket,&lt;br /&gt;
        glfw.GLFW_KEY_GRAVE_ACCENT  : PyCEGUI.Key.Grave,&lt;br /&gt;
        glfw.GLFW_KEY_WORLD_1       : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_WORLD_2       : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_ESCAPE        : PyCEGUI.Key.Escape,&lt;br /&gt;
        glfw.GLFW_KEY_ENTER         : PyCEGUI.Key.Return,&lt;br /&gt;
        glfw.GLFW_KEY_TAB           : PyCEGUI.Key.Tab,&lt;br /&gt;
        glfw.GLFW_KEY_BACKSPACE     : PyCEGUI.Key.Backspace,&lt;br /&gt;
        glfw.GLFW_KEY_INSERT        : PyCEGUI.Key.Insert,&lt;br /&gt;
        glfw.GLFW_KEY_DELETE        : PyCEGUI.Key.Delete,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT         : PyCEGUI.Key.ArrowRight,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT          : PyCEGUI.Key.ArrowLeft,&lt;br /&gt;
        glfw.GLFW_KEY_DOWN          : PyCEGUI.Key.ArrowDown,&lt;br /&gt;
        glfw.GLFW_KEY_UP            : PyCEGUI.Key.ArrowUp,&lt;br /&gt;
        glfw.GLFW_KEY_PAGE_UP       : PyCEGUI.Key.PageUp,&lt;br /&gt;
        glfw.GLFW_KEY_PAGE_DOWN     : PyCEGUI.Key.PageDown,&lt;br /&gt;
        glfw.GLFW_KEY_HOME          : PyCEGUI.Key.Home,&lt;br /&gt;
        glfw.GLFW_KEY_END           : PyCEGUI.Key.End,&lt;br /&gt;
        glfw.GLFW_KEY_CAPS_LOCK     : PyCEGUI.Key.Capital,&lt;br /&gt;
        glfw.GLFW_KEY_SCROLL_LOCK   : PyCEGUI.Key.ScrollLock,&lt;br /&gt;
        glfw.GLFW_KEY_NUM_LOCK      : PyCEGUI.Key.NumLock,&lt;br /&gt;
        glfw.GLFW_KEY_PRINT_SCREEN  : PyCEGUI.Key.SysRq,&lt;br /&gt;
        glfw.GLFW_KEY_PAUSE         : PyCEGUI.Key.Pause,&lt;br /&gt;
        glfw.GLFW_KEY_F1            : PyCEGUI.Key.F1,&lt;br /&gt;
        glfw.GLFW_KEY_F2            : PyCEGUI.Key.F2,&lt;br /&gt;
        glfw.GLFW_KEY_F3            : PyCEGUI.Key.F3,&lt;br /&gt;
        glfw.GLFW_KEY_F4            : PyCEGUI.Key.F4,&lt;br /&gt;
        glfw.GLFW_KEY_F5            : PyCEGUI.Key.F5,&lt;br /&gt;
        glfw.GLFW_KEY_F6            : PyCEGUI.Key.F6,&lt;br /&gt;
        glfw.GLFW_KEY_F7            : PyCEGUI.Key.F7,&lt;br /&gt;
        glfw.GLFW_KEY_F8            : PyCEGUI.Key.F8,&lt;br /&gt;
        glfw.GLFW_KEY_F9            : PyCEGUI.Key.F9,&lt;br /&gt;
        glfw.GLFW_KEY_F10           : PyCEGUI.Key.F10,&lt;br /&gt;
        glfw.GLFW_KEY_F11           : PyCEGUI.Key.F11,&lt;br /&gt;
        glfw.GLFW_KEY_F12           : PyCEGUI.Key.F12,&lt;br /&gt;
        glfw.GLFW_KEY_F13           : PyCEGUI.Key.F13,&lt;br /&gt;
        glfw.GLFW_KEY_F14           : PyCEGUI.Key.F14,&lt;br /&gt;
        glfw.GLFW_KEY_F15           : PyCEGUI.Key.F15,&lt;br /&gt;
        glfw.GLFW_KEY_F16           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F17           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F18           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F19           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F20           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F21           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F22           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F23           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F24           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F25           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_KP_0          : PyCEGUI.Key.Numpad0,&lt;br /&gt;
        glfw.GLFW_KEY_KP_1          : PyCEGUI.Key.Numpad1,&lt;br /&gt;
        glfw.GLFW_KEY_KP_2          : PyCEGUI.Key.Numpad2,&lt;br /&gt;
        glfw.GLFW_KEY_KP_3          : PyCEGUI.Key.Numpad3,&lt;br /&gt;
        glfw.GLFW_KEY_KP_4          : PyCEGUI.Key.Numpad4,&lt;br /&gt;
        glfw.GLFW_KEY_KP_5          : PyCEGUI.Key.Numpad5,&lt;br /&gt;
        glfw.GLFW_KEY_KP_6          : PyCEGUI.Key.Numpad6,&lt;br /&gt;
        glfw.GLFW_KEY_KP_7          : PyCEGUI.Key.Numpad7,&lt;br /&gt;
        glfw.GLFW_KEY_KP_8          : PyCEGUI.Key.Numpad8,&lt;br /&gt;
        glfw.GLFW_KEY_KP_9          : PyCEGUI.Key.Numpad9,&lt;br /&gt;
        glfw.GLFW_KEY_KP_DECIMAL    : PyCEGUI.Key.Decimal,&lt;br /&gt;
        glfw.GLFW_KEY_KP_DIVIDE     : PyCEGUI.Key.Divide,&lt;br /&gt;
        glfw.GLFW_KEY_KP_MULTIPLY   : PyCEGUI.Key.Multiply,&lt;br /&gt;
        glfw.GLFW_KEY_KP_SUBTRACT   : PyCEGUI.Key.Subtract,&lt;br /&gt;
        glfw.GLFW_KEY_KP_ADD        : PyCEGUI.Key.Add,&lt;br /&gt;
        glfw.GLFW_KEY_KP_ENTER      : PyCEGUI.Key.NumpadEnter,&lt;br /&gt;
        glfw.GLFW_KEY_KP_EQUAL      : PyCEGUI.Key.NumpadEquals,     &lt;br /&gt;
        glfw.GLFW_KEY_LEFT_SHIFT    : PyCEGUI.Key.LeftShift,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_CONTROL  : PyCEGUI.Key.LeftControl,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_ALT      : PyCEGUI.Key.LeftAlt,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_SUPER    : PyCEGUI.Key.LeftWindows,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_SHIFT   : PyCEGUI.Key.RightShift,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_CONTROL : PyCEGUI.Key.RightControl,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_ALT     : PyCEGUI.Key.RightAlt,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_SUPER   : PyCEGUI.Key.RightWindows,&lt;br /&gt;
        glfw.GLFW_KEY_MENU          : PyCEGUI.Key.AppMenu,&lt;br /&gt;
        glfw.GLFW_KEY_LAST          : PyCEGUI.Key.AppMenu&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Initialization glf3==&lt;br /&gt;
&lt;br /&gt;
    # Initialize glfw&lt;br /&gt;
    if not glfw.glfwInit():&lt;br /&gt;
        print (&amp;quot; Error : glfw failed to initialize&amp;quot;)&lt;br /&gt;
        sys.exit (glfw.EXIT_FAILURE)&lt;br /&gt;
&lt;br /&gt;
== Window Hints==&lt;br /&gt;
&lt;br /&gt;
Glfw3 allows to define window hints prior to creation and hints about your OpenGL Context (OpenGL Version). Note the MAJOR/MINOR values are the minimum API version of the window context, i.e. if you graphics card supports GL 4.4 that is what will be returned.&lt;br /&gt;
&lt;br /&gt;
GLFW_OPENGL_FORWARD_COMPAT (True) indicates that functionality deprecated in the requested version of OpenGL is removed.&lt;br /&gt;
&lt;br /&gt;
For the sake of testing PyCEGUI's OpenGL render set: &lt;br /&gt;
  ceguiGL3Renderer(True)/ GLFW_OPENGL_FORWARD_COMPAT(True)   - OpenGL3Renderer without GL2.1&lt;br /&gt;
  ceguiGL3Renderer(True)/ GLFW_OPENGL_FORWARD_COMPAT(False)  - OpenGL3Renderer with    GL2.1&lt;br /&gt;
  ceguiGL3Renderer(False)                                    - OpenGLRenderer&lt;br /&gt;
 &lt;br /&gt;
    ceguiGL3Renderer = True&lt;br /&gt;
    if ceguiGL3Renderer:&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 2)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, PyGL.GL_TRUE)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)&lt;br /&gt;
    else:&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 2)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 1)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_ANY_PROFILE)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Window==&lt;br /&gt;
If you try to create a window with a context that you graphics card does not support glfwCreateWindow will fail. We&lt;br /&gt;
also need to make our context current prior to creating our PyCEGUI renderer.&lt;br /&gt;
&lt;br /&gt;
    glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, None, None)&lt;br /&gt;
    if not glfw_window:&lt;br /&gt;
        print (&amp;quot; Error : glfw failed to create a window&amp;quot;)&lt;br /&gt;
        glfw.glfwTerminate()&lt;br /&gt;
        sys.exit()&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwMakeContextCurrent(glfw_window)&lt;br /&gt;
&lt;br /&gt;
== VSnyc ==&lt;br /&gt;
This does nothing on linux and is dependent on your card settings. For example with a NVidia card change settings with NVidia X Server Settings-&amp;gt;OpenGL Settings-&amp;gt;Sync to VBlank.&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwSwapInterval(0)&lt;br /&gt;
&lt;br /&gt;
== Callbacks ==&lt;br /&gt;
See the source for each of the following callbacks where we notify CEGUI of display size changes, mouse presses/movement, key presses and glfwSetCharCallback is our callback to pass the unicode char/key pressed to CEGUI.&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwSetKeyCallback(             glfw_window,  self.on_key)&lt;br /&gt;
    glfw.glfwSetMouseButtonCallback(     glfw_window,  self.on_mouse)&lt;br /&gt;
    glfw.glfwSetCursorPosCallback(       glfw_window,  self.on_move)&lt;br /&gt;
    glfw.glfwSetWindowSizeCallback(      glfw_window,  self.on_resize)&lt;br /&gt;
    glfw.glfwSetCharCallback(            glfw_window,  self.on_char_callback)&lt;br /&gt;
    glfw.glfwSetFramebufferSizeCallback( glfw_window,  self.on_framebuffer_size_callback)&lt;br /&gt;
&lt;br /&gt;
== PyCEGUI Renderer ==&lt;br /&gt;
Create our PyCEGUI renderer.&lt;br /&gt;
&lt;br /&gt;
    if (not ceguiGL3Renderer):&lt;br /&gt;
        PyCEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()&lt;br /&gt;
    else :&lt;br /&gt;
        PyCEGUIOpenGLRenderer.OpenGL3Renderer.bootstrapSystem()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Main Loop ==&lt;br /&gt;
Our main loop runs until the glfw3 window is closed updating CEGUI, swapping the buffers and handling glfw events.&lt;br /&gt;
&lt;br /&gt;
    def updateCEGUI(self, elapsed):&lt;br /&gt;
        ##CEGUI updates ###&lt;br /&gt;
        if (PyCEGUI.System.getSingleton()):&lt;br /&gt;
            PyCEGUI.System.getSingleton().injectTimePulse(elapsed)&lt;br /&gt;
            PyCEGUI.System.getSingleton().renderAllGUIContexts()&lt;br /&gt;
            self.labelFPS.setText(&amp;quot;FPS : %s&amp;quot; %(str(int(1.0/elapsed))))&lt;br /&gt;
&lt;br /&gt;
    while not glfw.glfwWindowShouldClose(self.glfw_window):&lt;br /&gt;
        PyGL.glClear(PyGL.GL_COLOR_BUFFER_BIT)&lt;br /&gt;
        # update timing&lt;br /&gt;
        self.current_time = glfw.glfwGetTime()&lt;br /&gt;
        elapsed = self.current_time - self.previous_time&lt;br /&gt;
        self.previous_time = self.current_time&lt;br /&gt;
        # update GL/CEGUI&lt;br /&gt;
        self.updateGL()&lt;br /&gt;
        self.updateCEGUI(elapsed)&lt;br /&gt;
        # Swap front and back buffers&lt;br /&gt;
        glfw.glfwSwapBuffers(self.glfw_window)&lt;br /&gt;
        # Handle glfw events&lt;br /&gt;
        glfw.glfwPollEvents()&lt;br /&gt;
&lt;br /&gt;
== Demo Source ==&lt;br /&gt;
&lt;br /&gt;
This is the full source code for the demo, see above saving the keyboard mappings.  &lt;br /&gt;
&lt;br /&gt;
     # -- coding: utf-8 --&lt;br /&gt;
    import glfw&lt;br /&gt;
    import OpenGL.GL as PyGL&lt;br /&gt;
    import sys, os , site&lt;br /&gt;
    ## set the path of your PyCEGUI* modules&lt;br /&gt;
    for _path in [os.path.join(s,'cegui-0.8') for s in site.getsitepackages()]:&lt;br /&gt;
        print _path&lt;br /&gt;
        sys.path.insert(0, _path)&lt;br /&gt;
    sys.path.insert(0, &amp;quot;/media/sdb5/python-ogre-cegui/cegui-0.8/lib&amp;quot;)&lt;br /&gt;
    ## set the path to our resource files&lt;br /&gt;
    CEGUI_PATH = &amp;quot;/media/sdb5/Libraries/OGRE/sdk/v1-9/share/cegui-0/&amp;quot;&lt;br /&gt;
    ## import our PyCEGUI and out glfw3 to cegui key mappings&lt;br /&gt;
    import PyCEGUI&lt;br /&gt;
    import PyCEGUIOpenGLRenderer&lt;br /&gt;
    from keymappings_glfw3 import *&lt;br /&gt;
    def ConvertMouseButton(button):&lt;br /&gt;
        ### Convert Mouse Buttons to CEGUI&lt;br /&gt;
        if (button == glfw.GLFW_MOUSE_BUTTON_RIGHT):&lt;br /&gt;
            return PyCEGUI.RightButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_LEFT):&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_MIDDLE):&lt;br /&gt;
            return PyCEGUI.MiddleButton&lt;br /&gt;
        else:&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
    class Application(object):&lt;br /&gt;
        def __init__(self):&lt;br /&gt;
            # Initialize glfw&lt;br /&gt;
            if not glfw.glfwInit():&lt;br /&gt;
                print (&amp;quot; Error : glfw failed to initialize&amp;quot;)&lt;br /&gt;
                sys.exit (glfw.EXIT_FAILURE)&lt;br /&gt;
            ceguiGL3Renderer = True&lt;br /&gt;
            if ceguiGL3Renderer:&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 2)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, PyGL.GL_TRUE)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)&lt;br /&gt;
            else:&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 2)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 1)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_ANY_PROFILE)&lt;br /&gt;
            # our window hints&lt;br /&gt;
            ## http://www.glfw.org/docs/latest/window.html&lt;br /&gt;
            ## set our framebuffer related hints&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_DEPTH_BITS, 24)&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_STENCIL_BITS, 8)&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_FOCUSED, True)&lt;br /&gt;
            fullScreen = False&lt;br /&gt;
            # create window&lt;br /&gt;
            if (not fullScreen):&lt;br /&gt;
                glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, None, None)&lt;br /&gt;
            else:&lt;br /&gt;
                glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, glfw.glfwGetPrimaryMonitor(), None)&lt;br /&gt;
            # check window created&lt;br /&gt;
            if not glfw_window:&lt;br /&gt;
                print (&amp;quot; Error : glfw failed to create a window&amp;quot;)&lt;br /&gt;
                glfw.glfwTerminate()&lt;br /&gt;
                sys.exit()&lt;br /&gt;
            self.glfw_window = glfw_window&lt;br /&gt;
            glfw.glfwMakeContextCurrent(glfw_window)&lt;br /&gt;
            self.showglfwInfo()&lt;br /&gt;
            ## this does nothing on linux&lt;br /&gt;
            glfw.glfwSwapInterval(0)&lt;br /&gt;
            glfw.glfwSetInputMode(glfw_window, glfw.GLFW_CURSOR, glfw.GLFW_CURSOR_HIDDEN)&lt;br /&gt;
            # call backs&lt;br /&gt;
            glfw.glfwSetKeyCallback(             glfw_window,  self.on_key)&lt;br /&gt;
            glfw.glfwSetMouseButtonCallback(     glfw_window,  self.on_mouse)&lt;br /&gt;
            glfw.glfwSetCursorPosCallback(       glfw_window,  self.on_move)&lt;br /&gt;
            glfw.glfwSetWindowSizeCallback(      glfw_window,  self.on_resize)&lt;br /&gt;
            glfw.glfwSetCharCallback(            glfw_window,  self.on_char_callback)&lt;br /&gt;
            glfw.glfwSetFramebufferSizeCallback( glfw_window,  self.on_framebuffer_size_callback)&lt;br /&gt;
            # initialise our CEGUI renderer&lt;br /&gt;
            ctx_major      = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            ctx_minor      = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MINOR)&lt;br /&gt;
            forward_compat = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_OPENGL_FORWARD_COMPAT)&lt;br /&gt;
            if (not ceguiGL3Renderer):&lt;br /&gt;
                PyCEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()&lt;br /&gt;
            else :&lt;br /&gt;
                PyCEGUIOpenGLRenderer.OpenGL3Renderer.bootstrapSystem()&lt;br /&gt;
            # initialise PyCEGUI and resources&lt;br /&gt;
            rp = PyCEGUI.System.getSingleton().getResourceProvider()&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;schemes&amp;quot;,    CEGUI_PATH + &amp;quot;schemes&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;imagesets&amp;quot;,  CEGUI_PATH + &amp;quot;imagesets&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;fonts&amp;quot;,      CEGUI_PATH + &amp;quot;fonts&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;layouts&amp;quot;,    CEGUI_PATH + &amp;quot;layouts&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;looknfeels&amp;quot;, CEGUI_PATH + &amp;quot;looknfeel&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;schemas&amp;quot;,    CEGUI_PATH + &amp;quot;xml_schemas&amp;quot;)&lt;br /&gt;
            PyCEGUI.ImageManager.setImagesetDefaultResourceGroup(&amp;quot;imagesets&amp;quot;)&lt;br /&gt;
            PyCEGUI.Font.setDefaultResourceGroup(&amp;quot;fonts&amp;quot;)&lt;br /&gt;
            PyCEGUI.Scheme.setDefaultResourceGroup(&amp;quot;schemes&amp;quot;)&lt;br /&gt;
            PyCEGUI.WidgetLookManager.setDefaultResourceGroup(&amp;quot;looknfeels&amp;quot;)&lt;br /&gt;
            PyCEGUI.WindowManager.setDefaultResourceGroup(&amp;quot;layouts&amp;quot;)&lt;br /&gt;
            parser = PyCEGUI.System.getSingleton().getXMLParser()&lt;br /&gt;
            if parser.isPropertyPresent(&amp;quot;SchemaDefaultResourceGroup&amp;quot;):&lt;br /&gt;
                parser.setProperty(&amp;quot;SchemaDefaultResourceGroup&amp;quot;, &amp;quot;schemas&amp;quot;)     &lt;br /&gt;
            # Load schemes&lt;br /&gt;
            PyCEGUI.SchemeManager.getSingleton().createFromFile(&amp;quot;TaharezLook.scheme&amp;quot;)&lt;br /&gt;
            PyCEGUI.SchemeManager.getSingleton().createFromFile(&amp;quot;WindowsLook.scheme&amp;quot;)&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage(&amp;quot;TaharezLook/MouseArrow&amp;quot;)&lt;br /&gt;
            # set root window&lt;br /&gt;
            root = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;DefaultWindow&amp;quot;, &amp;quot;background_wnd&amp;quot;);&lt;br /&gt;
            root.setArea( PyCEGUI.UVector2(PyCEGUI.UDim(0.0, 0),PyCEGUI.UDim(0.0, 0)) ,PyCEGUI.USize(PyCEGUI.UDim(1.0, 0),PyCEGUI.UDim(1.0, 0)))&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().setRootWindow(root)&lt;br /&gt;
            # load a layout&lt;br /&gt;
            layout = PyCEGUI.WindowManager.getSingleton().loadLayoutFromFile(&amp;quot;TextDemo.layout&amp;quot;)&lt;br /&gt;
            root.addChild(layout.getChild('TextDemo'))&lt;br /&gt;
            self.edit = root.getChild('TextDemo/MultiLineGroup/editMulti')&lt;br /&gt;
            # create label for our FPS&lt;br /&gt;
            self.labelFPS = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;TaharezLook/Label&amp;quot;, &amp;quot;FPSLabel&amp;quot;)&lt;br /&gt;
            root.addChild(self.labelFPS)&lt;br /&gt;
            # create hello button&lt;br /&gt;
            button = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;TaharezLook/Button&amp;quot;, &amp;quot;HelloButton&amp;quot;)&lt;br /&gt;
            button.setArea( PyCEGUI.UVector2(PyCEGUI.UDim(.50, 0),PyCEGUI.UDim(.92, 0)) ,PyCEGUI.USize(PyCEGUI.UDim(0.3, 0),PyCEGUI.UDim(0.05, 0)))&lt;br /&gt;
            button.setText(&amp;quot;Hello&amp;quot;)&lt;br /&gt;
            root.addChild(button)&lt;br /&gt;
            button.subscribeEvent(PyCEGUI.PushButton.EventClicked, self.OnbuttonClicked)&lt;br /&gt;
            # init simple timing&lt;br /&gt;
            self.previous_time = glfw.glfwGetTime()&lt;br /&gt;
            self.current_time  = self.previous_time&lt;br /&gt;
        def showglfwInfo(self):&lt;br /&gt;
            ctx_major      = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            ctx_minor      = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_CONTEXT_VERSION_MINOR)&lt;br /&gt;
            forward_compat = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_OPENGL_FORWARD_COMPAT)&lt;br /&gt;
            print &amp;quot;Created Window for OpenGL version %d.%d &amp;quot; % ( ctx_major, ctx_major )&lt;br /&gt;
            if ( ctx_major &amp;gt;=3 and forward_compat):&lt;br /&gt;
                print &amp;quot;Context is forward compatible, you can't use OpenGL 2.x commands&amp;quot; &lt;br /&gt;
            fwidth,fheight = glfw.glfwGetFramebufferSize(self.glfw_window)&lt;br /&gt;
            width, height =  glfw.glfwGetWindowSize(self.glfw_window)&lt;br /&gt;
            print &amp;quot;Framebuffer size %dx%d Window size %dx%d &amp;quot; % (fwidth,fheight, width,height) &lt;br /&gt;
        def OnbuttonClicked(self, args):&lt;br /&gt;
            self.edit.setText(self.edit.getText() + &amp;quot;You Clicked&amp;quot;)&lt;br /&gt;
            return&lt;br /&gt;
        def cleanUp(self):&lt;br /&gt;
            ### shutdown glfw and CEGUI &lt;br /&gt;
            PyCEGUIOpenGLRenderer.OpenGLRenderer.destroySystem()&lt;br /&gt;
            glfw.glfwTerminate()&lt;br /&gt;
        def updateGL(self):&lt;br /&gt;
            ### glfw GL updates&lt;br /&gt;
            pass&lt;br /&gt;
        def updateCEGUI(self, elapsed):&lt;br /&gt;
            ### CEGUI updates&lt;br /&gt;
            #focused = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            if (PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().injectTimePulse(elapsed)&lt;br /&gt;
                PyCEGUI.System.getSingleton().renderAllGUIContexts()&lt;br /&gt;
                self.labelFPS.setText(&amp;quot;FPS : %s&amp;quot; %(str(int(1.0/elapsed))))&lt;br /&gt;
        def mainLoop(self):&lt;br /&gt;
            ### Loop until glfw window is closed &lt;br /&gt;
            while not glfw.glfwWindowShouldClose(self.glfw_window):&lt;br /&gt;
                PyGL.glClear(PyGL.GL_COLOR_BUFFER_BIT)&lt;br /&gt;
                # update timing&lt;br /&gt;
                self.current_time = glfw.glfwGetTime()&lt;br /&gt;
                elapsed = self.current_time - self.previous_time&lt;br /&gt;
                self.previous_time = self.current_time&lt;br /&gt;
                # update GL/CEGUI&lt;br /&gt;
                self.updateGL()&lt;br /&gt;
                self.updateCEGUI(elapsed)&lt;br /&gt;
                # Swap front and back buffers&lt;br /&gt;
                glfw.glfwSwapBuffers(self.glfw_window)&lt;br /&gt;
                # Handle glfw events&lt;br /&gt;
                glfw.glfwPollEvents()&lt;br /&gt;
        def on_framebuffer_size_callback(self,window,width,height):&lt;br /&gt;
            PyGL.glViewport(0, 0, width, height)&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().notifyDisplaySizeChanged(PyCEGUI.Sizef(float(width), float(height) ))&lt;br /&gt;
        def on_move(self, window, x,y):&lt;br /&gt;
            ### pass glfw mouse moves to CEGUI&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().getDefaultGUIContext().injectMousePosition(x, y)&lt;br /&gt;
        def on_resize(self, window, width,height):&lt;br /&gt;
            ### resize glfw viewport and CEGUI display &lt;br /&gt;
            PyGL.glViewport(0, 0, width, height)&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().notifyDisplaySizeChanged(PyCEGUI.Sizef(float(width), float(height) ))&lt;br /&gt;
        def on_mouse(self, window, button, action, mods):&lt;br /&gt;
            ### pass glfw mouse press events to CEGUI &lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                context = PyCEGUI.System.getSingleton().getDefaultGUIContext()&lt;br /&gt;
                if (action == glfw.GLFW_PRESS):&lt;br /&gt;
                    context.injectMouseButtonDown( ConvertMouseButton(button) )&lt;br /&gt;
                if (action == glfw.GLFW_RELEASE):&lt;br /&gt;
                    context.injectMouseButtonUp( ConvertMouseButton(button) )&lt;br /&gt;
        def on_char_callback(self, window, code):&lt;br /&gt;
            ### Unicode character callback function to CEGUI &lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().injectChar(code)&lt;br /&gt;
        def on_key(self, window, key, scancode, action, mods):&lt;br /&gt;
            ### pass keypress events to CEGUI &lt;br /&gt;
            if PyCEGUI.System.getSingleton():&lt;br /&gt;
                cegui_key = KEYMAPPINGS[key]&lt;br /&gt;
                if (not cegui_key==PyCEGUI.Key.Unknown):&lt;br /&gt;
                    if (action == glfw.GLFW_PRESS):&lt;br /&gt;
                       PyCEGUI.System.getSingleton().getDefaultGUIContext().injectKeyDown(PyCEGUI.Key.Scan(cegui_key))&lt;br /&gt;
                    if (action == glfw.GLFW_RELEASE):&lt;br /&gt;
                        PyCEGUI.System.getSingleton().getDefaultGUIContext().injectKeyUp(PyCEGUI.Key.Scan(cegui_key))&lt;br /&gt;
            ## exit&lt;br /&gt;
            if key == glfw.GLFW_KEY_ESCAPE and action == glfw.GLFW_PRESS:&lt;br /&gt;
                glfw.glfwSetWindowShouldClose(window,1)&lt;br /&gt;
    if __name__ == '__main__':&lt;br /&gt;
        app = Application()&lt;br /&gt;
        app.mainLoop()&lt;br /&gt;
        app.cleanUp()&lt;br /&gt;
        del app&lt;br /&gt;
&lt;br /&gt;
And here is the link for the formatted [http://pastebin.com/d8RyqvSg source]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Dermont</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_PyCEGUI_with_glfw3_and_PyOpenGL_(0.8)&amp;diff=5646</id>
		<title>Using PyCEGUI with glfw3 and PyOpenGL (0.8)</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_PyCEGUI_with_glfw3_and_PyOpenGL_(0.8)&amp;diff=5646"/>
				<updated>2015-03-27T13:07:15Z</updated>
		
		<summary type="html">&lt;p&gt;Dermont: /* Main Loop */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.8}}&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
For this example it is assumed that  [http://www.glfw.org/download.html glfw3] and [http://www.opengl.org OpenGL] are already installed. &lt;br /&gt;
We will be using the bindings for [https://github.com/rougier/pyglfw.git python glfw3] from Nicolas P. Rougier. Download from git clone https://github.com/rougier/pyglfw.git and copy the file glfw.py to the directory you are running the demo from.&lt;br /&gt;
&lt;br /&gt;
== Importing Modules ==&lt;br /&gt;
If you have trouble importing the PyCEGUI libraries you can update your python path to point to the location of the modules. For Linux you can simply point to your CEGUI build_dir/lib.&lt;br /&gt;
&lt;br /&gt;
    for _path in [os.path.join(s,'cegui-0.8') for s in site.getsitepackages()]:&lt;br /&gt;
        print _path&lt;br /&gt;
        sys.path.insert(0, _path)&lt;br /&gt;
    #sys.path.insert(0, &amp;quot;/media/sdb5/python-ogre-cegui/cegui-0.8/lib&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Setting Data Path ==&lt;br /&gt;
Set your path to the CEGUI media dir.&lt;br /&gt;
&lt;br /&gt;
    CEGUI_PATH = &amp;quot;/media/sdb5/Libraries/OGRE/sdk/v1-9/share/cegui-0/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mouse/KeyBoard Mappings==&lt;br /&gt;
&lt;br /&gt;
    def ConvertMouseButton(button):&lt;br /&gt;
        ##Convert Mouse Buttons to CEGUI&lt;br /&gt;
        if (button == glfw.GLFW_MOUSE_BUTTON_RIGHT):&lt;br /&gt;
            return PyCEGUI.RightButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_LEFT):&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_MIDDLE):&lt;br /&gt;
            return PyCEGUI.MiddleButton&lt;br /&gt;
        else:&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
&lt;br /&gt;
Copy the following keyboard mappings to keymappings_glfw3.py in same directory as the demo.&lt;br /&gt;
&lt;br /&gt;
    import sys&lt;br /&gt;
    import glfw&lt;br /&gt;
    import PyCEGUI&lt;br /&gt;
    KEYMAPPINGS = {&lt;br /&gt;
        glfw.GLFW_KEY_UNKNOWN       : PyCEGUI.Key.Unknown, &lt;br /&gt;
        glfw.GLFW_KEY_SPACE         : PyCEGUI.Key.Space,&lt;br /&gt;
        glfw.GLFW_KEY_APOSTROPHE    : PyCEGUI.Key.Apostrophe,&lt;br /&gt;
        glfw.GLFW_KEY_COMMA         : PyCEGUI.Key.Comma,&lt;br /&gt;
        glfw.GLFW_KEY_MINUS         : PyCEGUI.Key.Minus,&lt;br /&gt;
        glfw.GLFW_KEY_PERIOD        : PyCEGUI.Key.Period,&lt;br /&gt;
        glfw.GLFW_KEY_SLASH         : PyCEGUI.Key.Slash,&lt;br /&gt;
        glfw.GLFW_KEY_0             : PyCEGUI.Key.Zero,&lt;br /&gt;
        glfw.GLFW_KEY_1             : PyCEGUI.Key.One,&lt;br /&gt;
        glfw.GLFW_KEY_2             : PyCEGUI.Key.Two,&lt;br /&gt;
        glfw.GLFW_KEY_3             : PyCEGUI.Key.Three,&lt;br /&gt;
        glfw.GLFW_KEY_4             : PyCEGUI.Key.Four,&lt;br /&gt;
        glfw.GLFW_KEY_5             : PyCEGUI.Key.Five,&lt;br /&gt;
        glfw.GLFW_KEY_6             : PyCEGUI.Key.Six,&lt;br /&gt;
        glfw.GLFW_KEY_7             : PyCEGUI.Key.Seven,&lt;br /&gt;
        glfw.GLFW_KEY_8             : PyCEGUI.Key.Eight,&lt;br /&gt;
        glfw.GLFW_KEY_9             : PyCEGUI.Key.Nine,&lt;br /&gt;
        glfw.GLFW_KEY_SEMICOLON     : PyCEGUI.Key.Semicolon,&lt;br /&gt;
        glfw.GLFW_KEY_EQUAL         : PyCEGUI.Key.Equals,&lt;br /&gt;
        glfw.GLFW_KEY_A             : PyCEGUI.Key.A,&lt;br /&gt;
        glfw.GLFW_KEY_B             : PyCEGUI.Key.B,&lt;br /&gt;
        glfw.GLFW_KEY_C             : PyCEGUI.Key.C,&lt;br /&gt;
        glfw.GLFW_KEY_D             : PyCEGUI.Key.D,&lt;br /&gt;
        glfw.GLFW_KEY_E             : PyCEGUI.Key.E,&lt;br /&gt;
        glfw.GLFW_KEY_F             : PyCEGUI.Key.F,&lt;br /&gt;
        glfw.GLFW_KEY_G             : PyCEGUI.Key.G,&lt;br /&gt;
        glfw.GLFW_KEY_H             : PyCEGUI.Key.H,&lt;br /&gt;
        glfw.GLFW_KEY_I             : PyCEGUI.Key.I,&lt;br /&gt;
        glfw.GLFW_KEY_J             : PyCEGUI.Key.J,&lt;br /&gt;
        glfw.GLFW_KEY_K             : PyCEGUI.Key.K,&lt;br /&gt;
        glfw.GLFW_KEY_L             : PyCEGUI.Key.L,&lt;br /&gt;
        glfw.GLFW_KEY_M             : PyCEGUI.Key.M,&lt;br /&gt;
        glfw.GLFW_KEY_N             : PyCEGUI.Key.N,&lt;br /&gt;
        glfw.GLFW_KEY_O             : PyCEGUI.Key.O,&lt;br /&gt;
        glfw.GLFW_KEY_P             : PyCEGUI.Key.P,&lt;br /&gt;
        glfw.GLFW_KEY_Q             : PyCEGUI.Key.Q,&lt;br /&gt;
        glfw.GLFW_KEY_R             : PyCEGUI.Key.R,&lt;br /&gt;
        glfw.GLFW_KEY_S             : PyCEGUI.Key.S,&lt;br /&gt;
        glfw.GLFW_KEY_T             : PyCEGUI.Key.T,&lt;br /&gt;
        glfw.GLFW_KEY_U             : PyCEGUI.Key.U,&lt;br /&gt;
        glfw.GLFW_KEY_V             : PyCEGUI.Key.V,&lt;br /&gt;
        glfw.GLFW_KEY_W             : PyCEGUI.Key.W,&lt;br /&gt;
        glfw.GLFW_KEY_X             : PyCEGUI.Key.X,&lt;br /&gt;
        glfw.GLFW_KEY_Y             : PyCEGUI.Key.Y,&lt;br /&gt;
        glfw.GLFW_KEY_Z             : PyCEGUI.Key.Z,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_BRACKET  : PyCEGUI.Key.LeftBracket,&lt;br /&gt;
        glfw.GLFW_KEY_BACKSLASH     : PyCEGUI.Key.Backslash,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_BRACKET : PyCEGUI.Key.RightBracket,&lt;br /&gt;
        glfw.GLFW_KEY_GRAVE_ACCENT  : PyCEGUI.Key.Grave,&lt;br /&gt;
        glfw.GLFW_KEY_WORLD_1       : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_WORLD_2       : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_ESCAPE        : PyCEGUI.Key.Escape,&lt;br /&gt;
        glfw.GLFW_KEY_ENTER         : PyCEGUI.Key.Return,&lt;br /&gt;
        glfw.GLFW_KEY_TAB           : PyCEGUI.Key.Tab,&lt;br /&gt;
        glfw.GLFW_KEY_BACKSPACE     : PyCEGUI.Key.Backspace,&lt;br /&gt;
        glfw.GLFW_KEY_INSERT        : PyCEGUI.Key.Insert,&lt;br /&gt;
        glfw.GLFW_KEY_DELETE        : PyCEGUI.Key.Delete,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT         : PyCEGUI.Key.ArrowRight,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT          : PyCEGUI.Key.ArrowLeft,&lt;br /&gt;
        glfw.GLFW_KEY_DOWN          : PyCEGUI.Key.ArrowDown,&lt;br /&gt;
        glfw.GLFW_KEY_UP            : PyCEGUI.Key.ArrowUp,&lt;br /&gt;
        glfw.GLFW_KEY_PAGE_UP       : PyCEGUI.Key.PageUp,&lt;br /&gt;
        glfw.GLFW_KEY_PAGE_DOWN     : PyCEGUI.Key.PageDown,&lt;br /&gt;
        glfw.GLFW_KEY_HOME          : PyCEGUI.Key.Home,&lt;br /&gt;
        glfw.GLFW_KEY_END           : PyCEGUI.Key.End,&lt;br /&gt;
        glfw.GLFW_KEY_CAPS_LOCK     : PyCEGUI.Key.Capital,&lt;br /&gt;
        glfw.GLFW_KEY_SCROLL_LOCK   : PyCEGUI.Key.ScrollLock,&lt;br /&gt;
        glfw.GLFW_KEY_NUM_LOCK      : PyCEGUI.Key.NumLock,&lt;br /&gt;
        glfw.GLFW_KEY_PRINT_SCREEN  : PyCEGUI.Key.SysRq,&lt;br /&gt;
        glfw.GLFW_KEY_PAUSE         : PyCEGUI.Key.Pause,&lt;br /&gt;
        glfw.GLFW_KEY_F1            : PyCEGUI.Key.F1,&lt;br /&gt;
        glfw.GLFW_KEY_F2            : PyCEGUI.Key.F2,&lt;br /&gt;
        glfw.GLFW_KEY_F3            : PyCEGUI.Key.F3,&lt;br /&gt;
        glfw.GLFW_KEY_F4            : PyCEGUI.Key.F4,&lt;br /&gt;
        glfw.GLFW_KEY_F5            : PyCEGUI.Key.F5,&lt;br /&gt;
        glfw.GLFW_KEY_F6            : PyCEGUI.Key.F6,&lt;br /&gt;
        glfw.GLFW_KEY_F7            : PyCEGUI.Key.F7,&lt;br /&gt;
        glfw.GLFW_KEY_F8            : PyCEGUI.Key.F8,&lt;br /&gt;
        glfw.GLFW_KEY_F9            : PyCEGUI.Key.F9,&lt;br /&gt;
        glfw.GLFW_KEY_F10           : PyCEGUI.Key.F10,&lt;br /&gt;
        glfw.GLFW_KEY_F11           : PyCEGUI.Key.F11,&lt;br /&gt;
        glfw.GLFW_KEY_F12           : PyCEGUI.Key.F12,&lt;br /&gt;
        glfw.GLFW_KEY_F13           : PyCEGUI.Key.F13,&lt;br /&gt;
        glfw.GLFW_KEY_F14           : PyCEGUI.Key.F14,&lt;br /&gt;
        glfw.GLFW_KEY_F15           : PyCEGUI.Key.F15,&lt;br /&gt;
        glfw.GLFW_KEY_F16           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F17           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F18           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F19           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F20           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F21           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F22           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F23           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F24           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F25           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_KP_0          : PyCEGUI.Key.Numpad0,&lt;br /&gt;
        glfw.GLFW_KEY_KP_1          : PyCEGUI.Key.Numpad1,&lt;br /&gt;
        glfw.GLFW_KEY_KP_2          : PyCEGUI.Key.Numpad2,&lt;br /&gt;
        glfw.GLFW_KEY_KP_3          : PyCEGUI.Key.Numpad3,&lt;br /&gt;
        glfw.GLFW_KEY_KP_4          : PyCEGUI.Key.Numpad4,&lt;br /&gt;
        glfw.GLFW_KEY_KP_5          : PyCEGUI.Key.Numpad5,&lt;br /&gt;
        glfw.GLFW_KEY_KP_6          : PyCEGUI.Key.Numpad6,&lt;br /&gt;
        glfw.GLFW_KEY_KP_7          : PyCEGUI.Key.Numpad7,&lt;br /&gt;
        glfw.GLFW_KEY_KP_8          : PyCEGUI.Key.Numpad8,&lt;br /&gt;
        glfw.GLFW_KEY_KP_9          : PyCEGUI.Key.Numpad9,&lt;br /&gt;
        glfw.GLFW_KEY_KP_DECIMAL    : PyCEGUI.Key.Decimal,&lt;br /&gt;
        glfw.GLFW_KEY_KP_DIVIDE     : PyCEGUI.Key.Divide,&lt;br /&gt;
        glfw.GLFW_KEY_KP_MULTIPLY   : PyCEGUI.Key.Multiply,&lt;br /&gt;
        glfw.GLFW_KEY_KP_SUBTRACT   : PyCEGUI.Key.Subtract,&lt;br /&gt;
        glfw.GLFW_KEY_KP_ADD        : PyCEGUI.Key.Add,&lt;br /&gt;
        glfw.GLFW_KEY_KP_ENTER      : PyCEGUI.Key.NumpadEnter,&lt;br /&gt;
        glfw.GLFW_KEY_KP_EQUAL      : PyCEGUI.Key.NumpadEquals,     &lt;br /&gt;
        glfw.GLFW_KEY_LEFT_SHIFT    : PyCEGUI.Key.LeftShift,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_CONTROL  : PyCEGUI.Key.LeftControl,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_ALT      : PyCEGUI.Key.LeftAlt,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_SUPER    : PyCEGUI.Key.LeftWindows,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_SHIFT   : PyCEGUI.Key.RightShift,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_CONTROL : PyCEGUI.Key.RightControl,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_ALT     : PyCEGUI.Key.RightAlt,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_SUPER   : PyCEGUI.Key.RightWindows,&lt;br /&gt;
        glfw.GLFW_KEY_MENU          : PyCEGUI.Key.AppMenu,&lt;br /&gt;
        glfw.GLFW_KEY_LAST          : PyCEGUI.Key.AppMenu&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Initialization glf3==&lt;br /&gt;
&lt;br /&gt;
    # Initialize glfw&lt;br /&gt;
    if not glfw.glfwInit():&lt;br /&gt;
        print (&amp;quot; Error : glfw failed to initialize&amp;quot;)&lt;br /&gt;
        sys.exit (glfw.EXIT_FAILURE)&lt;br /&gt;
&lt;br /&gt;
== Window Hints==&lt;br /&gt;
&lt;br /&gt;
Glfw3 allows to define window hints prior to creation and hints about your OpenGL Context (OpenGL Version). Note the MAJOR/MINOR values are the minimum API version of the window context, i.e. if you graphics card supports GL 4.4 that is what will be returned.&lt;br /&gt;
&lt;br /&gt;
GLFW_OPENGL_FORWARD_COMPAT (True) indicates that functionality deprecated in the requested version of OpenGL is removed.&lt;br /&gt;
&lt;br /&gt;
For the sake of testing PyCEGUI's OpenGL render set: &lt;br /&gt;
  ceguiGL3Renderer(True)/ GLFW_OPENGL_FORWARD_COMPAT(True)   - OpenGL3Renderer without GL2.1&lt;br /&gt;
  ceguiGL3Renderer(True)/ GLFW_OPENGL_FORWARD_COMPAT(False)  - OpenGL3Renderer with    GL2.1&lt;br /&gt;
  ceguiGL3Renderer(False)                                    - OpenGLRenderer&lt;br /&gt;
 &lt;br /&gt;
    ceguiGL3Renderer = True&lt;br /&gt;
    if ceguiGL3Renderer:&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 2)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, PyGL.GL_TRUE)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)&lt;br /&gt;
    else:&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 2)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 1)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_ANY_PROFILE)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Window==&lt;br /&gt;
If you try to create a window with a context that you graphics card does not support glfwCreateWindow will fail. We&lt;br /&gt;
also need to make our context current prior to creating our PyCEGUI renderer.&lt;br /&gt;
&lt;br /&gt;
    glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, None, None)&lt;br /&gt;
    if not glfw_window:&lt;br /&gt;
        print (&amp;quot; Error : glfw failed to create a window&amp;quot;)&lt;br /&gt;
        glfw.glfwTerminate()&lt;br /&gt;
        sys.exit()&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwMakeContextCurrent(glfw_window)&lt;br /&gt;
&lt;br /&gt;
== VSnyc ==&lt;br /&gt;
This does nothing on linux and is dependent on your card settings. For example with a NVidia card change settings with NVidia X Server Settings-&amp;gt;OpenGL Settings-&amp;gt;Sync to VBlank.&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwSwapInterval(0)&lt;br /&gt;
&lt;br /&gt;
== Callbacks ==&lt;br /&gt;
See the source for each of the following callbacks where we notify CEGUI of display size changes, mouse presses/movement, key presses and glfwSetCharCallback is our callback to pass the unicode char/key pressed to CEGUI.&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwSetKeyCallback(             glfw_window,  self.on_key)&lt;br /&gt;
    glfw.glfwSetMouseButtonCallback(     glfw_window,  self.on_mouse)&lt;br /&gt;
    glfw.glfwSetCursorPosCallback(       glfw_window,  self.on_move)&lt;br /&gt;
    glfw.glfwSetWindowSizeCallback(      glfw_window,  self.on_resize)&lt;br /&gt;
    glfw.glfwSetCharCallback(            glfw_window,  self.on_char_callback)&lt;br /&gt;
    glfw.glfwSetFramebufferSizeCallback( glfw_window,  self.on_framebuffer_size_callback)&lt;br /&gt;
&lt;br /&gt;
== PyCEGUI Renderer ==&lt;br /&gt;
Create our PyCEGUI renderer.&lt;br /&gt;
&lt;br /&gt;
    if (not ceguiGL3Renderer):&lt;br /&gt;
        PyCEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()&lt;br /&gt;
    else :&lt;br /&gt;
        PyCEGUIOpenGLRenderer.OpenGL3Renderer.bootstrapSystem()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Main Loop ==&lt;br /&gt;
Our main loop runs until the glfw3 window is closed updating CEGUI, swapping the buffers and handling glfw events.&lt;br /&gt;
&lt;br /&gt;
    def updateCEGUI(self, elapsed):&lt;br /&gt;
        ##CEGUI updates ###&lt;br /&gt;
        if (PyCEGUI.System.getSingleton()):&lt;br /&gt;
            PyCEGUI.System.getSingleton().injectTimePulse(elapsed)&lt;br /&gt;
            PyCEGUI.System.getSingleton().renderAllGUIContexts()&lt;br /&gt;
            self.labelFPS.setText(&amp;quot;FPS : %s&amp;quot; %(str(int(1.0/elapsed))))&lt;br /&gt;
&lt;br /&gt;
    while not glfw.glfwWindowShouldClose(self.glfw_window):&lt;br /&gt;
        PyGL.glClear(PyGL.GL_COLOR_BUFFER_BIT)&lt;br /&gt;
        # update timing&lt;br /&gt;
        self.current_time = glfw.glfwGetTime()&lt;br /&gt;
        elapsed = self.current_time - self.previous_time&lt;br /&gt;
        self.previous_time = self.current_time&lt;br /&gt;
        # update GL/CEGUI&lt;br /&gt;
        self.updateGL()&lt;br /&gt;
        self.updateCEGUI(elapsed)&lt;br /&gt;
        # Swap front and back buffers&lt;br /&gt;
        glfw.glfwSwapBuffers(self.glfw_window)&lt;br /&gt;
        # Handle glfw events&lt;br /&gt;
        glfw.glfwPollEvents()&lt;br /&gt;
&lt;br /&gt;
== Demo Source ==&lt;br /&gt;
&lt;br /&gt;
This is the full source code for the demo, see above saving the keyboard mappings.  &lt;br /&gt;
&lt;br /&gt;
     # -- coding: utf-8 --&lt;br /&gt;
&lt;br /&gt;
    import glfw&lt;br /&gt;
    import OpenGL.GL as PyGL&lt;br /&gt;
    import sys, os , site&lt;br /&gt;
&lt;br /&gt;
    ## set the path of your PyCEGUI* modules&lt;br /&gt;
    for _path in [os.path.join(s,'cegui-0.8') for s in site.getsitepackages()]:&lt;br /&gt;
        print _path&lt;br /&gt;
        sys.path.insert(0, _path)&lt;br /&gt;
    sys.path.insert(0, &amp;quot;/media/sdb5/python-ogre-cegui/cegui-0.8/lib&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ## set the path to our resource files&lt;br /&gt;
    CEGUI_PATH = &amp;quot;/media/sdb5/Libraries/OGRE/sdk/v1-9/share/cegui-0/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    ## import our PyCEGUI and out glfw3 to cegui key mappings&lt;br /&gt;
    import PyCEGUI&lt;br /&gt;
    import PyCEGUIOpenGLRenderer&lt;br /&gt;
    from keymappings_glfw3 import *&lt;br /&gt;
&lt;br /&gt;
    def ConvertMouseButton(button):&lt;br /&gt;
        ''' Convert Mouse Buttons to CEGUI '''&lt;br /&gt;
        if (button == glfw.GLFW_MOUSE_BUTTON_RIGHT):&lt;br /&gt;
            return PyCEGUI.RightButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_LEFT):&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_MIDDLE):&lt;br /&gt;
            return PyCEGUI.MiddleButton&lt;br /&gt;
        else:&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
&lt;br /&gt;
    class Application(object):&lt;br /&gt;
        def __init__(self):&lt;br /&gt;
&lt;br /&gt;
            # Initialize glfw&lt;br /&gt;
            if not glfw.glfwInit():&lt;br /&gt;
                print (&amp;quot; Error : glfw failed to initialize&amp;quot;)&lt;br /&gt;
                sys.exit (glfw.EXIT_FAILURE)&lt;br /&gt;
&lt;br /&gt;
            ceguiGL3Renderer = True&lt;br /&gt;
            if ceguiGL3Renderer:&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 2)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, PyGL.GL_TRUE)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)&lt;br /&gt;
            else:&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 2)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 1)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_ANY_PROFILE)&lt;br /&gt;
&lt;br /&gt;
            # our window hints&lt;br /&gt;
            ## http://www.glfw.org/docs/latest/window.html&lt;br /&gt;
            ## set our framebuffer related hints&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_DEPTH_BITS, 24)&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_STENCIL_BITS, 8)&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_FOCUSED, True)&lt;br /&gt;
&lt;br /&gt;
            fullScreen = False&lt;br /&gt;
            # create window&lt;br /&gt;
            if (not fullScreen):&lt;br /&gt;
                glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, None, None)&lt;br /&gt;
            else:&lt;br /&gt;
                glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, glfw.glfwGetPrimaryMonitor(), None)&lt;br /&gt;
&lt;br /&gt;
            # check window created&lt;br /&gt;
            if not glfw_window:&lt;br /&gt;
                print (&amp;quot; Error : glfw failed to create a window&amp;quot;)&lt;br /&gt;
                glfw.glfwTerminate()&lt;br /&gt;
                sys.exit()&lt;br /&gt;
            self.glfw_window = glfw_window&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwMakeContextCurrent(glfw_window)&lt;br /&gt;
&lt;br /&gt;
            self.showglfwInfo()&lt;br /&gt;
&lt;br /&gt;
            ## this does nothing on linux&lt;br /&gt;
            glfw.glfwSwapInterval(0)&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwSetInputMode(glfw_window, glfw.GLFW_CURSOR, glfw.GLFW_CURSOR_HIDDEN)&lt;br /&gt;
&lt;br /&gt;
            # call backs&lt;br /&gt;
            glfw.glfwSetKeyCallback(             glfw_window,  self.on_key)&lt;br /&gt;
            glfw.glfwSetMouseButtonCallback(     glfw_window,  self.on_mouse)&lt;br /&gt;
            glfw.glfwSetCursorPosCallback(       glfw_window,  self.on_move)&lt;br /&gt;
            glfw.glfwSetWindowSizeCallback(      glfw_window,  self.on_resize)&lt;br /&gt;
            glfw.glfwSetCharCallback(            glfw_window,  self.on_char_callback)&lt;br /&gt;
            glfw.glfwSetFramebufferSizeCallback( glfw_window,  self.on_framebuffer_size_callback)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            # initialise our CEGUI renderer&lt;br /&gt;
            ctx_major      = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            ctx_minor      = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MINOR)&lt;br /&gt;
            forward_compat = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_OPENGL_FORWARD_COMPAT)&lt;br /&gt;
&lt;br /&gt;
            if (not ceguiGL3Renderer):&lt;br /&gt;
                PyCEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()&lt;br /&gt;
            else :&lt;br /&gt;
                PyCEGUIOpenGLRenderer.OpenGL3Renderer.bootstrapSystem()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            # initialise PyCEGUI and resources&lt;br /&gt;
            rp = PyCEGUI.System.getSingleton().getResourceProvider()&lt;br /&gt;
         &lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;schemes&amp;quot;,    CEGUI_PATH + &amp;quot;schemes&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;imagesets&amp;quot;,  CEGUI_PATH + &amp;quot;imagesets&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;fonts&amp;quot;,      CEGUI_PATH + &amp;quot;fonts&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;layouts&amp;quot;,    CEGUI_PATH + &amp;quot;layouts&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;looknfeels&amp;quot;, CEGUI_PATH + &amp;quot;looknfeel&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;schemas&amp;quot;,    CEGUI_PATH + &amp;quot;xml_schemas&amp;quot;)&lt;br /&gt;
         &lt;br /&gt;
            PyCEGUI.ImageManager.setImagesetDefaultResourceGroup(&amp;quot;imagesets&amp;quot;)&lt;br /&gt;
            PyCEGUI.Font.setDefaultResourceGroup(&amp;quot;fonts&amp;quot;)&lt;br /&gt;
            PyCEGUI.Scheme.setDefaultResourceGroup(&amp;quot;schemes&amp;quot;)&lt;br /&gt;
            PyCEGUI.WidgetLookManager.setDefaultResourceGroup(&amp;quot;looknfeels&amp;quot;)&lt;br /&gt;
            PyCEGUI.WindowManager.setDefaultResourceGroup(&amp;quot;layouts&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            parser = PyCEGUI.System.getSingleton().getXMLParser()&lt;br /&gt;
            if parser.isPropertyPresent(&amp;quot;SchemaDefaultResourceGroup&amp;quot;):&lt;br /&gt;
                parser.setProperty(&amp;quot;SchemaDefaultResourceGroup&amp;quot;, &amp;quot;schemas&amp;quot;)     &lt;br /&gt;
&lt;br /&gt;
            # Load schemes&lt;br /&gt;
            PyCEGUI.SchemeManager.getSingleton().createFromFile(&amp;quot;TaharezLook.scheme&amp;quot;)&lt;br /&gt;
            PyCEGUI.SchemeManager.getSingleton().createFromFile(&amp;quot;WindowsLook.scheme&amp;quot;)&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage(&amp;quot;TaharezLook/MouseArrow&amp;quot;)&lt;br /&gt;
         &lt;br /&gt;
            # set root window&lt;br /&gt;
            root = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;DefaultWindow&amp;quot;, &amp;quot;background_wnd&amp;quot;);&lt;br /&gt;
            root.setArea( PyCEGUI.UVector2(PyCEGUI.UDim(0.0, 0),PyCEGUI.UDim(0.0, 0)) ,PyCEGUI.USize(PyCEGUI.UDim(1.0, 0),PyCEGUI.UDim(1.0, 0)))&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().setRootWindow(root)&lt;br /&gt;
&lt;br /&gt;
            # load a layout&lt;br /&gt;
            layout = PyCEGUI.WindowManager.getSingleton().loadLayoutFromFile(&amp;quot;TextDemo.layout&amp;quot;)&lt;br /&gt;
            root.addChild(layout.getChild('TextDemo'))&lt;br /&gt;
            self.edit = root.getChild('TextDemo/MultiLineGroup/editMulti')&lt;br /&gt;
&lt;br /&gt;
            # create label for our FPS&lt;br /&gt;
            self.labelFPS = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;TaharezLook/Label&amp;quot;, &amp;quot;FPSLabel&amp;quot;)&lt;br /&gt;
            root.addChild(self.labelFPS)&lt;br /&gt;
&lt;br /&gt;
            # create hello button&lt;br /&gt;
            button = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;TaharezLook/Button&amp;quot;, &amp;quot;HelloButton&amp;quot;)&lt;br /&gt;
            button.setArea( PyCEGUI.UVector2(PyCEGUI.UDim(.50, 0),PyCEGUI.UDim(.92, 0)) ,PyCEGUI.USize(PyCEGUI.UDim(0.3, 0),PyCEGUI.UDim(0.05, 0)))&lt;br /&gt;
            button.setText(&amp;quot;Hello&amp;quot;)&lt;br /&gt;
            root.addChild(button)&lt;br /&gt;
            button.subscribeEvent(PyCEGUI.PushButton.EventClicked, self.OnbuttonClicked)&lt;br /&gt;
&lt;br /&gt;
            # init simple timing&lt;br /&gt;
            self.previous_time = glfw.glfwGetTime()&lt;br /&gt;
            self.current_time  = self.previous_time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        def showglfwInfo(self):&lt;br /&gt;
            ctx_major      = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            ctx_minor      = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_CONTEXT_VERSION_MINOR)&lt;br /&gt;
            forward_compat = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_OPENGL_FORWARD_COMPAT)&lt;br /&gt;
            print &amp;quot;Created Window for OpenGL version %d.%d &amp;quot; % ( ctx_major, ctx_major )&lt;br /&gt;
            if ( ctx_major &amp;gt;=3 and forward_compat):&lt;br /&gt;
                print &amp;quot;Context is forward compatible, you can't use OpenGL 2.x commands&amp;quot; &lt;br /&gt;
            fwidth,fheight = glfw.glfwGetFramebufferSize(self.glfw_window)&lt;br /&gt;
            width, height =  glfw.glfwGetWindowSize(self.glfw_window)&lt;br /&gt;
     &lt;br /&gt;
            print &amp;quot;Framebuffer size %dx%d Window size %dx%d &amp;quot; % (fwidth,fheight, width,height) &lt;br /&gt;
&lt;br /&gt;
        def OnbuttonClicked(self, args):&lt;br /&gt;
            self.edit.setText(self.edit.getText() + &amp;quot;You Clicked&amp;quot;)&lt;br /&gt;
            return&lt;br /&gt;
&lt;br /&gt;
        def cleanUp(self):&lt;br /&gt;
            ''' shutdown glfw and CEGUI '''&lt;br /&gt;
            PyCEGUIOpenGLRenderer.OpenGLRenderer.destroySystem()&lt;br /&gt;
            glfw.glfwTerminate()&lt;br /&gt;
&lt;br /&gt;
        def updateGL(self):&lt;br /&gt;
            ''' glfw GL updates '''&lt;br /&gt;
            pass&lt;br /&gt;
        &lt;br /&gt;
        def updateCEGUI(self, elapsed):&lt;br /&gt;
            ''' CEGUI updates '''&lt;br /&gt;
            #focused = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
&lt;br /&gt;
            if (PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().injectTimePulse(elapsed)&lt;br /&gt;
                PyCEGUI.System.getSingleton().renderAllGUIContexts()&lt;br /&gt;
                self.labelFPS.setText(&amp;quot;FPS : %s&amp;quot; %(str(int(1.0/elapsed))))&lt;br /&gt;
&lt;br /&gt;
        def mainLoop(self):&lt;br /&gt;
            ''' Loop until glfw window is closed '''&lt;br /&gt;
&lt;br /&gt;
            while not glfw.glfwWindowShouldClose(self.glfw_window):&lt;br /&gt;
&lt;br /&gt;
                PyGL.glClear(PyGL.GL_COLOR_BUFFER_BIT)&lt;br /&gt;
&lt;br /&gt;
                # update timing&lt;br /&gt;
                self.current_time = glfw.glfwGetTime()&lt;br /&gt;
                elapsed = self.current_time - self.previous_time&lt;br /&gt;
                self.previous_time = self.current_time&lt;br /&gt;
&lt;br /&gt;
                # update GL/CEGUI&lt;br /&gt;
                self.updateGL()&lt;br /&gt;
                self.updateCEGUI(elapsed)&lt;br /&gt;
&lt;br /&gt;
                # Swap front and back buffers&lt;br /&gt;
                glfw.glfwSwapBuffers(self.glfw_window)&lt;br /&gt;
&lt;br /&gt;
                # Handle glfw events&lt;br /&gt;
                glfw.glfwPollEvents()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        def on_framebuffer_size_callback(self,window,width,height):&lt;br /&gt;
            ''' the framebuffer on high-DPI monitors may differ from the screen co-ords, so notify display size change here '''&lt;br /&gt;
            PyGL.glViewport(0, 0, width, height)&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().notifyDisplaySizeChanged(PyCEGUI.Sizef(float(width), float(height) ))&lt;br /&gt;
&lt;br /&gt;
        def on_move(self, window, x,y):&lt;br /&gt;
            ''' pass glfw mouse moves to CEGUI '''&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().getDefaultGUIContext().injectMousePosition(x, y)&lt;br /&gt;
&lt;br /&gt;
        def on_resize(self, window, width,height):&lt;br /&gt;
            ''' resize glfw viewport and CEGUI display '''&lt;br /&gt;
            PyGL.glViewport(0, 0, width, height)&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().notifyDisplaySizeChanged(PyCEGUI.Sizef(float(width), float(height) ))&lt;br /&gt;
&lt;br /&gt;
        def on_mouse(self, window, button, action, mods):&lt;br /&gt;
            ''' pass glfw mouse press events to CEGUI '''&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                context = PyCEGUI.System.getSingleton().getDefaultGUIContext()&lt;br /&gt;
                if (action == glfw.GLFW_PRESS):&lt;br /&gt;
                    context.injectMouseButtonDown( ConvertMouseButton(button) )&lt;br /&gt;
                if (action == glfw.GLFW_RELEASE):&lt;br /&gt;
                    context.injectMouseButtonUp( ConvertMouseButton(button) )&lt;br /&gt;
&lt;br /&gt;
        def on_char_callback(self, window, code):&lt;br /&gt;
            ''' Unicode character callback function to CEGUI '''&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().injectChar(code)&lt;br /&gt;
&lt;br /&gt;
        def on_key(self, window, key, scancode, action, mods):&lt;br /&gt;
            ''' pass keypress events to CEGUI '''&lt;br /&gt;
            if PyCEGUI.System.getSingleton():&lt;br /&gt;
                cegui_key = KEYMAPPINGS[key]&lt;br /&gt;
                if (not cegui_key==PyCEGUI.Key.Unknown):&lt;br /&gt;
                    if (action == glfw.GLFW_PRESS):&lt;br /&gt;
                        PyCEGUI.System.getSingleton().getDefaultGUIContext().injectKeyDown(PyCEGUI.Key.Scan(cegui_key))&lt;br /&gt;
                    if (action == glfw.GLFW_RELEASE):&lt;br /&gt;
                        PyCEGUI.System.getSingleton().getDefaultGUIContext().injectKeyUp(PyCEGUI.Key.Scan(cegui_key))&lt;br /&gt;
&lt;br /&gt;
            ## exit&lt;br /&gt;
            if key == glfw.GLFW_KEY_ESCAPE and action == glfw.GLFW_PRESS:&lt;br /&gt;
                glfw.glfwSetWindowShouldClose(window,1)&lt;br /&gt;
    if __name__ == '__main__':&lt;br /&gt;
        app = Application()&lt;br /&gt;
        app.mainLoop()&lt;br /&gt;
        app.cleanUp()&lt;br /&gt;
        del app&lt;br /&gt;
&lt;br /&gt;
And here is the link for the formatted [http://pastebin.com/d8RyqvSg source]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Dermont</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_PyCEGUI_with_glfw3_and_PyOpenGL_(0.8)&amp;diff=5645</id>
		<title>Using PyCEGUI with glfw3 and PyOpenGL (0.8)</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_PyCEGUI_with_glfw3_and_PyOpenGL_(0.8)&amp;diff=5645"/>
				<updated>2015-03-27T13:06:19Z</updated>
		
		<summary type="html">&lt;p&gt;Dermont: /* Mouse/KeyBoard Mappings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.8}}&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
For this example it is assumed that  [http://www.glfw.org/download.html glfw3] and [http://www.opengl.org OpenGL] are already installed. &lt;br /&gt;
We will be using the bindings for [https://github.com/rougier/pyglfw.git python glfw3] from Nicolas P. Rougier. Download from git clone https://github.com/rougier/pyglfw.git and copy the file glfw.py to the directory you are running the demo from.&lt;br /&gt;
&lt;br /&gt;
== Importing Modules ==&lt;br /&gt;
If you have trouble importing the PyCEGUI libraries you can update your python path to point to the location of the modules. For Linux you can simply point to your CEGUI build_dir/lib.&lt;br /&gt;
&lt;br /&gt;
    for _path in [os.path.join(s,'cegui-0.8') for s in site.getsitepackages()]:&lt;br /&gt;
        print _path&lt;br /&gt;
        sys.path.insert(0, _path)&lt;br /&gt;
    #sys.path.insert(0, &amp;quot;/media/sdb5/python-ogre-cegui/cegui-0.8/lib&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Setting Data Path ==&lt;br /&gt;
Set your path to the CEGUI media dir.&lt;br /&gt;
&lt;br /&gt;
    CEGUI_PATH = &amp;quot;/media/sdb5/Libraries/OGRE/sdk/v1-9/share/cegui-0/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mouse/KeyBoard Mappings==&lt;br /&gt;
&lt;br /&gt;
    def ConvertMouseButton(button):&lt;br /&gt;
        ##Convert Mouse Buttons to CEGUI&lt;br /&gt;
        if (button == glfw.GLFW_MOUSE_BUTTON_RIGHT):&lt;br /&gt;
            return PyCEGUI.RightButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_LEFT):&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_MIDDLE):&lt;br /&gt;
            return PyCEGUI.MiddleButton&lt;br /&gt;
        else:&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
&lt;br /&gt;
Copy the following keyboard mappings to keymappings_glfw3.py in same directory as the demo.&lt;br /&gt;
&lt;br /&gt;
    import sys&lt;br /&gt;
    import glfw&lt;br /&gt;
    import PyCEGUI&lt;br /&gt;
    KEYMAPPINGS = {&lt;br /&gt;
        glfw.GLFW_KEY_UNKNOWN       : PyCEGUI.Key.Unknown, &lt;br /&gt;
        glfw.GLFW_KEY_SPACE         : PyCEGUI.Key.Space,&lt;br /&gt;
        glfw.GLFW_KEY_APOSTROPHE    : PyCEGUI.Key.Apostrophe,&lt;br /&gt;
        glfw.GLFW_KEY_COMMA         : PyCEGUI.Key.Comma,&lt;br /&gt;
        glfw.GLFW_KEY_MINUS         : PyCEGUI.Key.Minus,&lt;br /&gt;
        glfw.GLFW_KEY_PERIOD        : PyCEGUI.Key.Period,&lt;br /&gt;
        glfw.GLFW_KEY_SLASH         : PyCEGUI.Key.Slash,&lt;br /&gt;
        glfw.GLFW_KEY_0             : PyCEGUI.Key.Zero,&lt;br /&gt;
        glfw.GLFW_KEY_1             : PyCEGUI.Key.One,&lt;br /&gt;
        glfw.GLFW_KEY_2             : PyCEGUI.Key.Two,&lt;br /&gt;
        glfw.GLFW_KEY_3             : PyCEGUI.Key.Three,&lt;br /&gt;
        glfw.GLFW_KEY_4             : PyCEGUI.Key.Four,&lt;br /&gt;
        glfw.GLFW_KEY_5             : PyCEGUI.Key.Five,&lt;br /&gt;
        glfw.GLFW_KEY_6             : PyCEGUI.Key.Six,&lt;br /&gt;
        glfw.GLFW_KEY_7             : PyCEGUI.Key.Seven,&lt;br /&gt;
        glfw.GLFW_KEY_8             : PyCEGUI.Key.Eight,&lt;br /&gt;
        glfw.GLFW_KEY_9             : PyCEGUI.Key.Nine,&lt;br /&gt;
        glfw.GLFW_KEY_SEMICOLON     : PyCEGUI.Key.Semicolon,&lt;br /&gt;
        glfw.GLFW_KEY_EQUAL         : PyCEGUI.Key.Equals,&lt;br /&gt;
        glfw.GLFW_KEY_A             : PyCEGUI.Key.A,&lt;br /&gt;
        glfw.GLFW_KEY_B             : PyCEGUI.Key.B,&lt;br /&gt;
        glfw.GLFW_KEY_C             : PyCEGUI.Key.C,&lt;br /&gt;
        glfw.GLFW_KEY_D             : PyCEGUI.Key.D,&lt;br /&gt;
        glfw.GLFW_KEY_E             : PyCEGUI.Key.E,&lt;br /&gt;
        glfw.GLFW_KEY_F             : PyCEGUI.Key.F,&lt;br /&gt;
        glfw.GLFW_KEY_G             : PyCEGUI.Key.G,&lt;br /&gt;
        glfw.GLFW_KEY_H             : PyCEGUI.Key.H,&lt;br /&gt;
        glfw.GLFW_KEY_I             : PyCEGUI.Key.I,&lt;br /&gt;
        glfw.GLFW_KEY_J             : PyCEGUI.Key.J,&lt;br /&gt;
        glfw.GLFW_KEY_K             : PyCEGUI.Key.K,&lt;br /&gt;
        glfw.GLFW_KEY_L             : PyCEGUI.Key.L,&lt;br /&gt;
        glfw.GLFW_KEY_M             : PyCEGUI.Key.M,&lt;br /&gt;
        glfw.GLFW_KEY_N             : PyCEGUI.Key.N,&lt;br /&gt;
        glfw.GLFW_KEY_O             : PyCEGUI.Key.O,&lt;br /&gt;
        glfw.GLFW_KEY_P             : PyCEGUI.Key.P,&lt;br /&gt;
        glfw.GLFW_KEY_Q             : PyCEGUI.Key.Q,&lt;br /&gt;
        glfw.GLFW_KEY_R             : PyCEGUI.Key.R,&lt;br /&gt;
        glfw.GLFW_KEY_S             : PyCEGUI.Key.S,&lt;br /&gt;
        glfw.GLFW_KEY_T             : PyCEGUI.Key.T,&lt;br /&gt;
        glfw.GLFW_KEY_U             : PyCEGUI.Key.U,&lt;br /&gt;
        glfw.GLFW_KEY_V             : PyCEGUI.Key.V,&lt;br /&gt;
        glfw.GLFW_KEY_W             : PyCEGUI.Key.W,&lt;br /&gt;
        glfw.GLFW_KEY_X             : PyCEGUI.Key.X,&lt;br /&gt;
        glfw.GLFW_KEY_Y             : PyCEGUI.Key.Y,&lt;br /&gt;
        glfw.GLFW_KEY_Z             : PyCEGUI.Key.Z,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_BRACKET  : PyCEGUI.Key.LeftBracket,&lt;br /&gt;
        glfw.GLFW_KEY_BACKSLASH     : PyCEGUI.Key.Backslash,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_BRACKET : PyCEGUI.Key.RightBracket,&lt;br /&gt;
        glfw.GLFW_KEY_GRAVE_ACCENT  : PyCEGUI.Key.Grave,&lt;br /&gt;
        glfw.GLFW_KEY_WORLD_1       : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_WORLD_2       : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_ESCAPE        : PyCEGUI.Key.Escape,&lt;br /&gt;
        glfw.GLFW_KEY_ENTER         : PyCEGUI.Key.Return,&lt;br /&gt;
        glfw.GLFW_KEY_TAB           : PyCEGUI.Key.Tab,&lt;br /&gt;
        glfw.GLFW_KEY_BACKSPACE     : PyCEGUI.Key.Backspace,&lt;br /&gt;
        glfw.GLFW_KEY_INSERT        : PyCEGUI.Key.Insert,&lt;br /&gt;
        glfw.GLFW_KEY_DELETE        : PyCEGUI.Key.Delete,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT         : PyCEGUI.Key.ArrowRight,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT          : PyCEGUI.Key.ArrowLeft,&lt;br /&gt;
        glfw.GLFW_KEY_DOWN          : PyCEGUI.Key.ArrowDown,&lt;br /&gt;
        glfw.GLFW_KEY_UP            : PyCEGUI.Key.ArrowUp,&lt;br /&gt;
        glfw.GLFW_KEY_PAGE_UP       : PyCEGUI.Key.PageUp,&lt;br /&gt;
        glfw.GLFW_KEY_PAGE_DOWN     : PyCEGUI.Key.PageDown,&lt;br /&gt;
        glfw.GLFW_KEY_HOME          : PyCEGUI.Key.Home,&lt;br /&gt;
        glfw.GLFW_KEY_END           : PyCEGUI.Key.End,&lt;br /&gt;
        glfw.GLFW_KEY_CAPS_LOCK     : PyCEGUI.Key.Capital,&lt;br /&gt;
        glfw.GLFW_KEY_SCROLL_LOCK   : PyCEGUI.Key.ScrollLock,&lt;br /&gt;
        glfw.GLFW_KEY_NUM_LOCK      : PyCEGUI.Key.NumLock,&lt;br /&gt;
        glfw.GLFW_KEY_PRINT_SCREEN  : PyCEGUI.Key.SysRq,&lt;br /&gt;
        glfw.GLFW_KEY_PAUSE         : PyCEGUI.Key.Pause,&lt;br /&gt;
        glfw.GLFW_KEY_F1            : PyCEGUI.Key.F1,&lt;br /&gt;
        glfw.GLFW_KEY_F2            : PyCEGUI.Key.F2,&lt;br /&gt;
        glfw.GLFW_KEY_F3            : PyCEGUI.Key.F3,&lt;br /&gt;
        glfw.GLFW_KEY_F4            : PyCEGUI.Key.F4,&lt;br /&gt;
        glfw.GLFW_KEY_F5            : PyCEGUI.Key.F5,&lt;br /&gt;
        glfw.GLFW_KEY_F6            : PyCEGUI.Key.F6,&lt;br /&gt;
        glfw.GLFW_KEY_F7            : PyCEGUI.Key.F7,&lt;br /&gt;
        glfw.GLFW_KEY_F8            : PyCEGUI.Key.F8,&lt;br /&gt;
        glfw.GLFW_KEY_F9            : PyCEGUI.Key.F9,&lt;br /&gt;
        glfw.GLFW_KEY_F10           : PyCEGUI.Key.F10,&lt;br /&gt;
        glfw.GLFW_KEY_F11           : PyCEGUI.Key.F11,&lt;br /&gt;
        glfw.GLFW_KEY_F12           : PyCEGUI.Key.F12,&lt;br /&gt;
        glfw.GLFW_KEY_F13           : PyCEGUI.Key.F13,&lt;br /&gt;
        glfw.GLFW_KEY_F14           : PyCEGUI.Key.F14,&lt;br /&gt;
        glfw.GLFW_KEY_F15           : PyCEGUI.Key.F15,&lt;br /&gt;
        glfw.GLFW_KEY_F16           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F17           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F18           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F19           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F20           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F21           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F22           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F23           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F24           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F25           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_KP_0          : PyCEGUI.Key.Numpad0,&lt;br /&gt;
        glfw.GLFW_KEY_KP_1          : PyCEGUI.Key.Numpad1,&lt;br /&gt;
        glfw.GLFW_KEY_KP_2          : PyCEGUI.Key.Numpad2,&lt;br /&gt;
        glfw.GLFW_KEY_KP_3          : PyCEGUI.Key.Numpad3,&lt;br /&gt;
        glfw.GLFW_KEY_KP_4          : PyCEGUI.Key.Numpad4,&lt;br /&gt;
        glfw.GLFW_KEY_KP_5          : PyCEGUI.Key.Numpad5,&lt;br /&gt;
        glfw.GLFW_KEY_KP_6          : PyCEGUI.Key.Numpad6,&lt;br /&gt;
        glfw.GLFW_KEY_KP_7          : PyCEGUI.Key.Numpad7,&lt;br /&gt;
        glfw.GLFW_KEY_KP_8          : PyCEGUI.Key.Numpad8,&lt;br /&gt;
        glfw.GLFW_KEY_KP_9          : PyCEGUI.Key.Numpad9,&lt;br /&gt;
        glfw.GLFW_KEY_KP_DECIMAL    : PyCEGUI.Key.Decimal,&lt;br /&gt;
        glfw.GLFW_KEY_KP_DIVIDE     : PyCEGUI.Key.Divide,&lt;br /&gt;
        glfw.GLFW_KEY_KP_MULTIPLY   : PyCEGUI.Key.Multiply,&lt;br /&gt;
        glfw.GLFW_KEY_KP_SUBTRACT   : PyCEGUI.Key.Subtract,&lt;br /&gt;
        glfw.GLFW_KEY_KP_ADD        : PyCEGUI.Key.Add,&lt;br /&gt;
        glfw.GLFW_KEY_KP_ENTER      : PyCEGUI.Key.NumpadEnter,&lt;br /&gt;
        glfw.GLFW_KEY_KP_EQUAL      : PyCEGUI.Key.NumpadEquals,     &lt;br /&gt;
        glfw.GLFW_KEY_LEFT_SHIFT    : PyCEGUI.Key.LeftShift,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_CONTROL  : PyCEGUI.Key.LeftControl,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_ALT      : PyCEGUI.Key.LeftAlt,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_SUPER    : PyCEGUI.Key.LeftWindows,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_SHIFT   : PyCEGUI.Key.RightShift,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_CONTROL : PyCEGUI.Key.RightControl,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_ALT     : PyCEGUI.Key.RightAlt,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_SUPER   : PyCEGUI.Key.RightWindows,&lt;br /&gt;
        glfw.GLFW_KEY_MENU          : PyCEGUI.Key.AppMenu,&lt;br /&gt;
        glfw.GLFW_KEY_LAST          : PyCEGUI.Key.AppMenu&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Initialization glf3==&lt;br /&gt;
&lt;br /&gt;
    # Initialize glfw&lt;br /&gt;
    if not glfw.glfwInit():&lt;br /&gt;
        print (&amp;quot; Error : glfw failed to initialize&amp;quot;)&lt;br /&gt;
        sys.exit (glfw.EXIT_FAILURE)&lt;br /&gt;
&lt;br /&gt;
== Window Hints==&lt;br /&gt;
&lt;br /&gt;
Glfw3 allows to define window hints prior to creation and hints about your OpenGL Context (OpenGL Version). Note the MAJOR/MINOR values are the minimum API version of the window context, i.e. if you graphics card supports GL 4.4 that is what will be returned.&lt;br /&gt;
&lt;br /&gt;
GLFW_OPENGL_FORWARD_COMPAT (True) indicates that functionality deprecated in the requested version of OpenGL is removed.&lt;br /&gt;
&lt;br /&gt;
For the sake of testing PyCEGUI's OpenGL render set: &lt;br /&gt;
  ceguiGL3Renderer(True)/ GLFW_OPENGL_FORWARD_COMPAT(True)   - OpenGL3Renderer without GL2.1&lt;br /&gt;
  ceguiGL3Renderer(True)/ GLFW_OPENGL_FORWARD_COMPAT(False)  - OpenGL3Renderer with    GL2.1&lt;br /&gt;
  ceguiGL3Renderer(False)                                    - OpenGLRenderer&lt;br /&gt;
 &lt;br /&gt;
    ceguiGL3Renderer = True&lt;br /&gt;
    if ceguiGL3Renderer:&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 2)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, PyGL.GL_TRUE)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)&lt;br /&gt;
    else:&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 2)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 1)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_ANY_PROFILE)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Window==&lt;br /&gt;
If you try to create a window with a context that you graphics card does not support glfwCreateWindow will fail. We&lt;br /&gt;
also need to make our context current prior to creating our PyCEGUI renderer.&lt;br /&gt;
&lt;br /&gt;
    glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, None, None)&lt;br /&gt;
    if not glfw_window:&lt;br /&gt;
        print (&amp;quot; Error : glfw failed to create a window&amp;quot;)&lt;br /&gt;
        glfw.glfwTerminate()&lt;br /&gt;
        sys.exit()&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwMakeContextCurrent(glfw_window)&lt;br /&gt;
&lt;br /&gt;
== VSnyc ==&lt;br /&gt;
This does nothing on linux and is dependent on your card settings. For example with a NVidia card change settings with NVidia X Server Settings-&amp;gt;OpenGL Settings-&amp;gt;Sync to VBlank.&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwSwapInterval(0)&lt;br /&gt;
&lt;br /&gt;
== Callbacks ==&lt;br /&gt;
See the source for each of the following callbacks where we notify CEGUI of display size changes, mouse presses/movement, key presses and glfwSetCharCallback is our callback to pass the unicode char/key pressed to CEGUI.&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwSetKeyCallback(             glfw_window,  self.on_key)&lt;br /&gt;
    glfw.glfwSetMouseButtonCallback(     glfw_window,  self.on_mouse)&lt;br /&gt;
    glfw.glfwSetCursorPosCallback(       glfw_window,  self.on_move)&lt;br /&gt;
    glfw.glfwSetWindowSizeCallback(      glfw_window,  self.on_resize)&lt;br /&gt;
    glfw.glfwSetCharCallback(            glfw_window,  self.on_char_callback)&lt;br /&gt;
    glfw.glfwSetFramebufferSizeCallback( glfw_window,  self.on_framebuffer_size_callback)&lt;br /&gt;
&lt;br /&gt;
== PyCEGUI Renderer ==&lt;br /&gt;
Create our PyCEGUI renderer.&lt;br /&gt;
&lt;br /&gt;
    if (not ceguiGL3Renderer):&lt;br /&gt;
        PyCEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()&lt;br /&gt;
    else :&lt;br /&gt;
        PyCEGUIOpenGLRenderer.OpenGL3Renderer.bootstrapSystem()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Main Loop ==&lt;br /&gt;
Our main loop runs until the glfw3 window is closed updating CEGUI, swapping the buffers and handling glfw events.&lt;br /&gt;
&lt;br /&gt;
    def updateCEGUI(self, elapsed):&lt;br /&gt;
        ##CEGUI updates ###&lt;br /&gt;
        if (PyCEGUI.System.getSingleton()):&lt;br /&gt;
            PyCEGUI.System.getSingleton().injectTimePulse(elapsed)&lt;br /&gt;
            PyCEGUI.System.getSingleton().renderAllGUIContexts()&lt;br /&gt;
            self.labelFPS.setText(&amp;quot;FPS : %s&amp;quot; %(str(int(1.0/elapsed))))&lt;br /&gt;
&lt;br /&gt;
    while not glfw.glfwWindowShouldClose(self.glfw_window):&lt;br /&gt;
        PyGL.glClear(PyGL.GL_COLOR_BUFFER_BIT)&lt;br /&gt;
        # update timing&lt;br /&gt;
        self.current_time = glfw.glfwGetTime()&lt;br /&gt;
        elapsed = self.current_time - self.previous_time&lt;br /&gt;
        self.previous_time = self.current_time&lt;br /&gt;
&lt;br /&gt;
        # update GL/CEGUI&lt;br /&gt;
        self.updateGL()&lt;br /&gt;
        self.updateCEGUI(elapsed)&lt;br /&gt;
&lt;br /&gt;
        # Swap front and back buffers&lt;br /&gt;
        glfw.glfwSwapBuffers(self.glfw_window)&lt;br /&gt;
&lt;br /&gt;
        # Handle glfw events&lt;br /&gt;
        glfw.glfwPollEvents()&lt;br /&gt;
&lt;br /&gt;
== Demo Source ==&lt;br /&gt;
&lt;br /&gt;
This is the full source code for the demo, see above saving the keyboard mappings.  &lt;br /&gt;
&lt;br /&gt;
     # -- coding: utf-8 --&lt;br /&gt;
&lt;br /&gt;
    import glfw&lt;br /&gt;
    import OpenGL.GL as PyGL&lt;br /&gt;
    import sys, os , site&lt;br /&gt;
&lt;br /&gt;
    ## set the path of your PyCEGUI* modules&lt;br /&gt;
    for _path in [os.path.join(s,'cegui-0.8') for s in site.getsitepackages()]:&lt;br /&gt;
        print _path&lt;br /&gt;
        sys.path.insert(0, _path)&lt;br /&gt;
    sys.path.insert(0, &amp;quot;/media/sdb5/python-ogre-cegui/cegui-0.8/lib&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ## set the path to our resource files&lt;br /&gt;
    CEGUI_PATH = &amp;quot;/media/sdb5/Libraries/OGRE/sdk/v1-9/share/cegui-0/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    ## import our PyCEGUI and out glfw3 to cegui key mappings&lt;br /&gt;
    import PyCEGUI&lt;br /&gt;
    import PyCEGUIOpenGLRenderer&lt;br /&gt;
    from keymappings_glfw3 import *&lt;br /&gt;
&lt;br /&gt;
    def ConvertMouseButton(button):&lt;br /&gt;
        ''' Convert Mouse Buttons to CEGUI '''&lt;br /&gt;
        if (button == glfw.GLFW_MOUSE_BUTTON_RIGHT):&lt;br /&gt;
            return PyCEGUI.RightButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_LEFT):&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_MIDDLE):&lt;br /&gt;
            return PyCEGUI.MiddleButton&lt;br /&gt;
        else:&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
&lt;br /&gt;
    class Application(object):&lt;br /&gt;
        def __init__(self):&lt;br /&gt;
&lt;br /&gt;
            # Initialize glfw&lt;br /&gt;
            if not glfw.glfwInit():&lt;br /&gt;
                print (&amp;quot; Error : glfw failed to initialize&amp;quot;)&lt;br /&gt;
                sys.exit (glfw.EXIT_FAILURE)&lt;br /&gt;
&lt;br /&gt;
            ceguiGL3Renderer = True&lt;br /&gt;
            if ceguiGL3Renderer:&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 2)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, PyGL.GL_TRUE)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)&lt;br /&gt;
            else:&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 2)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 1)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_ANY_PROFILE)&lt;br /&gt;
&lt;br /&gt;
            # our window hints&lt;br /&gt;
            ## http://www.glfw.org/docs/latest/window.html&lt;br /&gt;
            ## set our framebuffer related hints&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_DEPTH_BITS, 24)&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_STENCIL_BITS, 8)&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_FOCUSED, True)&lt;br /&gt;
&lt;br /&gt;
            fullScreen = False&lt;br /&gt;
            # create window&lt;br /&gt;
            if (not fullScreen):&lt;br /&gt;
                glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, None, None)&lt;br /&gt;
            else:&lt;br /&gt;
                glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, glfw.glfwGetPrimaryMonitor(), None)&lt;br /&gt;
&lt;br /&gt;
            # check window created&lt;br /&gt;
            if not glfw_window:&lt;br /&gt;
                print (&amp;quot; Error : glfw failed to create a window&amp;quot;)&lt;br /&gt;
                glfw.glfwTerminate()&lt;br /&gt;
                sys.exit()&lt;br /&gt;
            self.glfw_window = glfw_window&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwMakeContextCurrent(glfw_window)&lt;br /&gt;
&lt;br /&gt;
            self.showglfwInfo()&lt;br /&gt;
&lt;br /&gt;
            ## this does nothing on linux&lt;br /&gt;
            glfw.glfwSwapInterval(0)&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwSetInputMode(glfw_window, glfw.GLFW_CURSOR, glfw.GLFW_CURSOR_HIDDEN)&lt;br /&gt;
&lt;br /&gt;
            # call backs&lt;br /&gt;
            glfw.glfwSetKeyCallback(             glfw_window,  self.on_key)&lt;br /&gt;
            glfw.glfwSetMouseButtonCallback(     glfw_window,  self.on_mouse)&lt;br /&gt;
            glfw.glfwSetCursorPosCallback(       glfw_window,  self.on_move)&lt;br /&gt;
            glfw.glfwSetWindowSizeCallback(      glfw_window,  self.on_resize)&lt;br /&gt;
            glfw.glfwSetCharCallback(            glfw_window,  self.on_char_callback)&lt;br /&gt;
            glfw.glfwSetFramebufferSizeCallback( glfw_window,  self.on_framebuffer_size_callback)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            # initialise our CEGUI renderer&lt;br /&gt;
            ctx_major      = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            ctx_minor      = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MINOR)&lt;br /&gt;
            forward_compat = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_OPENGL_FORWARD_COMPAT)&lt;br /&gt;
&lt;br /&gt;
            if (not ceguiGL3Renderer):&lt;br /&gt;
                PyCEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()&lt;br /&gt;
            else :&lt;br /&gt;
                PyCEGUIOpenGLRenderer.OpenGL3Renderer.bootstrapSystem()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            # initialise PyCEGUI and resources&lt;br /&gt;
            rp = PyCEGUI.System.getSingleton().getResourceProvider()&lt;br /&gt;
         &lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;schemes&amp;quot;,    CEGUI_PATH + &amp;quot;schemes&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;imagesets&amp;quot;,  CEGUI_PATH + &amp;quot;imagesets&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;fonts&amp;quot;,      CEGUI_PATH + &amp;quot;fonts&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;layouts&amp;quot;,    CEGUI_PATH + &amp;quot;layouts&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;looknfeels&amp;quot;, CEGUI_PATH + &amp;quot;looknfeel&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;schemas&amp;quot;,    CEGUI_PATH + &amp;quot;xml_schemas&amp;quot;)&lt;br /&gt;
         &lt;br /&gt;
            PyCEGUI.ImageManager.setImagesetDefaultResourceGroup(&amp;quot;imagesets&amp;quot;)&lt;br /&gt;
            PyCEGUI.Font.setDefaultResourceGroup(&amp;quot;fonts&amp;quot;)&lt;br /&gt;
            PyCEGUI.Scheme.setDefaultResourceGroup(&amp;quot;schemes&amp;quot;)&lt;br /&gt;
            PyCEGUI.WidgetLookManager.setDefaultResourceGroup(&amp;quot;looknfeels&amp;quot;)&lt;br /&gt;
            PyCEGUI.WindowManager.setDefaultResourceGroup(&amp;quot;layouts&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            parser = PyCEGUI.System.getSingleton().getXMLParser()&lt;br /&gt;
            if parser.isPropertyPresent(&amp;quot;SchemaDefaultResourceGroup&amp;quot;):&lt;br /&gt;
                parser.setProperty(&amp;quot;SchemaDefaultResourceGroup&amp;quot;, &amp;quot;schemas&amp;quot;)     &lt;br /&gt;
&lt;br /&gt;
            # Load schemes&lt;br /&gt;
            PyCEGUI.SchemeManager.getSingleton().createFromFile(&amp;quot;TaharezLook.scheme&amp;quot;)&lt;br /&gt;
            PyCEGUI.SchemeManager.getSingleton().createFromFile(&amp;quot;WindowsLook.scheme&amp;quot;)&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage(&amp;quot;TaharezLook/MouseArrow&amp;quot;)&lt;br /&gt;
         &lt;br /&gt;
            # set root window&lt;br /&gt;
            root = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;DefaultWindow&amp;quot;, &amp;quot;background_wnd&amp;quot;);&lt;br /&gt;
            root.setArea( PyCEGUI.UVector2(PyCEGUI.UDim(0.0, 0),PyCEGUI.UDim(0.0, 0)) ,PyCEGUI.USize(PyCEGUI.UDim(1.0, 0),PyCEGUI.UDim(1.0, 0)))&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().setRootWindow(root)&lt;br /&gt;
&lt;br /&gt;
            # load a layout&lt;br /&gt;
            layout = PyCEGUI.WindowManager.getSingleton().loadLayoutFromFile(&amp;quot;TextDemo.layout&amp;quot;)&lt;br /&gt;
            root.addChild(layout.getChild('TextDemo'))&lt;br /&gt;
            self.edit = root.getChild('TextDemo/MultiLineGroup/editMulti')&lt;br /&gt;
&lt;br /&gt;
            # create label for our FPS&lt;br /&gt;
            self.labelFPS = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;TaharezLook/Label&amp;quot;, &amp;quot;FPSLabel&amp;quot;)&lt;br /&gt;
            root.addChild(self.labelFPS)&lt;br /&gt;
&lt;br /&gt;
            # create hello button&lt;br /&gt;
            button = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;TaharezLook/Button&amp;quot;, &amp;quot;HelloButton&amp;quot;)&lt;br /&gt;
            button.setArea( PyCEGUI.UVector2(PyCEGUI.UDim(.50, 0),PyCEGUI.UDim(.92, 0)) ,PyCEGUI.USize(PyCEGUI.UDim(0.3, 0),PyCEGUI.UDim(0.05, 0)))&lt;br /&gt;
            button.setText(&amp;quot;Hello&amp;quot;)&lt;br /&gt;
            root.addChild(button)&lt;br /&gt;
            button.subscribeEvent(PyCEGUI.PushButton.EventClicked, self.OnbuttonClicked)&lt;br /&gt;
&lt;br /&gt;
            # init simple timing&lt;br /&gt;
            self.previous_time = glfw.glfwGetTime()&lt;br /&gt;
            self.current_time  = self.previous_time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        def showglfwInfo(self):&lt;br /&gt;
            ctx_major      = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            ctx_minor      = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_CONTEXT_VERSION_MINOR)&lt;br /&gt;
            forward_compat = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_OPENGL_FORWARD_COMPAT)&lt;br /&gt;
            print &amp;quot;Created Window for OpenGL version %d.%d &amp;quot; % ( ctx_major, ctx_major )&lt;br /&gt;
            if ( ctx_major &amp;gt;=3 and forward_compat):&lt;br /&gt;
                print &amp;quot;Context is forward compatible, you can't use OpenGL 2.x commands&amp;quot; &lt;br /&gt;
            fwidth,fheight = glfw.glfwGetFramebufferSize(self.glfw_window)&lt;br /&gt;
            width, height =  glfw.glfwGetWindowSize(self.glfw_window)&lt;br /&gt;
     &lt;br /&gt;
            print &amp;quot;Framebuffer size %dx%d Window size %dx%d &amp;quot; % (fwidth,fheight, width,height) &lt;br /&gt;
&lt;br /&gt;
        def OnbuttonClicked(self, args):&lt;br /&gt;
            self.edit.setText(self.edit.getText() + &amp;quot;You Clicked&amp;quot;)&lt;br /&gt;
            return&lt;br /&gt;
&lt;br /&gt;
        def cleanUp(self):&lt;br /&gt;
            ''' shutdown glfw and CEGUI '''&lt;br /&gt;
            PyCEGUIOpenGLRenderer.OpenGLRenderer.destroySystem()&lt;br /&gt;
            glfw.glfwTerminate()&lt;br /&gt;
&lt;br /&gt;
        def updateGL(self):&lt;br /&gt;
            ''' glfw GL updates '''&lt;br /&gt;
            pass&lt;br /&gt;
        &lt;br /&gt;
        def updateCEGUI(self, elapsed):&lt;br /&gt;
            ''' CEGUI updates '''&lt;br /&gt;
            #focused = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
&lt;br /&gt;
            if (PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().injectTimePulse(elapsed)&lt;br /&gt;
                PyCEGUI.System.getSingleton().renderAllGUIContexts()&lt;br /&gt;
                self.labelFPS.setText(&amp;quot;FPS : %s&amp;quot; %(str(int(1.0/elapsed))))&lt;br /&gt;
&lt;br /&gt;
        def mainLoop(self):&lt;br /&gt;
            ''' Loop until glfw window is closed '''&lt;br /&gt;
&lt;br /&gt;
            while not glfw.glfwWindowShouldClose(self.glfw_window):&lt;br /&gt;
&lt;br /&gt;
                PyGL.glClear(PyGL.GL_COLOR_BUFFER_BIT)&lt;br /&gt;
&lt;br /&gt;
                # update timing&lt;br /&gt;
                self.current_time = glfw.glfwGetTime()&lt;br /&gt;
                elapsed = self.current_time - self.previous_time&lt;br /&gt;
                self.previous_time = self.current_time&lt;br /&gt;
&lt;br /&gt;
                # update GL/CEGUI&lt;br /&gt;
                self.updateGL()&lt;br /&gt;
                self.updateCEGUI(elapsed)&lt;br /&gt;
&lt;br /&gt;
                # Swap front and back buffers&lt;br /&gt;
                glfw.glfwSwapBuffers(self.glfw_window)&lt;br /&gt;
&lt;br /&gt;
                # Handle glfw events&lt;br /&gt;
                glfw.glfwPollEvents()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        def on_framebuffer_size_callback(self,window,width,height):&lt;br /&gt;
            ''' the framebuffer on high-DPI monitors may differ from the screen co-ords, so notify display size change here '''&lt;br /&gt;
            PyGL.glViewport(0, 0, width, height)&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().notifyDisplaySizeChanged(PyCEGUI.Sizef(float(width), float(height) ))&lt;br /&gt;
&lt;br /&gt;
        def on_move(self, window, x,y):&lt;br /&gt;
            ''' pass glfw mouse moves to CEGUI '''&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().getDefaultGUIContext().injectMousePosition(x, y)&lt;br /&gt;
&lt;br /&gt;
        def on_resize(self, window, width,height):&lt;br /&gt;
            ''' resize glfw viewport and CEGUI display '''&lt;br /&gt;
            PyGL.glViewport(0, 0, width, height)&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().notifyDisplaySizeChanged(PyCEGUI.Sizef(float(width), float(height) ))&lt;br /&gt;
&lt;br /&gt;
        def on_mouse(self, window, button, action, mods):&lt;br /&gt;
            ''' pass glfw mouse press events to CEGUI '''&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                context = PyCEGUI.System.getSingleton().getDefaultGUIContext()&lt;br /&gt;
                if (action == glfw.GLFW_PRESS):&lt;br /&gt;
                    context.injectMouseButtonDown( ConvertMouseButton(button) )&lt;br /&gt;
                if (action == glfw.GLFW_RELEASE):&lt;br /&gt;
                    context.injectMouseButtonUp( ConvertMouseButton(button) )&lt;br /&gt;
&lt;br /&gt;
        def on_char_callback(self, window, code):&lt;br /&gt;
            ''' Unicode character callback function to CEGUI '''&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().injectChar(code)&lt;br /&gt;
&lt;br /&gt;
        def on_key(self, window, key, scancode, action, mods):&lt;br /&gt;
            ''' pass keypress events to CEGUI '''&lt;br /&gt;
            if PyCEGUI.System.getSingleton():&lt;br /&gt;
                cegui_key = KEYMAPPINGS[key]&lt;br /&gt;
                if (not cegui_key==PyCEGUI.Key.Unknown):&lt;br /&gt;
                    if (action == glfw.GLFW_PRESS):&lt;br /&gt;
                        PyCEGUI.System.getSingleton().getDefaultGUIContext().injectKeyDown(PyCEGUI.Key.Scan(cegui_key))&lt;br /&gt;
                    if (action == glfw.GLFW_RELEASE):&lt;br /&gt;
                        PyCEGUI.System.getSingleton().getDefaultGUIContext().injectKeyUp(PyCEGUI.Key.Scan(cegui_key))&lt;br /&gt;
&lt;br /&gt;
            ## exit&lt;br /&gt;
            if key == glfw.GLFW_KEY_ESCAPE and action == glfw.GLFW_PRESS:&lt;br /&gt;
                glfw.glfwSetWindowShouldClose(window,1)&lt;br /&gt;
    if __name__ == '__main__':&lt;br /&gt;
        app = Application()&lt;br /&gt;
        app.mainLoop()&lt;br /&gt;
        app.cleanUp()&lt;br /&gt;
        del app&lt;br /&gt;
&lt;br /&gt;
And here is the link for the formatted [http://pastebin.com/d8RyqvSg source]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Dermont</name></author>	</entry>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Using_PyCEGUI_with_glfw3_and_PyOpenGL_(0.8)&amp;diff=5644</id>
		<title>Using PyCEGUI with glfw3 and PyOpenGL (0.8)</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Using_PyCEGUI_with_glfw3_and_PyOpenGL_(0.8)&amp;diff=5644"/>
				<updated>2015-03-27T12:56:32Z</updated>
		
		<summary type="html">&lt;p&gt;Dermont: An example of using PyCEGUI with glfw3&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{VersionBadge|0.8}}&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
For this example it is assumed that  [http://www.glfw.org/download.html glfw3] and [http://www.opengl.org OpenGL] are already installed. &lt;br /&gt;
We will be using the bindings for [https://github.com/rougier/pyglfw.git python glfw3] from Nicolas P. Rougier. Download from git clone https://github.com/rougier/pyglfw.git and copy the file glfw.py to the directory you are running the demo from.&lt;br /&gt;
&lt;br /&gt;
== Importing Modules ==&lt;br /&gt;
If you have trouble importing the PyCEGUI libraries you can update your python path to point to the location of the modules. For Linux you can simply point to your CEGUI build_dir/lib.&lt;br /&gt;
&lt;br /&gt;
    for _path in [os.path.join(s,'cegui-0.8') for s in site.getsitepackages()]:&lt;br /&gt;
        print _path&lt;br /&gt;
        sys.path.insert(0, _path)&lt;br /&gt;
    #sys.path.insert(0, &amp;quot;/media/sdb5/python-ogre-cegui/cegui-0.8/lib&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Setting Data Path ==&lt;br /&gt;
Set your path to the CEGUI media dir.&lt;br /&gt;
&lt;br /&gt;
    CEGUI_PATH = &amp;quot;/media/sdb5/Libraries/OGRE/sdk/v1-9/share/cegui-0/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Mouse/KeyBoard Mappings==&lt;br /&gt;
&lt;br /&gt;
    def ConvertMouseButton(button):&lt;br /&gt;
        ##Convert Mouse Buttons to CEGUI&lt;br /&gt;
        if (button == glfw.GLFW_MOUSE_BUTTON_RIGHT):&lt;br /&gt;
            return PyCEGUI.RightButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_LEFT):&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_MIDDLE):&lt;br /&gt;
            return PyCEGUI.MiddleButton&lt;br /&gt;
        else:&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
&lt;br /&gt;
Copy the following keyboard mappings to keymappings_glfw3.py in same directory as the demo.&lt;br /&gt;
&lt;br /&gt;
import sys&lt;br /&gt;
    import glfw&lt;br /&gt;
    import PyCEGUI&lt;br /&gt;
&lt;br /&gt;
    ## our keyboard mappings&lt;br /&gt;
    KEYMAPPINGS = {&lt;br /&gt;
        glfw.GLFW_KEY_UNKNOWN       : PyCEGUI.Key.Unknown, &lt;br /&gt;
        glfw.GLFW_KEY_SPACE         : PyCEGUI.Key.Space,&lt;br /&gt;
        glfw.GLFW_KEY_APOSTROPHE    : PyCEGUI.Key.Apostrophe,&lt;br /&gt;
        glfw.GLFW_KEY_COMMA         : PyCEGUI.Key.Comma,&lt;br /&gt;
        glfw.GLFW_KEY_MINUS         : PyCEGUI.Key.Minus,&lt;br /&gt;
        glfw.GLFW_KEY_PERIOD        : PyCEGUI.Key.Period,&lt;br /&gt;
        glfw.GLFW_KEY_SLASH         : PyCEGUI.Key.Slash,&lt;br /&gt;
        glfw.GLFW_KEY_0             : PyCEGUI.Key.Zero,&lt;br /&gt;
        glfw.GLFW_KEY_1             : PyCEGUI.Key.One,&lt;br /&gt;
        glfw.GLFW_KEY_2             : PyCEGUI.Key.Two,&lt;br /&gt;
        glfw.GLFW_KEY_3             : PyCEGUI.Key.Three,&lt;br /&gt;
        glfw.GLFW_KEY_4             : PyCEGUI.Key.Four,&lt;br /&gt;
        glfw.GLFW_KEY_5             : PyCEGUI.Key.Five,&lt;br /&gt;
        glfw.GLFW_KEY_6             : PyCEGUI.Key.Six,&lt;br /&gt;
        glfw.GLFW_KEY_7             : PyCEGUI.Key.Seven,&lt;br /&gt;
        glfw.GLFW_KEY_8             : PyCEGUI.Key.Eight,&lt;br /&gt;
        glfw.GLFW_KEY_9             : PyCEGUI.Key.Nine,&lt;br /&gt;
        glfw.GLFW_KEY_SEMICOLON     : PyCEGUI.Key.Semicolon,&lt;br /&gt;
        glfw.GLFW_KEY_EQUAL         : PyCEGUI.Key.Equals,&lt;br /&gt;
        glfw.GLFW_KEY_A             : PyCEGUI.Key.A,&lt;br /&gt;
        glfw.GLFW_KEY_B             : PyCEGUI.Key.B,&lt;br /&gt;
        glfw.GLFW_KEY_C             : PyCEGUI.Key.C,&lt;br /&gt;
        glfw.GLFW_KEY_D             : PyCEGUI.Key.D,&lt;br /&gt;
        glfw.GLFW_KEY_E             : PyCEGUI.Key.E,&lt;br /&gt;
        glfw.GLFW_KEY_F             : PyCEGUI.Key.F,&lt;br /&gt;
        glfw.GLFW_KEY_G             : PyCEGUI.Key.G,&lt;br /&gt;
        glfw.GLFW_KEY_H             : PyCEGUI.Key.H,&lt;br /&gt;
        glfw.GLFW_KEY_I             : PyCEGUI.Key.I,&lt;br /&gt;
        glfw.GLFW_KEY_J             : PyCEGUI.Key.J,&lt;br /&gt;
        glfw.GLFW_KEY_K             : PyCEGUI.Key.K,&lt;br /&gt;
        glfw.GLFW_KEY_L             : PyCEGUI.Key.L,&lt;br /&gt;
        glfw.GLFW_KEY_M             : PyCEGUI.Key.M,&lt;br /&gt;
        glfw.GLFW_KEY_N             : PyCEGUI.Key.N,&lt;br /&gt;
        glfw.GLFW_KEY_O             : PyCEGUI.Key.O,&lt;br /&gt;
        glfw.GLFW_KEY_P             : PyCEGUI.Key.P,&lt;br /&gt;
        glfw.GLFW_KEY_Q             : PyCEGUI.Key.Q,&lt;br /&gt;
        glfw.GLFW_KEY_R             : PyCEGUI.Key.R,&lt;br /&gt;
        glfw.GLFW_KEY_S             : PyCEGUI.Key.S,&lt;br /&gt;
        glfw.GLFW_KEY_T             : PyCEGUI.Key.T,&lt;br /&gt;
        glfw.GLFW_KEY_U             : PyCEGUI.Key.U,&lt;br /&gt;
        glfw.GLFW_KEY_V             : PyCEGUI.Key.V,&lt;br /&gt;
        glfw.GLFW_KEY_W             : PyCEGUI.Key.W,&lt;br /&gt;
        glfw.GLFW_KEY_X             : PyCEGUI.Key.X,&lt;br /&gt;
        glfw.GLFW_KEY_Y             : PyCEGUI.Key.Y,&lt;br /&gt;
        glfw.GLFW_KEY_Z             : PyCEGUI.Key.Z,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_BRACKET  : PyCEGUI.Key.LeftBracket,&lt;br /&gt;
        glfw.GLFW_KEY_BACKSLASH     : PyCEGUI.Key.Backslash,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_BRACKET : PyCEGUI.Key.RightBracket,&lt;br /&gt;
        glfw.GLFW_KEY_GRAVE_ACCENT  : PyCEGUI.Key.Grave,&lt;br /&gt;
        glfw.GLFW_KEY_WORLD_1       : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_WORLD_2       : PyCEGUI.Key.Unknown,&lt;br /&gt;
&lt;br /&gt;
        glfw.GLFW_KEY_ESCAPE        : PyCEGUI.Key.Escape,&lt;br /&gt;
        glfw.GLFW_KEY_ENTER         : PyCEGUI.Key.Return,&lt;br /&gt;
        glfw.GLFW_KEY_TAB           : PyCEGUI.Key.Tab,&lt;br /&gt;
        glfw.GLFW_KEY_BACKSPACE     : PyCEGUI.Key.Backspace,&lt;br /&gt;
        glfw.GLFW_KEY_INSERT        : PyCEGUI.Key.Insert,&lt;br /&gt;
        glfw.GLFW_KEY_DELETE        : PyCEGUI.Key.Delete,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT         : PyCEGUI.Key.ArrowRight,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT          : PyCEGUI.Key.ArrowLeft,&lt;br /&gt;
        glfw.GLFW_KEY_DOWN          : PyCEGUI.Key.ArrowDown,&lt;br /&gt;
        glfw.GLFW_KEY_UP            : PyCEGUI.Key.ArrowUp,&lt;br /&gt;
        glfw.GLFW_KEY_PAGE_UP       : PyCEGUI.Key.PageUp,&lt;br /&gt;
        glfw.GLFW_KEY_PAGE_DOWN     : PyCEGUI.Key.PageDown,&lt;br /&gt;
        glfw.GLFW_KEY_HOME          : PyCEGUI.Key.Home,&lt;br /&gt;
        glfw.GLFW_KEY_END           : PyCEGUI.Key.End,&lt;br /&gt;
        glfw.GLFW_KEY_CAPS_LOCK     : PyCEGUI.Key.Capital,&lt;br /&gt;
        glfw.GLFW_KEY_SCROLL_LOCK   : PyCEGUI.Key.ScrollLock,&lt;br /&gt;
        glfw.GLFW_KEY_NUM_LOCK      : PyCEGUI.Key.NumLock,&lt;br /&gt;
        glfw.GLFW_KEY_PRINT_SCREEN  : PyCEGUI.Key.SysRq,&lt;br /&gt;
        glfw.GLFW_KEY_PAUSE         : PyCEGUI.Key.Pause,&lt;br /&gt;
        glfw.GLFW_KEY_F1            : PyCEGUI.Key.F1,&lt;br /&gt;
        glfw.GLFW_KEY_F2            : PyCEGUI.Key.F2,&lt;br /&gt;
        glfw.GLFW_KEY_F3            : PyCEGUI.Key.F3,&lt;br /&gt;
        glfw.GLFW_KEY_F4            : PyCEGUI.Key.F4,&lt;br /&gt;
        glfw.GLFW_KEY_F5            : PyCEGUI.Key.F5,&lt;br /&gt;
        glfw.GLFW_KEY_F6            : PyCEGUI.Key.F6,&lt;br /&gt;
        glfw.GLFW_KEY_F7            : PyCEGUI.Key.F7,&lt;br /&gt;
        glfw.GLFW_KEY_F8            : PyCEGUI.Key.F8,&lt;br /&gt;
        glfw.GLFW_KEY_F9            : PyCEGUI.Key.F9,&lt;br /&gt;
        glfw.GLFW_KEY_F10           : PyCEGUI.Key.F10,&lt;br /&gt;
        glfw.GLFW_KEY_F11           : PyCEGUI.Key.F11,&lt;br /&gt;
        glfw.GLFW_KEY_F12           : PyCEGUI.Key.F12,&lt;br /&gt;
        glfw.GLFW_KEY_F13           : PyCEGUI.Key.F13,&lt;br /&gt;
        glfw.GLFW_KEY_F14           : PyCEGUI.Key.F14,&lt;br /&gt;
        glfw.GLFW_KEY_F15           : PyCEGUI.Key.F15,&lt;br /&gt;
        glfw.GLFW_KEY_F16           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F17           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F18           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F19           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F20           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F21           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F22           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F23           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F24           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_F25           : PyCEGUI.Key.Unknown,&lt;br /&gt;
        glfw.GLFW_KEY_KP_0          : PyCEGUI.Key.Numpad0,&lt;br /&gt;
        glfw.GLFW_KEY_KP_1          : PyCEGUI.Key.Numpad1,&lt;br /&gt;
        glfw.GLFW_KEY_KP_2          : PyCEGUI.Key.Numpad2,&lt;br /&gt;
        glfw.GLFW_KEY_KP_3          : PyCEGUI.Key.Numpad3,&lt;br /&gt;
        glfw.GLFW_KEY_KP_4          : PyCEGUI.Key.Numpad4,&lt;br /&gt;
        glfw.GLFW_KEY_KP_5          : PyCEGUI.Key.Numpad5,&lt;br /&gt;
        glfw.GLFW_KEY_KP_6          : PyCEGUI.Key.Numpad6,&lt;br /&gt;
        glfw.GLFW_KEY_KP_7          : PyCEGUI.Key.Numpad7,&lt;br /&gt;
        glfw.GLFW_KEY_KP_8          : PyCEGUI.Key.Numpad8,&lt;br /&gt;
        glfw.GLFW_KEY_KP_9          : PyCEGUI.Key.Numpad9,&lt;br /&gt;
        glfw.GLFW_KEY_KP_DECIMAL    : PyCEGUI.Key.Decimal,&lt;br /&gt;
        glfw.GLFW_KEY_KP_DIVIDE     : PyCEGUI.Key.Divide,&lt;br /&gt;
        glfw.GLFW_KEY_KP_MULTIPLY   : PyCEGUI.Key.Multiply,&lt;br /&gt;
        glfw.GLFW_KEY_KP_SUBTRACT   : PyCEGUI.Key.Subtract,&lt;br /&gt;
        glfw.GLFW_KEY_KP_ADD        : PyCEGUI.Key.Add,&lt;br /&gt;
        glfw.GLFW_KEY_KP_ENTER      : PyCEGUI.Key.NumpadEnter,&lt;br /&gt;
        glfw.GLFW_KEY_KP_EQUAL      : PyCEGUI.Key.NumpadEquals,     &lt;br /&gt;
        glfw.GLFW_KEY_LEFT_SHIFT    : PyCEGUI.Key.LeftShift,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_CONTROL  : PyCEGUI.Key.LeftControl,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_ALT      : PyCEGUI.Key.LeftAlt,&lt;br /&gt;
        glfw.GLFW_KEY_LEFT_SUPER    : PyCEGUI.Key.LeftWindows,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_SHIFT   : PyCEGUI.Key.RightShift,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_CONTROL : PyCEGUI.Key.RightControl,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_ALT     : PyCEGUI.Key.RightAlt,&lt;br /&gt;
        glfw.GLFW_KEY_RIGHT_SUPER   : PyCEGUI.Key.RightWindows,&lt;br /&gt;
        glfw.GLFW_KEY_MENU          : PyCEGUI.Key.AppMenu,&lt;br /&gt;
        glfw.GLFW_KEY_LAST          : PyCEGUI.Key.AppMenu&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Initialization glf3==&lt;br /&gt;
&lt;br /&gt;
    # Initialize glfw&lt;br /&gt;
    if not glfw.glfwInit():&lt;br /&gt;
        print (&amp;quot; Error : glfw failed to initialize&amp;quot;)&lt;br /&gt;
        sys.exit (glfw.EXIT_FAILURE)&lt;br /&gt;
&lt;br /&gt;
== Window Hints==&lt;br /&gt;
&lt;br /&gt;
Glfw3 allows to define window hints prior to creation and hints about your OpenGL Context (OpenGL Version). Note the MAJOR/MINOR values are the minimum API version of the window context, i.e. if you graphics card supports GL 4.4 that is what will be returned.&lt;br /&gt;
&lt;br /&gt;
GLFW_OPENGL_FORWARD_COMPAT (True) indicates that functionality deprecated in the requested version of OpenGL is removed.&lt;br /&gt;
&lt;br /&gt;
For the sake of testing PyCEGUI's OpenGL render set: &lt;br /&gt;
  ceguiGL3Renderer(True)/ GLFW_OPENGL_FORWARD_COMPAT(True)   - OpenGL3Renderer without GL2.1&lt;br /&gt;
  ceguiGL3Renderer(True)/ GLFW_OPENGL_FORWARD_COMPAT(False)  - OpenGL3Renderer with    GL2.1&lt;br /&gt;
  ceguiGL3Renderer(False)                                    - OpenGLRenderer&lt;br /&gt;
 &lt;br /&gt;
    ceguiGL3Renderer = True&lt;br /&gt;
    if ceguiGL3Renderer:&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 2)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, PyGL.GL_TRUE)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)&lt;br /&gt;
    else:&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 2)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 1)&lt;br /&gt;
        glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_ANY_PROFILE)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Window==&lt;br /&gt;
If you try to create a window with a context that you graphics card does not support glfwCreateWindow will fail. We&lt;br /&gt;
also need to make our context current prior to creating our PyCEGUI renderer.&lt;br /&gt;
&lt;br /&gt;
    glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, None, None)&lt;br /&gt;
    if not glfw_window:&lt;br /&gt;
        print (&amp;quot; Error : glfw failed to create a window&amp;quot;)&lt;br /&gt;
        glfw.glfwTerminate()&lt;br /&gt;
        sys.exit()&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwMakeContextCurrent(glfw_window)&lt;br /&gt;
&lt;br /&gt;
== VSnyc ==&lt;br /&gt;
This does nothing on linux and is dependent on your card settings. For example with a NVidia card change settings with NVidia X Server Settings-&amp;gt;OpenGL Settings-&amp;gt;Sync to VBlank.&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwSwapInterval(0)&lt;br /&gt;
&lt;br /&gt;
== Callbacks ==&lt;br /&gt;
See the source for each of the following callbacks where we notify CEGUI of display size changes, mouse presses/movement, key presses and glfwSetCharCallback is our callback to pass the unicode char/key pressed to CEGUI.&lt;br /&gt;
&lt;br /&gt;
    glfw.glfwSetKeyCallback(             glfw_window,  self.on_key)&lt;br /&gt;
    glfw.glfwSetMouseButtonCallback(     glfw_window,  self.on_mouse)&lt;br /&gt;
    glfw.glfwSetCursorPosCallback(       glfw_window,  self.on_move)&lt;br /&gt;
    glfw.glfwSetWindowSizeCallback(      glfw_window,  self.on_resize)&lt;br /&gt;
    glfw.glfwSetCharCallback(            glfw_window,  self.on_char_callback)&lt;br /&gt;
    glfw.glfwSetFramebufferSizeCallback( glfw_window,  self.on_framebuffer_size_callback)&lt;br /&gt;
&lt;br /&gt;
== PyCEGUI Renderer ==&lt;br /&gt;
Create our PyCEGUI renderer.&lt;br /&gt;
&lt;br /&gt;
    if (not ceguiGL3Renderer):&lt;br /&gt;
        PyCEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()&lt;br /&gt;
    else :&lt;br /&gt;
        PyCEGUIOpenGLRenderer.OpenGL3Renderer.bootstrapSystem()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Main Loop ==&lt;br /&gt;
Our main loop runs until the glfw3 window is closed updating CEGUI, swapping the buffers and handling glfw events.&lt;br /&gt;
&lt;br /&gt;
    def updateCEGUI(self, elapsed):&lt;br /&gt;
        ##CEGUI updates ###&lt;br /&gt;
        if (PyCEGUI.System.getSingleton()):&lt;br /&gt;
            PyCEGUI.System.getSingleton().injectTimePulse(elapsed)&lt;br /&gt;
            PyCEGUI.System.getSingleton().renderAllGUIContexts()&lt;br /&gt;
            self.labelFPS.setText(&amp;quot;FPS : %s&amp;quot; %(str(int(1.0/elapsed))))&lt;br /&gt;
&lt;br /&gt;
    while not glfw.glfwWindowShouldClose(self.glfw_window):&lt;br /&gt;
        PyGL.glClear(PyGL.GL_COLOR_BUFFER_BIT)&lt;br /&gt;
        # update timing&lt;br /&gt;
        self.current_time = glfw.glfwGetTime()&lt;br /&gt;
        elapsed = self.current_time - self.previous_time&lt;br /&gt;
        self.previous_time = self.current_time&lt;br /&gt;
&lt;br /&gt;
        # update GL/CEGUI&lt;br /&gt;
        self.updateGL()&lt;br /&gt;
        self.updateCEGUI(elapsed)&lt;br /&gt;
&lt;br /&gt;
        # Swap front and back buffers&lt;br /&gt;
        glfw.glfwSwapBuffers(self.glfw_window)&lt;br /&gt;
&lt;br /&gt;
        # Handle glfw events&lt;br /&gt;
        glfw.glfwPollEvents()&lt;br /&gt;
&lt;br /&gt;
== Demo Source ==&lt;br /&gt;
&lt;br /&gt;
This is the full source code for the demo, see above saving the keyboard mappings.  &lt;br /&gt;
&lt;br /&gt;
     # -- coding: utf-8 --&lt;br /&gt;
&lt;br /&gt;
    import glfw&lt;br /&gt;
    import OpenGL.GL as PyGL&lt;br /&gt;
    import sys, os , site&lt;br /&gt;
&lt;br /&gt;
    ## set the path of your PyCEGUI* modules&lt;br /&gt;
    for _path in [os.path.join(s,'cegui-0.8') for s in site.getsitepackages()]:&lt;br /&gt;
        print _path&lt;br /&gt;
        sys.path.insert(0, _path)&lt;br /&gt;
    sys.path.insert(0, &amp;quot;/media/sdb5/python-ogre-cegui/cegui-0.8/lib&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ## set the path to our resource files&lt;br /&gt;
    CEGUI_PATH = &amp;quot;/media/sdb5/Libraries/OGRE/sdk/v1-9/share/cegui-0/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    ## import our PyCEGUI and out glfw3 to cegui key mappings&lt;br /&gt;
    import PyCEGUI&lt;br /&gt;
    import PyCEGUIOpenGLRenderer&lt;br /&gt;
    from keymappings_glfw3 import *&lt;br /&gt;
&lt;br /&gt;
    def ConvertMouseButton(button):&lt;br /&gt;
        ''' Convert Mouse Buttons to CEGUI '''&lt;br /&gt;
        if (button == glfw.GLFW_MOUSE_BUTTON_RIGHT):&lt;br /&gt;
            return PyCEGUI.RightButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_LEFT):&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
        elif (button == glfw.GLFW_MOUSE_BUTTON_MIDDLE):&lt;br /&gt;
            return PyCEGUI.MiddleButton&lt;br /&gt;
        else:&lt;br /&gt;
            return PyCEGUI.LeftButton&lt;br /&gt;
&lt;br /&gt;
    class Application(object):&lt;br /&gt;
        def __init__(self):&lt;br /&gt;
&lt;br /&gt;
            # Initialize glfw&lt;br /&gt;
            if not glfw.glfwInit():&lt;br /&gt;
                print (&amp;quot; Error : glfw failed to initialize&amp;quot;)&lt;br /&gt;
                sys.exit (glfw.EXIT_FAILURE)&lt;br /&gt;
&lt;br /&gt;
            ceguiGL3Renderer = True&lt;br /&gt;
            if ceguiGL3Renderer:&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 3)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 2)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_FORWARD_COMPAT, PyGL.GL_TRUE)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_CORE_PROFILE)&lt;br /&gt;
            else:&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MAJOR, 2)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_CONTEXT_VERSION_MINOR, 1)&lt;br /&gt;
                glfw.glfwWindowHint(glfw.GLFW_OPENGL_PROFILE, glfw.GLFW_OPENGL_ANY_PROFILE)&lt;br /&gt;
&lt;br /&gt;
            # our window hints&lt;br /&gt;
            ## http://www.glfw.org/docs/latest/window.html&lt;br /&gt;
            ## set our framebuffer related hints&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_DEPTH_BITS, 24)&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_STENCIL_BITS, 8)&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwWindowHint(glfw.GLFW_FOCUSED, True)&lt;br /&gt;
&lt;br /&gt;
            fullScreen = False&lt;br /&gt;
            # create window&lt;br /&gt;
            if (not fullScreen):&lt;br /&gt;
                glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, None, None)&lt;br /&gt;
            else:&lt;br /&gt;
                glfw_window = glfw.glfwCreateWindow(1024, 768, &amp;quot;PyCEGUI glfw3 Demo&amp;quot;, glfw.glfwGetPrimaryMonitor(), None)&lt;br /&gt;
&lt;br /&gt;
            # check window created&lt;br /&gt;
            if not glfw_window:&lt;br /&gt;
                print (&amp;quot; Error : glfw failed to create a window&amp;quot;)&lt;br /&gt;
                glfw.glfwTerminate()&lt;br /&gt;
                sys.exit()&lt;br /&gt;
            self.glfw_window = glfw_window&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwMakeContextCurrent(glfw_window)&lt;br /&gt;
&lt;br /&gt;
            self.showglfwInfo()&lt;br /&gt;
&lt;br /&gt;
            ## this does nothing on linux&lt;br /&gt;
            glfw.glfwSwapInterval(0)&lt;br /&gt;
&lt;br /&gt;
            glfw.glfwSetInputMode(glfw_window, glfw.GLFW_CURSOR, glfw.GLFW_CURSOR_HIDDEN)&lt;br /&gt;
&lt;br /&gt;
            # call backs&lt;br /&gt;
            glfw.glfwSetKeyCallback(             glfw_window,  self.on_key)&lt;br /&gt;
            glfw.glfwSetMouseButtonCallback(     glfw_window,  self.on_mouse)&lt;br /&gt;
            glfw.glfwSetCursorPosCallback(       glfw_window,  self.on_move)&lt;br /&gt;
            glfw.glfwSetWindowSizeCallback(      glfw_window,  self.on_resize)&lt;br /&gt;
            glfw.glfwSetCharCallback(            glfw_window,  self.on_char_callback)&lt;br /&gt;
            glfw.glfwSetFramebufferSizeCallback( glfw_window,  self.on_framebuffer_size_callback)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            # initialise our CEGUI renderer&lt;br /&gt;
            ctx_major      = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            ctx_minor      = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MINOR)&lt;br /&gt;
            forward_compat = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_OPENGL_FORWARD_COMPAT)&lt;br /&gt;
&lt;br /&gt;
            if (not ceguiGL3Renderer):&lt;br /&gt;
                PyCEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()&lt;br /&gt;
            else :&lt;br /&gt;
                PyCEGUIOpenGLRenderer.OpenGL3Renderer.bootstrapSystem()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            # initialise PyCEGUI and resources&lt;br /&gt;
            rp = PyCEGUI.System.getSingleton().getResourceProvider()&lt;br /&gt;
         &lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;schemes&amp;quot;,    CEGUI_PATH + &amp;quot;schemes&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;imagesets&amp;quot;,  CEGUI_PATH + &amp;quot;imagesets&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;fonts&amp;quot;,      CEGUI_PATH + &amp;quot;fonts&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;layouts&amp;quot;,    CEGUI_PATH + &amp;quot;layouts&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;looknfeels&amp;quot;, CEGUI_PATH + &amp;quot;looknfeel&amp;quot;)&lt;br /&gt;
            rp.setResourceGroupDirectory(&amp;quot;schemas&amp;quot;,    CEGUI_PATH + &amp;quot;xml_schemas&amp;quot;)&lt;br /&gt;
         &lt;br /&gt;
            PyCEGUI.ImageManager.setImagesetDefaultResourceGroup(&amp;quot;imagesets&amp;quot;)&lt;br /&gt;
            PyCEGUI.Font.setDefaultResourceGroup(&amp;quot;fonts&amp;quot;)&lt;br /&gt;
            PyCEGUI.Scheme.setDefaultResourceGroup(&amp;quot;schemes&amp;quot;)&lt;br /&gt;
            PyCEGUI.WidgetLookManager.setDefaultResourceGroup(&amp;quot;looknfeels&amp;quot;)&lt;br /&gt;
            PyCEGUI.WindowManager.setDefaultResourceGroup(&amp;quot;layouts&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            parser = PyCEGUI.System.getSingleton().getXMLParser()&lt;br /&gt;
            if parser.isPropertyPresent(&amp;quot;SchemaDefaultResourceGroup&amp;quot;):&lt;br /&gt;
                parser.setProperty(&amp;quot;SchemaDefaultResourceGroup&amp;quot;, &amp;quot;schemas&amp;quot;)     &lt;br /&gt;
&lt;br /&gt;
            # Load schemes&lt;br /&gt;
            PyCEGUI.SchemeManager.getSingleton().createFromFile(&amp;quot;TaharezLook.scheme&amp;quot;)&lt;br /&gt;
            PyCEGUI.SchemeManager.getSingleton().createFromFile(&amp;quot;WindowsLook.scheme&amp;quot;)&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage(&amp;quot;TaharezLook/MouseArrow&amp;quot;)&lt;br /&gt;
         &lt;br /&gt;
            # set root window&lt;br /&gt;
            root = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;DefaultWindow&amp;quot;, &amp;quot;background_wnd&amp;quot;);&lt;br /&gt;
            root.setArea( PyCEGUI.UVector2(PyCEGUI.UDim(0.0, 0),PyCEGUI.UDim(0.0, 0)) ,PyCEGUI.USize(PyCEGUI.UDim(1.0, 0),PyCEGUI.UDim(1.0, 0)))&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().setRootWindow(root)&lt;br /&gt;
&lt;br /&gt;
            # load a layout&lt;br /&gt;
            layout = PyCEGUI.WindowManager.getSingleton().loadLayoutFromFile(&amp;quot;TextDemo.layout&amp;quot;)&lt;br /&gt;
            root.addChild(layout.getChild('TextDemo'))&lt;br /&gt;
            self.edit = root.getChild('TextDemo/MultiLineGroup/editMulti')&lt;br /&gt;
&lt;br /&gt;
            # create label for our FPS&lt;br /&gt;
            self.labelFPS = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;TaharezLook/Label&amp;quot;, &amp;quot;FPSLabel&amp;quot;)&lt;br /&gt;
            root.addChild(self.labelFPS)&lt;br /&gt;
&lt;br /&gt;
            # create hello button&lt;br /&gt;
            button = PyCEGUI.WindowManager.getSingleton().createWindow(&amp;quot;TaharezLook/Button&amp;quot;, &amp;quot;HelloButton&amp;quot;)&lt;br /&gt;
            button.setArea( PyCEGUI.UVector2(PyCEGUI.UDim(.50, 0),PyCEGUI.UDim(.92, 0)) ,PyCEGUI.USize(PyCEGUI.UDim(0.3, 0),PyCEGUI.UDim(0.05, 0)))&lt;br /&gt;
            button.setText(&amp;quot;Hello&amp;quot;)&lt;br /&gt;
            root.addChild(button)&lt;br /&gt;
            button.subscribeEvent(PyCEGUI.PushButton.EventClicked, self.OnbuttonClicked)&lt;br /&gt;
&lt;br /&gt;
            # init simple timing&lt;br /&gt;
            self.previous_time = glfw.glfwGetTime()&lt;br /&gt;
            self.current_time  = self.previous_time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        def showglfwInfo(self):&lt;br /&gt;
            ctx_major      = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
            ctx_minor      = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_CONTEXT_VERSION_MINOR)&lt;br /&gt;
            forward_compat = glfw.glfwGetWindowAttrib(self.glfw_window, glfw.GLFW_OPENGL_FORWARD_COMPAT)&lt;br /&gt;
            print &amp;quot;Created Window for OpenGL version %d.%d &amp;quot; % ( ctx_major, ctx_major )&lt;br /&gt;
            if ( ctx_major &amp;gt;=3 and forward_compat):&lt;br /&gt;
                print &amp;quot;Context is forward compatible, you can't use OpenGL 2.x commands&amp;quot; &lt;br /&gt;
            fwidth,fheight = glfw.glfwGetFramebufferSize(self.glfw_window)&lt;br /&gt;
            width, height =  glfw.glfwGetWindowSize(self.glfw_window)&lt;br /&gt;
     &lt;br /&gt;
            print &amp;quot;Framebuffer size %dx%d Window size %dx%d &amp;quot; % (fwidth,fheight, width,height) &lt;br /&gt;
&lt;br /&gt;
        def OnbuttonClicked(self, args):&lt;br /&gt;
            self.edit.setText(self.edit.getText() + &amp;quot;You Clicked&amp;quot;)&lt;br /&gt;
            return&lt;br /&gt;
&lt;br /&gt;
        def cleanUp(self):&lt;br /&gt;
            ''' shutdown glfw and CEGUI '''&lt;br /&gt;
            PyCEGUIOpenGLRenderer.OpenGLRenderer.destroySystem()&lt;br /&gt;
            glfw.glfwTerminate()&lt;br /&gt;
&lt;br /&gt;
        def updateGL(self):&lt;br /&gt;
            ''' glfw GL updates '''&lt;br /&gt;
            pass&lt;br /&gt;
        &lt;br /&gt;
        def updateCEGUI(self, elapsed):&lt;br /&gt;
            ''' CEGUI updates '''&lt;br /&gt;
            #focused = glfw.glfwGetWindowAttrib(glfw_window, glfw.GLFW_CONTEXT_VERSION_MAJOR)&lt;br /&gt;
&lt;br /&gt;
            if (PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().injectTimePulse(elapsed)&lt;br /&gt;
                PyCEGUI.System.getSingleton().renderAllGUIContexts()&lt;br /&gt;
                self.labelFPS.setText(&amp;quot;FPS : %s&amp;quot; %(str(int(1.0/elapsed))))&lt;br /&gt;
&lt;br /&gt;
        def mainLoop(self):&lt;br /&gt;
            ''' Loop until glfw window is closed '''&lt;br /&gt;
&lt;br /&gt;
            while not glfw.glfwWindowShouldClose(self.glfw_window):&lt;br /&gt;
&lt;br /&gt;
                PyGL.glClear(PyGL.GL_COLOR_BUFFER_BIT)&lt;br /&gt;
&lt;br /&gt;
                # update timing&lt;br /&gt;
                self.current_time = glfw.glfwGetTime()&lt;br /&gt;
                elapsed = self.current_time - self.previous_time&lt;br /&gt;
                self.previous_time = self.current_time&lt;br /&gt;
&lt;br /&gt;
                # update GL/CEGUI&lt;br /&gt;
                self.updateGL()&lt;br /&gt;
                self.updateCEGUI(elapsed)&lt;br /&gt;
&lt;br /&gt;
                # Swap front and back buffers&lt;br /&gt;
                glfw.glfwSwapBuffers(self.glfw_window)&lt;br /&gt;
&lt;br /&gt;
                # Handle glfw events&lt;br /&gt;
                glfw.glfwPollEvents()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        def on_framebuffer_size_callback(self,window,width,height):&lt;br /&gt;
            ''' the framebuffer on high-DPI monitors may differ from the screen co-ords, so notify display size change here '''&lt;br /&gt;
            PyGL.glViewport(0, 0, width, height)&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().notifyDisplaySizeChanged(PyCEGUI.Sizef(float(width), float(height) ))&lt;br /&gt;
&lt;br /&gt;
        def on_move(self, window, x,y):&lt;br /&gt;
            ''' pass glfw mouse moves to CEGUI '''&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().getDefaultGUIContext().injectMousePosition(x, y)&lt;br /&gt;
&lt;br /&gt;
        def on_resize(self, window, width,height):&lt;br /&gt;
            ''' resize glfw viewport and CEGUI display '''&lt;br /&gt;
            PyGL.glViewport(0, 0, width, height)&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                PyCEGUI.System.getSingleton().notifyDisplaySizeChanged(PyCEGUI.Sizef(float(width), float(height) ))&lt;br /&gt;
&lt;br /&gt;
        def on_mouse(self, window, button, action, mods):&lt;br /&gt;
            ''' pass glfw mouse press events to CEGUI '''&lt;br /&gt;
            if ( PyCEGUI.System.getSingleton()):&lt;br /&gt;
                context = PyCEGUI.System.getSingleton().getDefaultGUIContext()&lt;br /&gt;
                if (action == glfw.GLFW_PRESS):&lt;br /&gt;
                    context.injectMouseButtonDown( ConvertMouseButton(button) )&lt;br /&gt;
                if (action == glfw.GLFW_RELEASE):&lt;br /&gt;
                    context.injectMouseButtonUp( ConvertMouseButton(button) )&lt;br /&gt;
&lt;br /&gt;
        def on_char_callback(self, window, code):&lt;br /&gt;
            ''' Unicode character callback function to CEGUI '''&lt;br /&gt;
            PyCEGUI.System.getSingleton().getDefaultGUIContext().injectChar(code)&lt;br /&gt;
&lt;br /&gt;
        def on_key(self, window, key, scancode, action, mods):&lt;br /&gt;
            ''' pass keypress events to CEGUI '''&lt;br /&gt;
            if PyCEGUI.System.getSingleton():&lt;br /&gt;
                cegui_key = KEYMAPPINGS[key]&lt;br /&gt;
                if (not cegui_key==PyCEGUI.Key.Unknown):&lt;br /&gt;
                    if (action == glfw.GLFW_PRESS):&lt;br /&gt;
                        PyCEGUI.System.getSingleton().getDefaultGUIContext().injectKeyDown(PyCEGUI.Key.Scan(cegui_key))&lt;br /&gt;
                    if (action == glfw.GLFW_RELEASE):&lt;br /&gt;
                        PyCEGUI.System.getSingleton().getDefaultGUIContext().injectKeyUp(PyCEGUI.Key.Scan(cegui_key))&lt;br /&gt;
&lt;br /&gt;
            ## exit&lt;br /&gt;
            if key == glfw.GLFW_KEY_ESCAPE and action == glfw.GLFW_PRESS:&lt;br /&gt;
                glfw.glfwSetWindowShouldClose(window,1)&lt;br /&gt;
    if __name__ == '__main__':&lt;br /&gt;
        app = Application()&lt;br /&gt;
        app.mainLoop()&lt;br /&gt;
        app.cleanUp()&lt;br /&gt;
        del app&lt;br /&gt;
&lt;br /&gt;
And here is the link for the formatted [http://pastebin.com/d8RyqvSg source]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Dermont</name></author>	</entry>

	</feed>