Page 1 of 1

Problem starting with CEGUI

Posted: Sat Mar 11, 2006 21:22
by kuri
first, hi !
and thanks for what seems to me to be the lib that will save me in my personnal project :)

But it is not very easy to start using it, and im getting problems starting my first test program :(

i tried to following code

Code: Select all

#include "CEGUI.h"
#include "renderers/OpenGLGUIRenderer/openglrenderer.h"
using namespace CEGUI;
main(int argc, char *argv[])
{
    CEGUI::OpenGLRenderer* myRenderer = new CEGUI::OpenGLRenderer(0);
    new CEGUI::System(myRenderer);
    //draw3DScene();
    CEGUI::System::getSingleton().renderGUI();

    WindowManager& wmgr = WindowManager::getSingleton();
    SchemeManager::getSingleton().loadScheme("VanillaSkin.scheme");
    Window* myRoot = wmgr.createWindow("DefaultWindow", "root");
    System::getSingleton().setGUISheet(myRoot);
    FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "testWindow");
    myRoot->addChildWindow(fWnd);
    fWnd->setPosition( Point( 0.25f, 0.25f ) );
    fWnd->setSize( Size( 0.5f, 0.5f ) );
    fWnd->setText( "Hello World!" );

return 0;
}


then i compile with :

Code: Select all

g++-4.0 -o main main.c -I/usr/include/CEGUI  -lCEGUIBase -lCEGUIOpenGLRenderer


and when i start it, i get an error :

Code: Select all

terminate called after throwing an instance of 'CEGUI::InvalidRequestException'
Abandon


If anybody can lighten me, it would be very appreciated :)

Posted: Sat Mar 11, 2006 22:45
by lindquist
You cannot just start out by creating the openglrenderer. The renderer doesnt create any OpenGL rendering context.

CEGUI is meant to be flexible, and thus you decide which windowing backend you want to use. Be it SDL, Win32, Qt etc...

After you have created your rendering context you can create the renderer and initialise the System.

But you must also handle the main loop yourself. injecting input, timp pulses etc + issue rendering.

You can look at the SDL+OpenGL+CEGUI "tutorial" in the wiki for pointers...

HTH

Posted: Sat Mar 11, 2006 22:52
by kuri
yes i did it, and i have the same problem, so here is the whole code that i now have :

Code: Select all

#include "CEGUI.h"
#include "renderers/OpenGLGUIRenderer/openglrenderer.h"
#include <time.h>

#include "SDL.h"
#include "SDL_image.h"
using namespace CEGUI;

void handle_mouse_down(Uint8 button)
   {
   switch ( button )
      {
      // handle real mouse buttons
      case SDL_BUTTON_LEFT:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
         break;
      case SDL_BUTTON_MIDDLE:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);
         break;
      case SDL_BUTTON_RIGHT:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);
         break;
      
      // handle the mouse wheel
      case SDL_BUTTON_WHEELDOWN:
         CEGUI::System::getSingleton().injectMouseWheelChange( -1 );
         break;
      case SDL_BUTTON_WHEELUP:
         CEGUI::System::getSingleton().injectMouseWheelChange( +1 );
         break;
      }
   }
   
   void handle_mouse_up(Uint8 button)
   {
   switch ( button )
      {
      case SDL_BUTTON_LEFT:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
         break;
      case SDL_BUTTON_MIDDLE:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);
         break;
      case SDL_BUTTON_RIGHT:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);
         break;
      }
   }
   
