Compilation error on OgreEvenListeners.h

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jan 22, 2008 19:18

Hi :)

I may run a couple more tests in relation to this, thought I'll just waffle on here for a bit anyway :lol:

Due to some double-dependencies between Ogre and CEGUI, the usual sequence of things is this:

    Configure, build and install CEGUI
    Configure, build and install Ogre (this will detect you have CEGUI and build the Ogre CEGUI renderer module)
    Re-configure, build and install CEGUI (this will then detect the Ogre CEGUI renderer module and use it in the samples.


Now, from source it is Ogre and not CEGUI that installs the CEGUI-OGRE.pc file. But in the pre-packaged versions, this file comes with CEGUI and not Ogre - which is the first point where things can start to get hairy.

Another issue is that by default, the default local .pc file install path of "/usr/local/lib/pkgconfig" is not added to the environment variable PKG_CONFIG_PATH used by pkg-config - so if you have the pre-packaged CEGUI still installed, this will get picked up instead of the 'real' one you just installed via the source. This wrong version of the file basically points to the pre-built libs, so you'll end up with errors there too. So it's essential to remove the prebuilt version if you're going the source route. And add the appropriate dir to the search path used by pkg-config.

If you do go the source route for CEGUI then SVN code is recommended since it has almost the required fixes for OIS support required by newer Ogre versions (almost because depending on the OIS you have, there are still minor changes to make - see above posts).

Anyway, at least life is not dull :)

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jan 22, 2008 21:51

Ok, this post details my experiences with getting Ogre and CEGUI working on a machine running Kubuntu 7.1 (Gutsy Gibbon). I'd like to mention that this is not my 'usual' system - which is Gentoo Linux (amd64), and it's a system that's not normally used for development, though this post does not detail installing the build tools.

First of all i removed libogre-dev and libcegui-mk2-dev packages that I previously had installed via aptitude.

At this point I'd like to note that you'll probably already have most or all of the required libs already installed if you use your system for development, as mentioned I did not previously use this system for development, so that's why I mention the packages I installed.

I downloaded and unpacked the latest stables for Ogre and CEGUI, which are 1.4.6 and 0.5.0b respectively.

I installed the following packages that were either required to build CEGUI, or that I decided I'd like :)

Code: Select all

xorg-dev
libgl1-mesa-dev
libglu1-mesa-dev
libdevil-dev
libtiff-dev
libois-dev


Somewhere around this point I discovered a bug in the config scripts, so had to make the following change. This relates to the DevIL image loading lib, so if you've not got that installed, then you could skip this :)

Code: Select all

--- acinclude.m4        2006-10-25 11:54:43.000000000 +0100
+++ new_acinclude.m4    2008-01-22 21:42:06.000000000 +0000
@@ -293,7 +293,7 @@
             if test x$cegui_with_il_lib = xyes -a x$cegui_with_ilu_lib = xyes ; then
                 AC_MSG_NOTICE([Image loading via DevIL by OpenGL renderer enabled])
                 DevIL_CFLAGS="-DUSE_DEVIL_LIBRARY"
-                DevIL_LIBS="-LIL -lILU"
+                DevIL_LIBS="-lIL -lILU"
                 AC_SUBST(DevIL_CFLAGS)
                 AC_SUBST(DevIL_LIBS)
                 cegui_with_devil=yes


Now, we need to backport this release to support OIS. So for that you need the following patch. Note this patch was assembled by hand from stuff I got from the web svn for CEGUI. If you place it in ./dev/CEGUI-0.5.0/ you should appy it with the -p2 option.

Code: Select all

--- cegui_mk2/trunk/Samples/common/include/CEGuiOgreBaseApplication.h   2006/05/12 19:42:23   1125
+++ cegui_mk2/trunk/Samples/common/include/CEGuiOgreBaseApplication.h   2007/08/08 18:50:37   1480
@@ -33,7 +33,7 @@
 
 #include <OgreCEGUIRenderer.h>
 #include <Ogre.h>
-#include <OgreEventListeners.h>
+#include <OIS.h>
 
 #if defined(_WIN32)
 #  if defined(_DEBUG)
@@ -90,7 +90,7 @@
 \brief
     Ogre FrameListener class where we deal with input processing and the like.
 */
