An OGRE Tutorial with CEGUI Segmentation Fault

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
javisaman
Just popping in
Just popping in
Posts: 4
Joined: Wed Aug 10, 2005 21:41

An OGRE Tutorial with CEGUI Segmentation Fault

Postby javisaman » Wed Aug 10, 2005 22:01

Hello


I'm following tutorial "Basic Tutorial 6: CEGUI" on the www.ogre3d.org website.

Tutorial 6


I've already posted a similar topic on the Ogre forums, but my problem is coming from the CEGUI stuff, so I thought I might post here.

I'm using gentoo Linux with OGRE 1.0.3 and CEGUI 0.3.0 .

The source code I have so far is:


Code: Select all

#include <CEGUI/CEGUIImageset.h>
#include <CEGUI/CEGUISystem.h>
#include <CEGUI/CEGUILogger.h>
#include <CEGUI/CEGUISchemeManager.h>
#include <CEGUI/CEGUIWindowManager.h>
#include <CEGUI/CEGUIWindow.h>
#include <CEGUI/CEGUIBase.h>
#include "OgreCEGUIRenderer.h"
#include "OgreCEGUIResourceProvider.h"
#include "ExampleApplication.h"
#include <CEGUI/elements/CEGUIPushButton.h>

//using namespace CEGUI;
class GuiFrameListener : public ExampleFrameListener
{
private:
  CEGUI::Renderer* mGUIRenderer;
public:
  GuiFrameListener(RenderWindow* win, Camera* cam,
         CEGUI::Renderer* renderer): ExampleFrameListener(win, cam),
  mGUIRenderer(renderer){
  }
};

class TutorialApplication : public ExampleApplication
{
private:
  CEGUI::OgreCEGUIRenderer* mGUIRenderer;
  CEGUI::System* mGUISystem;
  CEGUI::Window* mEditorGuiSheet;
 
public:
  TutorialApplication(): mGUIRenderer(0),
          mGUISystem(0),
          mEditorGuiSheet(0){
  }
 
  ~TutorialApplication(){
   
    if(mEditorGuiSheet){
   CEGUI::
     WindowManager::
     getSingleton().destroyWindow(mEditorGuiSheet);
    }
    if(mGUISystem){
      delete mGUISystem;
      mGUISystem = 0;
    }
    if(mGUIRenderer){
      delete mGUIRenderer;
      mGUIRenderer = 0;
    }
  }

protected:
  void createScene(void){
    mSceneMgr->setAmbientLight( ColourValue(0.25, 0.25, 0.25));
    Entity *ent = mSceneMgr->createEntity("Ninja", "ninja.mesh");
    SceneNode *node =
      mSceneMgr->getRootSceneNode()->createChildSceneNode("NinjaNode");
    node->attachObject(ent);
   
    Light *light = mSceneMgr->createLight("Light1");
    light->setType(Light::LT_POINT);
    light->setPosition(Vector3(250,150,250));
    light->setDiffuseColour(ColourValue::White);
    light->setSpecularColour( ColourValue::White);

    node =
      mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1",
                       Vector3(-400, 200,
                          400));
    node->yaw (Degree(-45));

    node = node->createChildSceneNode( "PitchNode1");
    node->attachObject(mCamera);