void inject_input(bool& must_quit)
{
  SDL_Event e;
 
  // go through all available events
  while (SDL_PollEvent(&e))
  {
    // we use a switch to determine the event type
    switch (e.type)
    {
      // mouse motion handler
      case SDL_MOUSEMOTION:
        // we inject the mouse position directly.
        CEGUI::System::getSingleton().injectMousePosition(
          static_cast<float>(e.motion.x),
          static_cast<float>(e.motion.y)
        );
        break;
   
    // mouse down handler
      case SDL_MOUSEBUTTONDOWN:
        // let a special function handle the mouse button down event
        handle_mouse_down(e.button.button);
        break;
   
      // mouse up handler
      case SDL_MOUSEBUTTONUP:
        // let a special function handle the mouse button up event
        handle_mouse_up(e.button.button);
        break;
   
   
      // key down
      case SDL_KEYDOWN:
        // to tell CEGUI that a key was pressed, we inject the scancode.
        CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);
       
        // as for the character it's a litte more complicated. we'll use for translated unicode value.
        // this is described in more detail below.
        if ((e.key.keysym.unicode & 0xFF80) == 0)
        {
          CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode & 0x7F);
        }
        break;
   
      // key up
      case SDL_KEYUP:
        // like before we inject the scancode directly.
        CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);
        break;
   
   
      // WM quit event occured
      case SDL_QUIT:
        must_quit = true;
        break;
   
    }
 
  }

}


   
   
   void inject_time_pulse(double& last_time_pulse)
{
   // get current "run-time" in seconds
   double t = 0.001*SDL_GetTicks();

   // inject the time that passed since the last call
   CEGUI::System::getSingleton().injectTimePulse( float(t-last_time_pulse) );

   // store the new time as the last time
   last_time_pulse = t;
}

void render_gui()
{
   // clear the colour buffer
   glClear( GL_COLOR_BUFFER_BIT );

   // render the GUI :)
   CEGUI::System::getSingleton().renderGUI();

   // Update the screen
   SDL_GL_SwapBuffers();
}


main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO)<0)
{
  fprintf(stderr, "Unable to initialise SDL: %s", SDL_GetError());
  exit(0);
}

if (SDL_SetVideoMode(800,600,0,SDL_OPENGL)==NULL)
{
  fprintf(stderr, "Unable to set OpenGL videomode: %s", SDL_GetError());
  SDL_Quit();
  exit(0);
}
glEnable(GL_CULL_FACE);
glDisable(GL_FOG);
glClearColor(0.0f,0.0f,0.0f,1.0f);
glViewport(0,0, 800,600);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 800.0/600.0, 0.1,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

CEGUI::OpenGLRenderer* renderer = new CEGUI::OpenGLRenderer(0,800,600);
new CEGUI::System(renderer);
SDL_ShowCursor(SDL_DISABLE);
SDL_EnableUNICODE(1);

  bool must_quit = false;
 
  // get "run-time" in seconds
  double last_time_pulse = 0.001*static_cast<double>(SDL_GetTicks());
  WindowManager& wmgr = WindowManager::getSingleton();
Window* myRoot = wmgr.createWindow("DefaultWindow", "root");
System::getSingleton().setGUISheet(myRoot);
FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "testWindow");
myRoot->addChildWindow(fWnd);
fWnd->setPosition( Point( 0.25f, 0.25f ) );
fWnd->setSize( Size( 0.5f, 0.5f ) );
fWnd->setText( "Hello World!" );
 
  while (!must_quit)
  {
    inject_input(must_quit);
    inject_time_pulse(last_time_pulse);
    render_gui();
}
return 0;
}


i still get same exception, now here is the CEGUI log :

Code: Select all