-class CEGuiDemoFrameListener: public Ogre::FrameListener, public Ogre::KeyListener, Ogre::MouseMotionListener, Ogre::MouseListener
+class CEGuiDemoFrameListener : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener
 {
 public:
     // Construction and Destruction
@@ -102,29 +102,23 @@
     bool frameEnded(const Ogre::FrameEvent& evt);
 
     // Raw input handlers that we care about
-    void mouseMoved(Ogre::MouseEvent *e);
-    void mouseDragged(Ogre::MouseEvent *e);
-    void keyPressed(Ogre::KeyEvent *e);
-    void keyReleased(Ogre::KeyEvent *e);
-    void mousePressed(Ogre::MouseEvent *e);
-    void mouseReleased(Ogre::MouseEvent *e);
-
-    // Raw input handlers that we do not care about
-    void keyClicked(Ogre::KeyEvent *e);
-    void mouseClicked(Ogre::MouseEvent *e);
-    void mouseEntered(Ogre::MouseEvent *e);
-    void mouseExited(Ogre::MouseEvent *e);
+    bool mouseMoved(const OIS::MouseEvent &e);
+    bool keyPressed(const OIS::KeyEvent &e);
+    bool keyReleased(const OIS::KeyEvent &e);
+    bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
+    bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);
 
 protected:
-    // convert an Ogre mouse button into a CEGUI mouse button
-    CEGUI::MouseButton convertOgreButtonToCegui(int ogre_button_id);
+    // convert an OIS mouse button into a CEGUI mouse button
+    CEGUI::MouseButton convertOISButtonToCegui(int buttonID);
 
     /*************************************************************************
         Data Fields
     *************************************************************************/
     Ogre::Overlay* d_statsOverlay;
-    Ogre::EventProcessor* d_eventProcessor;
-
+    OIS::InputManager* d_inputManager;
+    OIS::Keyboard* d_keyboard;
+    OIS::Mouse* d_mouse;
     Ogre::Camera* d_camera;
     Ogre::RenderWindow* d_window;
     bool d_quit;
--- cegui_mk2/trunk/Samples/common/src/CEGuiOgreBaseApplication.cpp   2006/10/20 13:29:12   1407
+++ cegui_mk2/trunk/Samples/common/src/CEGuiOgreBaseApplication.cpp   2007/08/08 18:50:37   1480
@@ -36,9 +36,6 @@
 #include "CEGuiOgreBaseApplication.h"
 #include "CEGuiSample.h"
 
-#include <OgreKeyEvent.h>
-
-
 CEGuiOgreBaseApplication::CEGuiOgreBaseApplication() :
         d_ogreRoot(0),
         d_renderer(0),
@@ -178,13 +175,42 @@
 ////////////////////////////////////////////////////////////////////////////////
 CEGuiDemoFrameListener::CEGuiDemoFrameListener(CEGuiBaseApplication* baseApp, Ogre::RenderWindow* window, Ogre::Camera* camera, bool useBufferedInputKeys, bool useBufferedInputMouse)
 {
-    // create and initialise events processor
-    d_eventProcessor = new Ogre::EventProcessor();
-    d_eventProcessor->initialise(window);
-    d_eventProcessor->addKeyListener(this);
-    d_eventProcessor->addMouseMotionListener(this);
-    d_eventProcessor->addMouseListener(this);
-    d_eventProcessor->startProcessingEvents();
+    // OIS setup
+    OIS::ParamList paramList;
+    size_t windowHnd = 0;
+    std::ostringstream windowHndStr;
+
+    // get window handle
+    window->getCustomAttribute("WINDOW", &windowHnd);
+   
+    // fill param list
+    windowHndStr << (unsigned int)windowHnd;
+    paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+
+    // create input system
+    d_inputManager = OIS::InputManager::createInputSystem(paramList);
+
+    // create buffered keyboard
+    if (d_inputManager->numKeyBoards() > 0)
+    {
+        d_keyboard = static_cast<OIS::Keyboard*>(d_inputManager->createInputObject(OIS::OISKeyboard, true));
+        d_keyboard->setEventCallback(this);
+    }
+
+    // create buffered mouse
+    if (d_inputManager->numMice() > 0)
+    {
+        d_mouse = static_cast<OIS::Mouse*>(d_inputManager->createInputObject(OIS::OISMouse, true));
+        d_mouse->setEventCallback(this);
+       
+        unsigned int width, height, depth;
+        int left, top;
+
+        window->getMetrics(width, height, depth, left, top);
+        const OIS::MouseState& mouseState = d_mouse->getMouseState();
+        mouseState.width = width;
+        mouseState.height = height;
+    }
 
     // store inputs we want to make use of
     d_camera = camera;
@@ -199,7 +225,13 @@
 
 CEGuiDemoFrameListener::~CEGuiDemoFrameListener()
 {
-    delete d_eventProcessor;
+    if (d_inputManager)
+    {
+        d_inputManager->destroyInputObject(d_mouse);
+        d_inputManager->destroyInputObject(d_keyboard);
+        OIS::InputManager::destroyInputSystem(d_inputManager);
+    }
+
 }
 
 bool CEGuiDemoFrameListener::frameStarted(const Ogre::FrameEvent& evt)
@@ -212,8 +244,16 @@
     {
         // always inject a time pulse to enable widget automation
         CEGUI::System::getSingleton().injectTimePulse(static_cast<float>(evt.timeSinceLastFrame));
+
+        // update input system
+        if (d_mouse)
+            d_mouse->capture();
+        if (d_keyboard)
+            d_keyboard->capture();
+
         return true;
     }
+   
 }
 
 bool CEGuiDemoFrameListener::frameEnded(const Ogre::FrameEvent& evt)