    node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode2",
                            Vector3(0, 200,
                              400));
    node = node->createChildSceneNode("PitchNode2");

    // set up GUI system

    CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
    mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow,
                  Ogre::RENDER_QUEUE_OVERLAY,
                  false,
                  3000);
   
    mGUISystem = new CEGUI::System(mGUIRenderer);

    RenderTexture* rttTex =
      mRoot->getRenderSystem()->createRenderTexture( "RttTex", 512, 512,
                       TEX_TYPE_2D, PF_R8G8B8);
    {
      Camera *rttCam = mSceneMgr->createCamera("RttCam");
      SceneNode* camNode =
   mSceneMgr->getRootSceneNode()->createChildSceneNode("rttCamNode");
      camNode->attachObject(rttCam);
      rttCam->setPosition(0,0,200);
      //rttCam->setVisible(true)
      Viewport *v = rttTex->addViewport (rttCam);
      v->setOverlaysEnabled(false);
      v->setClearEveryFrame(true);
      v->setBackgroundColour( ColourValue::Black);
    }
   
    CEGUI::Texture* rttTexture =
      mGUIRenderer->createTexture((CEGUI::utf8*)"RttTex");
    CEGUI::Imageset* rttImageSet =
      CEGUI::ImagesetManager::
      getSingleton().createImageset((CEGUI::utf8*)"RttImageset", rttTexture);
    rttImageSet->defineImage((CEGUI::utf8*)"RttImage",
              CEGUI::Point(0.0f,0.0f),
              CEGUI::Size(rttTexture->getWidth(),
                rttTexture->getHeight()),
              CEGUI::Point(0.0f, 0.0f));
    CEGUI::
      SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"Taharez.scheme");
    mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook",
                  (CEGUI::utf8*)"MouseArrow");
    mGUISystem->setDefaultFont((CEGUI::utf8*)"Tahoma-12");
    mEditorGuiSheet =
      CEGUI::
      WindowManager::
      getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow",
              (CEGUI::utf8*)"Sheet");
    mGUISystem->setGUISheet(mEditorGuiSheet);
   
    CEGUI::PushButton* quitButton =
      (CEGUI::PushButton*)CEGUI::
      WindowManager::
      getSingleton().createWindow("TaharezLook/Button",
              (CEGUI::utf8*)"Quit");
    mEditorGuiSheet->addChildWindow(quitButton);
    quitButton->setPosition(CEGUI::Point(0.35f, 0.45f));
    quitButton->setSize(CEGUI::Size(0.3f, 0.1f));
    quitButton->setText("Quit");
  }


  void createFrameListener(void)
  {
    mFrameListener = new GuiFrameListener(mWindow, mCamera, mGUIRenderer);
    mRoot->addFrameListener(mFrameListener);
  }

};

int main(int argc, char **argv)
{
  TutorialApplication app;
 
  try{
    app.go();
  }catch( Exception& e){
    fprintf(stderr, "An exception has occured: %s\n",
       e.getFullDescription().c_str());
  }
  return 0;
}





Using printstatements and debuggers I've narrowed down the problem to the lines:

Code: Select all

mGUISystem = new CEGUI::System(mGUIRenderer);


I've also determined that mGUIRenderer is not NULL and mWindow is not NULL.


This is the line in context:

Code: Select all

mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow,
                  Ogre::RENDER_QUEUE_OVERLAY,
                  false,
                  3000);
   
    mGUISystem = new CEGUI::System(mGUIRenderer);



When I run the program I get an error message from the CEGUI Log:

Code: Select all