12/03/2006 00:49:20 (InfL1)   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
12/03/2006 00:49:20 (InfL1)   +                     Crazy Eddie's GUI System - Event log                    +
12/03/2006 00:49:20 (InfL1)   +                          (http://www.cegui.org.uk/)                         +
12/03/2006 00:49:20 (InfL1)   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

12/03/2006 00:49:20 (InfL1)   CEGUI::Logger singleton created.
12/03/2006 00:49:20 (InfL1)   ---- Begining CEGUI System initialisation ----
12/03/2006 00:49:20 (InfL1)   CEGUI::ImagesetManager singleton created
12/03/2006 00:49:20 (InfL1)   CEGUI::FontManager singleton created.
12/03/2006 00:49:20 (InfL1)   CEGUI::WindowFactoryManager singleton created
12/03/2006 00:49:20 (InfL1)   CEGUI::WindowManager singleton created
12/03/2006 00:49:20 (InfL1)   CEGUI::SchemeManager singleton created.
12/03/2006 00:49:20 (InfL1)   CEGUI::MouseCursor singleton created.
12/03/2006 00:49:20 (InfL1)   CEGUI::GlobalEventSet singleton created.
12/03/2006 00:49:20 (InfL1)   CEGUI::WidgetLookManager singleton created.
12/03/2006 00:49:20 (InfL1)   WindowFactory for 'DefaultWindow' windows added.
12/03/2006 00:49:20 (InfL1)   WindowFactory for 'DragContainer' windows added.
12/03/2006 00:49:20 (InfL1)   WindowFactory for 'ScrolledContainer' windows added.
12/03/2006 00:49:20 (InfL1)   Window type alias named 'DefaultGUISheet' added for window type 'DefaultWindow'.
12/03/2006 00:49:20 (InfL1)   CEGUI::System singleton created.
12/03/2006 00:49:20 (InfL1)   ---- CEGUI System initialisation completed ----
12/03/2006 00:49:20 (InfL1)   ---- Version 0.4.1 ----
12/03/2006 00:49:20 (InfL1)   ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based renderer module for CEGUI ----
12/03/2006 00:49:20 (InfL1)   ---- XML Parser module is: CEGUI::XercesParser - Official Xerces-C++ based parser module for CEGUI ----
12/03/2006 00:49:20 (InfL1)   ---- Scripting module is: None ----
12/03/2006 00:49:20 (Error)   Exception: WindowFactoryManager::getFactory - A WindowFactory object, an alias, or mapping for 'TaharezLook/FrameWindow' Window objects is not registered with the system.

Posted: Sat Mar 11, 2006 22:57
by lindquist
You're loading the vanilla scheme, but trying to use a taharez widget

[edit] you were in the first post. In the second post you're not loading a scheme at all [/edit]

Posted: Sat Mar 11, 2006 23:07
by kuri
OK, i begin to understand!
so i grabbed some files, edited them to fix the right path, but i still fall there :

Code: Select all

12/03/2006 01:04:04 (InfL1)   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
12/03/2006 01:04:04 (InfL1)   +                     Crazy Eddie's GUI System - Event log                    +
12/03/2006 01:04:04 (InfL1)   +                          (http://www.cegui.org.uk/)                         +
12/03/2006 01:04:04 (InfL1)   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

12/03/2006 01:04:04 (InfL1)   CEGUI::Logger singleton created.
12/03/2006 01:04:04 (InfL1)   ---- Begining CEGUI System initialisation ----
12/03/2006 01:04:04 (InfL1)   CEGUI::ImagesetManager singleton created
12/03/2006 01:04:04 (InfL1)   CEGUI::FontManager singleton created.
12/03/2006 01:04:04 (InfL1)   CEGUI::WindowFactoryManager singleton created
12/03/2006 01:04:04 (InfL1)   CEGUI::WindowManager singleton created
12/03/2006 01:04:04 (InfL1)   CEGUI::SchemeManager singleton created.
12/03/2006 01:04:04 (InfL1)   CEGUI::MouseCursor singleton created.
12/03/2006 01:04:04 (InfL1)   CEGUI::GlobalEventSet singleton created.
12/03/2006 01:04:04 (InfL1)   CEGUI::WidgetLookManager singleton created.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'DefaultWindow' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'DragContainer' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'ScrolledContainer' windows added.
12/03/2006 01:04:04 (InfL1)   Window type alias named 'DefaultGUISheet' added for window type 'DefaultWindow'.
12/03/2006 01:04:04 (InfL1)   CEGUI::System singleton created.
12/03/2006 01:04:04 (InfL1)   ---- CEGUI System initialisation completed ----
12/03/2006 01:04:04 (InfL1)   ---- Version 0.4.1 ----
12/03/2006 01:04:04 (InfL1)   ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based renderer module for CEGUI ----
12/03/2006 01:04:04 (InfL1)   ---- XML Parser module is: CEGUI::XercesParser - Official Xerces-C++ based parser module for CEGUI ----
12/03/2006 01:04:04 (InfL1)   ---- Scripting module is: None ----
12/03/2006 01:04:04 (InfL1)   Attempting to load Scheme from file 'VanillaSkin.scheme'.
12/03/2006 01:04:04 (InfL1)   XercesParser::initialiseSchema - Attempting to load schema from file 'GUIScheme.xsd'.
12/03/2006 01:04:04 (InfL1)   XercesParser::initialiseSchema - XML schema file 'GUIScheme.xsd' has been initialised.
12/03/2006 01:04:04 (InfL1)   Attempting to create an Imageset from the information specified in file 'Vanilla.imageset'.
12/03/2006 01:04:04 (InfL1)   XercesParser::initialiseSchema - Attempting to load schema from file 'Imageset.xsd'.
12/03/2006 01:04:04 (InfL1)   XercesParser::initialiseSchema - XML schema file 'Imageset.xsd' has been initialised.
12/03/2006 01:04:04 (InfL1)   XercesParser::initialiseSchema - Attempting to load schema from file 'Falagard.xsd'.
12/03/2006 01:04:04 (InfL1)   XercesParser::initialiseSchema - XML schema file 'Falagard.xsd' has been initialised.
12/03/2006 01:04:04 (InfL1)   ===== Falagard 'root' element: look and feel parsing begins =====
12/03/2006 01:04:04 (InfL1)   ===== Look and feel parsing completed =====
12/03/2006 01:04:04 (InfL1)   No window factories specified for module 'CEGUIFalagardBase' - adding all available factories...
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Button' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Checkbox' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/ComboDropList' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Combobox' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Editbox' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/FrameWindow' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/ListHeader' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/ListHeaderSegment' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Listbox' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Menubar' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/MenuItem' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/MultiColumnList' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/MultiLineEditbox' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/PopupMenu' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/ProgressBar' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/RadioButton' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/ScrollablePane' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Scrollbar' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Slider' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Spinner' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/StaticImage' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/StaticText' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/SystemButton' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/TabButton' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/TabControl' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/TabPane' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Thumb' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Titlebar' windows added.
12/03/2006 01:04:04 (InfL1)   WindowFactory for 'Falagard/Tooltip' windows added.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/Titlebar' using base type 'Falagard/Titlebar' and LookN'Feel 'Vanilla/Titlebar'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/Button' using base type 'Falagard/Button' and LookN'Feel 'Vanilla/Button'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/FrameWindow' using base type 'Falagard/FrameWindow' and LookN'Feel 'Vanilla/FrameWindow'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/Editbox' using base type 'Falagard/Editbox' and LookN'Feel 'Vanilla/Editbox'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/VerticalScrollbarThumb' using base type 'Falagard/Thumb' and LookN'Feel 'Vanilla/VerticalScrollbarThumb'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/VerticalScrollbar' using base type 'Falagard/Scrollbar' and LookN'Feel 'Vanilla/VerticalScrollbar'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/HorizontalScrollbarThumb' using base type 'Falagard/Thumb' and LookN'Feel 'Vanilla/HorizontalScrollbarThumb'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/HorizontalScrollbar' using base type 'Falagard/Scrollbar' and LookN'Feel 'Vanilla/HorizontalScrollbar'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/StaticImage' using base type 'Falagard/StaticImage' and LookN'Feel 'Vanilla/StaticImage'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/StaticText' using base type 'Falagard/StaticText' and LookN'Feel 'Vanilla/StaticText'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/Listbox' using base type 'Falagard/Listbox' and LookN'Feel 'Vanilla/Listbox'.
12/03/2006 01:04:04 (InfL1)   Creating falagard mapping for type 'Vanilla/MultiLineEditbox' using base type 'Falagard/MultiLineEditbox' and LookN'Feel 'Vanilla/MultiLineEditbox'.
12/03/2006 01:04:04 (Error)   Exception: WindowFactoryManager::getFactory - A WindowFactory object, an alias, or mapping for 'VanillaSkin/FrameWindow' Window objects is not registered with the system.



And now i dont know what more to do

Posted: Sat Mar 11, 2006 23:08
by kuri
i forgot to add the CEGUI code :

Code: Select all

WindowManager& wmgr = WindowManager::getSingleton();
 SchemeManager::getSingleton().loadScheme("VanillaSkin.scheme");
Window* myRoot = wmgr.createWindow("DefaultWindow", "root");
System::getSingleton().setGUISheet(myRoot);
FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow("VanillaSkin/FrameWindow", "testWindow");
myRoot->addChildWindow(fWnd);
fWnd->setPosition( Point( 0.25f, 0.25f ) );
fWnd->setSize( Size( 0.5f, 0.5f ) );
fWnd->setText( "Hello World!" );

Posted: Sat Mar 11, 2006 23:23
by kuri
ok the problem was here:
FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow("VanillaSkin/FrameWindow", "testWindow");

On the wiki its said VanillaSkin/FrameWindow, while its Vanilla/FrameWindow

it now works!

Posted: Sat Mar 11, 2006 23:55
by kuri
it works but i dont see the Hello World string :)

edit: ok i had to add the following:

Code: Select all

FontManager::getSingleton().createFont("Iconified-12.font");

Posted: Fri Jul 28, 2006 23:47
by Percy Camilo
Hello ths, this code works but i can't see the cursor, i'm in debian etch. Any suggestions ?

this is the same sample but with TaharezLookSkin.scheme:

Code: Select all

#include "CEGUI.h"
#include "renderers/OpenGLGUIRenderer/openglrenderer.h"
#include <time.h>

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
using namespace CEGUI;

void handle_mouse_down(Uint8 button)
   {
   switch ( button )
      {
      // handle real mouse buttons
      case SDL_BUTTON_LEFT:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
         break;
      case SDL_BUTTON_MIDDLE:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);
         break;
      case SDL_BUTTON_RIGHT:
         CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);
         break;
     
      // handle the mouse wheel
      case SDL_BUTTON_WHEELDOWN:
         CEGUI::System::getSingleton().injectMouseWheelChange( -1 );
         break;
      case SDL_BUTTON_WHEELUP:
         CEGUI::System::getSingleton().injectMouseWheelChange( +1 );
         break;
      }
   }
   
   void handle_mouse_up(Uint8 button)
   {
   switch ( button )
      {
      case SDL_BUTTON_LEFT:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
         break;
      case SDL_BUTTON_MIDDLE:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);
         break;
      case SDL_BUTTON_RIGHT:
         CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);
         break;
      }
   }
   