@@ -221,109 +261,83 @@
     return true;
 }
 
-void CEGuiDemoFrameListener::mouseMoved(Ogre::MouseEvent *e)
+bool CEGuiDemoFrameListener::mouseMoved(const OIS::MouseEvent &e)
 {
-    CEGUI::Renderer* rend = CEGUI::System::getSingleton().getRenderer();
-    CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * rend->getWidth(), e->getRelY() * rend->getHeight());
 
-    float wheel = e->getRelZ();
+    CEGUI::System& cegui = CEGUI::System::getSingleton();
 
-    if (wheel != 0)
-    {
-        CEGUI::System::getSingleton().injectMouseWheelChange(wheel * 10);
-    }
+    cegui.injectMouseMove(e.state.X.rel, e.state.Y.rel);
+    cegui.injectMouseWheelChange(e.state.Z.rel * 0.03);
 
-    e->consume();
+    return true;
 }
 
 
-void CEGuiDemoFrameListener::mouseDragged(Ogre::MouseEvent *e)
-{
-    mouseMoved(e);
-}
-
 
-void CEGuiDemoFrameListener::keyPressed(Ogre::KeyEvent *e)
+bool CEGuiDemoFrameListener::keyPressed(const OIS::KeyEvent &e)
 {
     // give 'quitting' priority
-    if (e->getKey() == Ogre::KC_ESCAPE)
+    if (e.key == OIS::KC_ESCAPE)
     {
         d_quit = true;
-        e->consume();
-        return;
+         return true;
     }
 
     // do event injection
     CEGUI::System& cegui = CEGUI::System::getSingleton();
 
     // key down
-    cegui.injectKeyDown(e->getKey());
+    cegui.injectKeyDown(e.key);
 
     // now character
-    cegui.injectChar(e->getKeyChar());
+    cegui.injectChar(e.text);
+
 
-    e->consume();
+    return true;
 }
 
 
-void CEGuiDemoFrameListener::keyReleased(Ogre::KeyEvent *e)
+bool CEGuiDemoFrameListener::keyReleased(const OIS::KeyEvent &e)
 {
-    CEGUI::System::getSingleton().injectKeyUp(e->getKey());
+    CEGUI::System::getSingleton().injectKeyUp(e.key);
+    return true;
 }
 
 
 
-void CEGuiDemoFrameListener::mousePressed(Ogre::MouseEvent *e)
+bool CEGuiDemoFrameListener::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
 {
-    CEGUI::System::getSingleton().injectMouseButtonDown(convertOgreButtonToCegui(e->getButtonID()));
-    e->consume();
-}
+    CEGUI::System::getSingleton().injectMouseButtonDown(convertOISButtonToCegui(id));
 
-
-void CEGuiDemoFrameListener::mouseReleased(Ogre::MouseEvent *e)
-{
-    CEGUI::System::getSingleton().injectMouseButtonUp(convertOgreButtonToCegui(e->getButtonID()));
-    e->consume();
+    return true;
 }
 