test: ../include/CEGUISingleton.h:66: static T& CEGUI::Singleton<T>::getSingleton() [with T = CEGUI::Logger]: Assertion `ms_Singleton' failed.
Aborted



Thanks!

User avatar
javisaman
Just popping in
Just popping in
Posts: 4
Joined: Wed Aug 10, 2005 21:41

Re: An OGRE Tutorial with CEGUI Segmentation Fault

Postby javisaman » Thu Aug 11, 2005 01:09

I have discovered that this tutorial was written using CEGUI 0.2.0. So I compiled it with that version and viola it WORKED! But I would like to know how to do this with CEGUI 0.3.0.

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

Re: An OGRE Tutorial with CEGUI Segmentation Fault

Postby CrazyEddie » Thu Aug 11, 2005 13:37

I have no answers for you, I'm afraid. There were no source level breaking changes from 0.2.x to 0.3.0, so any issues should be fixed by a recompile.

Technically speaking Ogre 1.0.3 requires CEGUI 0.3.0, and they definiately work together. Did you try source packages instead of the gentoo ebuilds? I've not tested those, and there's a chance that the issue lies there.

Apart from any of this, you should step through things with the debugger and let us know how to reproduce the issue; as currently, I have no idea as to how to reproduce such an issue at the point you indicate :?

User avatar
javisaman
Just popping in
Just popping in
Posts: 4
Joined: Wed Aug 10, 2005 21:41

Re: An OGRE Tutorial with CEGUI Segmentation Fault

Postby javisaman » Fri Aug 12, 2005 00:19

Thank you for the reply.

I don't think the ebuilds are the problem though. Because the sources are downloaded from this website.

What part of the program do you want me to debug?

Because I'm 100% sure it is coming from that line that I mentioned. Just compiling and running the code below causes it to crash. Would you like me to include all of the files necessary to compile?

Thanks

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

Re: An OGRE Tutorial with CEGUI Segmentation Fault

Postby CrazyEddie » Sun Aug 14, 2005 09:17

Ok. I didn't realise the ebuilds grabbed the code from here ;)

I still suspect some kind of version mismatch though.

The thing is, that the line:

Code: Select all

mGUISystem = new CEGUI::System(mGUIRenderer);


is the line that creates the the Logger in the first place, and the error you're getting is saying that the logger is being used without having been created - so having that error eminate from that line makes no sense at all :?

User avatar
studio
Just popping in
Just popping in
Posts: 2
Joined: Sun Aug 14, 2005 15:37

Re: An OGRE Tutorial with CEGUI Segmentation Fault

Postby studio » Sun Aug 14, 2005 17:07

I get a similar problem with my program except i suspect the cause is different. The class CEGUI::System is based on a Singleton class (http://gethelp.devx.com/techtips/cpp_pr ... in0200.asp)

What this means (in this particular implementation of an Singleton class) is that you may only call "new CEGUI::System" once plus you can only call it after the global variables have been initalized. Otherwise an assert will be triggered (the same one that youve posted here) which is put there to prevent multiply instances being created.

The reason this is a problem for me is i require more than once instance of CEGUI::System to work with my multimonitor program, but maybe someone else can help you solve your problem

User avatar
javisaman
Just popping in
Just popping in
Posts: 4
Joined: Wed Aug 10, 2005 21:41

Re: An OGRE Tutorial with CEGUI Segmentation Fault

Postby javisaman » Sat Aug 20, 2005 01:49

CrazyEddie

Sorry it looks like I posted the wrong error message...I was just getting a generic segmentation fault at the line I mentioned.

I posted the same problem in the Ogre
forums

I pretty much copied and pasted the tutorial and it seems to work now (I'm not exactly sure what caused it to crash).

Here is the code:

Code: Select all

#include <CEGUI/CEGUIImageset.h>
#include <CEGUI/CEGUISystem.h>
#include <CEGUI/CEGUILogger.h>
#include <CEGUI/CEGUISchemeManager.h>
#include <CEGUI/CEGUIWindowManager.h>
#include <CEGUI/CEGUIWindow.h>
#include "OgreCEGUIRenderer.h"
#include "OgreCEGUIResourceProvider.h"
#include <CEGUI/elements/CEGUIPushButton.h>

#include "ExampleApplication.h"

class GuiFrameListener : public ExampleFrameListener
{
private:
  CEGUI::Renderer* mGUIRenderer;
public:
  GuiFrameListener(RenderWindow* win, Camera* cam, CEGUI::Renderer* renderer) : ExampleFrameListener(win, cam), mGUIRenderer(renderer)
  {
  }
};

class TutorialApplication : public ExampleApplication
{
private:
   CEGUI::OgreCEGUIRenderer* mGUIRenderer;
   CEGUI::System* mGUISystem;
   CEGUI::Window* mEditorGuiSheet;
public:
    TutorialApplication(): mGUIRenderer(0), mGUISystem(0), mEditorGuiSheet(0)
    {
    }

    ~TutorialApplication()
    {
       if(mEditorGuiSheet)
       {
           CEGUI::WindowManager::getSingleton().destroyWindow(mEditorGuiSheet);
       }
       if(mGUISystem)
       {
           delete mGUISystem;
           mGUISystem = 0;
       }
       if(mGUIRenderer)
       {
           delete mGUIRenderer;
           mGUIRenderer = 0;
       }
    }
protected:
  void createScene(void)
  {
      // Set ambient light
      mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
      mSceneMgr->setAmbientLight ( ColourValue (1, 1, 1));

      Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh");
     
      SceneNode *node1 =
   mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode");
     
      node1->attachObject( ent1 );
     

       // setup GUI system
       mGUIRenderer =
    new CEGUI::
    OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000);
       mGUISystem = new CEGUI::System(mGUIRenderer);
       CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
       
       RenderTexture* rttTex =
    mRoot->getRenderSystem()->createRenderTexture( "RttTex",
                     512, 512,
                     TEX_TYPE_2D,
                     PF_R8G8B8 );
 {
    Camera* rttCam = mSceneMgr->createCamera("RttCam");
           SceneNode* camNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("rttCamNode");
           camNode->attachObject(rttCam);
           rttCam->setPosition(0,0,200);
           //rttCam->setVisible(true);
           Viewport *v = rttTex->addViewport( rttCam );
           v->setOverlaysEnabled(false);
           v->setClearEveryFrame( true );
           v->setBackgroundColour( ColourValue::Black );
       }
       
       // Retrieve CEGUI texture for the RTT
       CEGUI::Texture* rttTexture = mGUIRenderer->createTexture((CEGUI::utf8*)"RttTex");
       CEGUI::Imageset* rttImageSet =
    CEGUI::
    ImagesetManager::
    getSingleton().createImageset((CEGUI::utf8*)"RttImageset", rttTexture);
       rttImageSet->defineImage((CEGUI::utf8*)"RttImage",
            CEGUI::Point(0.0f, 0.0f),
            CEGUI::Size(rttTexture->getWidth(),
                   rttTexture->getHeight()),
            CEGUI::Point(0.0f,0.0f));
       
       CEGUI::SchemeManager::
    getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
       mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook",
                (CEGUI::utf8*)"MouseArrow");
       mGUISystem->setDefaultFont((CEGUI::utf8*)"Tahoma-12");
       mEditorGuiSheet= CEGUI::
    WindowManager::getSingleton().createWindow((CEGUI::utf8*)"DefaultWindow", (CEGUI::utf8*)"Sheet"); 
       mGUISystem->setGUISheet(mEditorGuiSheet);

    CEGUI::PushButton* quitButton =
      (CEGUI::PushButton*)CEGUI::
      WindowManager::
      getSingleton().createWindow("TaharezLook/Button",
              (CEGUI::utf8*)"Quit");
    mEditorGuiSheet->addChildWindow(quitButton);
    quitButton->setPosition(CEGUI::Point(0.35f, 0.45f));
    quitButton->setSize(CEGUI::Size(0.3f, 0.1f));
    quitButton->setText("Quit");

    }

void createFrameListener(void)
   {
       mFrameListener= new GuiFrameListener(mWindow, mCamera, mGUIRenderer);
       mRoot->addFrameListener(mFrameListener);
   }
};

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
    // Create application object
    TutorialApplication app;

    try {
        app.go();
    } catch( Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
        fprintf(stderr, "An exception has occured: %s\n",
                e.getFullDescription().c_str());
#endif
    }

    return 0;
}

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

Re: An OGRE Tutorial with CEGUI Segmentation Fault

Postby CrazyEddie » Sat Aug 20, 2005 18:15

I still don't know what would have caused it, but so long as you have it running now, that's all that matters :)

maebius
Just popping in
Just popping in
Posts: 2
Joined: Fri Dec 08, 2006 08:35
Location: Helsinki, Finland

Postby maebius » Fri Dec 08, 2006 11:30

Hello, fellow developers! :)

I actually posted this message to Ogre-forums, but as I don't use Ogre, just CEGUI, this is a more appropriate place :).

I have a similar problem that has been discussed in this thread. I haven't managed to get around it even with the help of this insightfull discussion, though. There is something about loading textures from file, and propable cause is somekind of library mismatch (with DevIL). Anyway.

I get a segfault when calling

CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*) "./cegui/schemes/TaharezLook.scheme");

I run the program on Fedora Core 5, with default CEGUI opengl-renderer. The last lines of CEGUI.log are as follows:

08/12/2006 09:30:07 (InfL2) Loaded GUI scheme 'TaharezLook' from data in file './cegui/schemes/TaharezLook.scheme'.
08/12/2006 09:30:07 (InfL2) ---- Begining resource loading for GUI scheme 'TaharezLook' ----
08/12/2006 09:30:07 (InfL1) Attempting to create an Imageset from the information specified in file './cegui/imagesets/TaharezLook.imageset'.
08/12/2006 09:30:07 (InfL1) Started creation of Imageset from XML specification:
08/12/2006 09:30:07 (InfL1) ---- CEGUI Imageset name: TaharezLook
08/12/2006 09:30:07 (InfL1) ---- Source texture file: ./cegui/imagesets/TaharezLook.tga in resource group: (Default)

And this is what debugger (gdb) says:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208879408 (LWP 3878)]
0x00cac6c2 in iGetIntegervImage (Image=0x8cf2a40, Mode=3571, Param=0x4bb86b70) at il_states.c:485
485 *Param = 0;

Any ideas/advices?

Best regards,
Markus


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 7 guests