void inject_input(bool& must_quit)
{
  SDL_Event e;
 
  // go through all available events
  while (SDL_PollEvent(&e))
  {
    // we use a switch to determine the event type
    switch (e.type)
    {
      // mouse motion handler
      case SDL_MOUSEMOTION:
        // we inject the mouse position directly.
        CEGUI::System::getSingleton().injectMousePosition(
          static_cast<float>(e.motion.x),
          static_cast<float>(e.motion.y)
        );
        break;
   
    // mouse down handler
      case SDL_MOUSEBUTTONDOWN:
        // let a special function handle the mouse button down event
        handle_mouse_down(e.button.button);
        break;
   
      // mouse up handler
      case SDL_MOUSEBUTTONUP:
        // let a special function handle the mouse button up event
        handle_mouse_up(e.button.button);
        break;
   
   
      // key down
      case SDL_KEYDOWN:
        // to tell CEGUI that a key was pressed, we inject the scancode.
        CEGUI::System::getSingleton().injectKeyDown(e.key.keysym.scancode);
       
        // as for the character it's a litte more complicated. we'll use for translated unicode value.
        // this is described in more detail below.
        if ((e.key.keysym.unicode & 0xFF80) == 0)
        {
          CEGUI::System::getSingleton().injectChar(e.key.keysym.unicode & 0x7F);
        }
        break;
   
      // key up
      case SDL_KEYUP:
        // like before we inject the scancode directly.
        CEGUI::System::getSingleton().injectKeyUp(e.key.keysym.scancode);
        break;
   
   
      // WM quit event occured
      case SDL_QUIT:
        must_quit = true;
        break;
   
    }
 
  }

}


   
   
   void inject_time_pulse(double& last_time_pulse)
{
   // get current "run-time" in seconds
   double t = 0.001*SDL_GetTicks();

   // inject the time that passed since the last call
   CEGUI::System::getSingleton().injectTimePulse( float(t-last_time_pulse) );

   // store the new time as the last time
   last_time_pulse = t;
}