-void CEGuiDemoFrameListener::keyClicked(Ogre::KeyEvent *e)
-{}
 
-void CEGuiDemoFrameListener::mouseClicked(Ogre::MouseEvent *e)
-{}
-
-void CEGuiDemoFrameListener::mouseEntered(Ogre::MouseEvent *e)
-{}
+bool CEGuiDemoFrameListener::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+{
+    CEGUI::System::getSingleton().injectMouseButtonUp(convertOISButtonToCegui(id));
 
-void CEGuiDemoFrameListener::mouseExited(Ogre::MouseEvent *e)
-{}
+    return true;
+}
 
-CEGUI::MouseButton CEGuiDemoFrameListener::convertOgreButtonToCegui(int ogre_button_id)
+CEGUI::MouseButton CEGuiDemoFrameListener::convertOISButtonToCegui(int buttonID)
 {
-    switch (ogre_button_id)
+   using namespace OIS;
+
+   switch (buttonID)
     {
-    case Ogre::MouseEvent::BUTTON0_MASK:
+   case OIS::MB_Left:
         return CEGUI::LeftButton;
-        break;
-
-    case Ogre::MouseEvent::BUTTON1_MASK:
+   case OIS::MB_Right:
         return CEGUI::RightButton;
-        break;
-
-    case Ogre::MouseEvent::BUTTON2_MASK:
+   case OIS::MB_Middle:
         return CEGUI::MiddleButton;
-        break;
-
-    case Ogre::MouseEvent::BUTTON3_MASK:
-        return CEGUI::X1Button;
-        break;
-
     default:
         return CEGUI::LeftButton;
-        break;
     }
-
 }
 
 #endif
 
+
+
--- cegui_mk2/trunk/Samples/common/src/Makefile.am   2006/11/05 19:58:14   1448
+++ cegui_mk2/trunk/Samples/common/src/Makefile.am   2007/08/08 18:50:37   1480
@@ -17,9 +17,9 @@
     libCEGUISampleHelper_la_SOURCES += GTK2CEGuiRendererSelector.cpp
 endif
 if CEGUI_SAMPLES_USE_OGRE
-    INCLUDES += $(CEGUIOGRE_CFLAGS)
+    INCLUDES += $(CEGUIOGRE_CFLAGS) $(OIS_CFLAGS)
     libCEGUISampleHelper_la_SOURCES += CEGuiOgreBaseApplication.cpp
-    libCEGUISampleHelper_la_LIBADD += $(CEGUIOGRE_LIBS)
+    libCEGUISampleHelper_la_LIBADD += $(CEGUIOGRE_LIBS) $(OIS_LIBS)
 endif
 if CEGUI_SAMPLES_USE_OPENGL
     libCEGUISampleHelper_la_SOURCES += CEGuiOpenGLBaseApplication.cpp
--- cegui_mk2/trunk/acinclude.m4   2006/10/25 10:54:43   1415
+++ cegui_mk2/trunk/acinclude.m4   2007/08/08 18:50:37   1480
@@ -148,10 +148,25 @@
 AC_DEFUN([CEGUI_ENABLE_OGRE_RENDERER], [
     PKG_CHECK_MODULES(CEGUIOGRE, CEGUI-OGRE >= 1.0.0, [cegui_found_ogre_renderer=yes], [cegui_found_ogre_renderer=no])
     PKG_CHECK_MODULES(CEGUI_NULL, CEGUI, [cegui_found_cegui=yes], [cegui_found_cegui=no])   
+   PKG_CHECK_MODULES(OIS, OIS >= 1.0.0, [ois_found=yes],[ois_found=no])
+
     AC_ARG_WITH([ogre-renderer], AC_HELP_STRING([--without-ogre-renderer], [Disables the use of the Ogre3D renderer, when available, in samples]),
                 [cegui_with_ogre=$withval], [cegui_with_ogre=yes])
 
-    if test x$cegui_found_ogre_renderer = xyes && test x$cegui_found_cegui = xyes && test x$cegui_with_ogre = xyes; then
+
+   if test "x$ois_found" = "xno" ; then
+      cegui_samples_use_ogre=no
+      AC_MSG_NOTICE([
+****************************************************************
+* You do not have OIS installed.  This is required to build    *
+* Ogre CEGUI demos. You may find it at:                        *
+* http://www.sourceforge.net/projects/wgois.                   *
+* If you do not want to build the demos, you can safely ignore *
+* this.                                                        *
+****************************************************************])
+   fi
+
+    if test x$cegui_found_ogre_renderer = xyes && test x$cegui_found_cegui = xyes && test x$cegui_with_ogre = xyes && test x$ois_found = xyes; then
         cegui_samples_use_ogre=yes
         AC_DEFINE(CEGUI_SAMPLES_USE_OGRE, [], [Define to have the Ogre3D CEGUI renderer available in the samples])
         AC_MSG_NOTICE([Use of Ogre3D in Samples is enabled])
@@ -161,6 +176,8 @@
     fi
 
     AM_CONDITIONAL([CEGUI_SAMPLES_USE_OGRE], [test x$cegui_samples_use_ogre = xyes])
+   AC_SUBST(OIS_CFLAGS)
+   AC_SUBST(OIS_LIBS)
     AC_SUBST(CEGUIOGRE_CFLAGS)
     AC_SUBST(CEGUIOGRE_LIBS)
 ])