void render_gui()
{
   // clear the colour buffer
   glClear( GL_COLOR_BUFFER_BIT );

   // render the GUI :)
   CEGUI::System::getSingleton().renderGUI();

   // Update the screen
   SDL_GL_SwapBuffers();
}


main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO)<0)
{
  fprintf(stderr, "Unable to initialise SDL: %s", SDL_GetError());
  exit(0);
}

if (SDL_SetVideoMode(800,600,0,SDL_OPENGL)==NULL)
{
  fprintf(stderr, "Unable to set OpenGL videomode: %s", SDL_GetError());
  SDL_Quit();
  exit(0);
}
glEnable(GL_CULL_FACE);
glDisable(GL_FOG);
glClearColor(0.0f,0.0f,0.0f,1.0f);
glViewport(0,0, 800,600);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 800.0/600.0, 0.1,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

CEGUI::OpenGLRenderer* renderer = new CEGUI::OpenGLRenderer(0,800,600);
new CEGUI::System(renderer);
SDL_ShowCursor(SDL_DISABLE);
SDL_EnableUNICODE(1);

  bool must_quit = false;
 
  // get "run-time" in seconds
  double last_time_pulse = 0.001*static_cast<double>(SDL_GetTicks());

/*
WindowManager& wmgr = WindowManager::getSingleton();
Window* myRoot = wmgr.createWindow("DefaultWindow", "root");
System::getSingleton().setGUISheet(myRoot);
FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "testWindow");
myRoot->addChildWindow(fWnd);
fWnd->setPosition( Point( 0.25f, 0.25f ) );
fWnd->setSize( Size( 0.5f, 0.5f ) );
fWnd->setText( "Hello World!" );
*/