now I configured, built and installed CEGUI.

For Ogre, I installed the following stuff via aptitude:

Code: Select all

libzzip-dev
libfreeimage-dev
nvidia-cg-toolkit


Now I configured, built and installed Ogre.

At this point you can test the Ogre samples that use CEGUI if you like :)

Once this was all working, I went back and redid the configure, build and install of CEGUI.

One final step that was required was to copy the plugins.cfg file from ./dev/ogrenew/Samples/Common/bin to ./dev/CEGUI-0.5.0/Samples/bin

Now the CEGUI samples will run under Ogre.

Some final thoughts are that the PKG_CONFIG_PATH stuff I waffled about earlier did not seem to matter. And don't forget to do ldconfig so that the library cache is updated.

I hope this helps :)

CE.

Priato
Just popping in
Just popping in
Posts: 5
Joined: Sun Jan 20, 2008 13:02

Postby Priato » Fri Jan 25, 2008 17:35

Thanks a lot for your help ( again :) )
I have some errors like:

Code: Select all

priato@priato:~/src/Ogre_Tuto_06$ make
g++ example_6.cpp -o example_6 -I/usr/local/include/OGRE/ -I../include -I/usr/include/CEGUI `pkg-config OGRE OIS CEGUI CEGUI-OGRE --libs`
Dans le fichier inclus à partir de /usr/local/include/CEGUI/CEGUI.h:66,
          à partir de example_6.cpp:2:
/usr/local/include/CEGUI/falagard/CEGUIFalWidgetLookManager.h:31:28: erreur: CEGUISingleton.h : Aucun fichier ou répertoire de ce type
/usr/local/include/CEGUI/falagard/CEGUIFalWidgetLookManager.h:32:25: erreur: CEGUIString.h : Aucun fichier ou répertoire de ce type
/usr/local/include/CEGUI/falagard/CEGUIFalWidgetLookManager.h:33:29: erreur: CEGUIExceptions.h : Aucun fichier ou répertoire de ce type
/usr/local/include/CEGUI/falagard/CEGUIFalWidgetLookManager.h:34:45: erreur: falagard/CEGUIFalWidgetLookFeel.h : Aucun fichier ou répertoire de ce type
Dans le fichier inclus à partir de /usr/local/include/CEGUI/CEGUI.h:69,
          à partir de example_6.cpp:2:
/usr/local/include/CEGUI/elements/CEGUIButtonBase.h:33:23: erreur: CEGUIBase.h : Aucun fichier ou répertoire de ce type
/usr/local/include/CEGUI/elements/CEGUIButtonBase.h:34:25: erreur: CEGUIWindow.h : Aucun fichier ou répertoire de ce type
...

I will see the problem later.

Sorry for french language in console...
Last edited by Priato on Mon Jan 28, 2008 20:10, edited 1 time in total.

Priato
Just popping in
Just popping in
Posts: 5
Joined: Sun Jan 20, 2008 13:02

Postby Priato » Mon Jan 28, 2008 20:09

I have checked my configuration and I have done an error in my makefile, So now, it works correctly.

I've tried your patch and it works perfectly, and I've tried svn too (never tried on linux).

Thanks a lot for your help,

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jan 29, 2008 10:09

Priato wrote:Thanks a lot for your help,

No problemo :)


Return to “Help”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 13 guests