WindowManager& wmgr = WindowManager::getSingleton();
SchemeManager::getSingleton().loadScheme("../datafiles/schemes/TaharezLookSkin.scheme");
Window* myRoot = wmgr.createWindow("DefaultWindow", "root");
System::getSingleton().setGUISheet(myRoot);
//FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow("VanillaSkin/FrameWindow", "testWindow");
FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "testWindow");
FontManager::getSingleton().createFont("../datafiles/fonts/Iconified-12.font");
myRoot->addChildWindow(fWnd);
fWnd->setPosition( Point( 0.25f, 0.25f ) );
fWnd->setSize( Size( 0.5f, 0.5f ) );
fWnd->setText( "Hello World!" );



 
  while (!must_quit)
  {
    inject_input(must_quit);
    inject_time_pulse(last_time_pulse);
    render_gui();
}
return 0;
}


Link with:

Code: Select all

-lSDLmain -lSDL -lCEGUIBase -lCEGUIOpenGLRenderer


And put the folder "datafiles" on the top of your binary(or exe) folder:
PD: datafiles comes in the folder Samples with the source of CEGUI:
cegui_mk2-source-0.4.1.tar.bz2

And sorry my english i'am from PerĂº
:wink:

SOLVEDDD::

Change
new CEGUI::System(renderer);
with
CEGUI::System *mySystem = new CEGUI::System(renderer);
and you can add:
mySystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");

and ther is , now you have a nice cursor

bytes thx again