segfault trying to use CEGUI with PyOgre

arrummzen

11-01-2007 23:49:52

I'm trying to use CEGUI with PyOgre.

In my resource directory, I have:
Commonwealth-10.font TaharezLook.looknfeel TaharezLook.imageset TaharezLook.scheme TaharezLookSkin.scheme

I have edited TaharezLook.scheme TaharezLookSkin.scheme to remove the relative path information (should be unneeded with all the files in the same directory)

I do:
#init the CEGUI
self.CEOgreRenderer = cegui.OgreCEGUIRenderer(RenderWin)
self.CEGUISys = cegui.System(self.CEOgreRenderer)
cegui.Logger.getSingleton().loggingLevel = cegui.Insane

#load the scheme
cegui.SchemeManager.getSingleton().loadScheme("TaharezLookSkin.scheme")
cegui.FontManager.getSingleton().createFont("Commonwealth-10.font")


I get:
Program received signal SIGSEGV, Segmentation fault.
0xb7ea10ea in PyType_IsSubtype (a=0x0, b=0xb7f37a80) at typeobject.c:821
821 typeobject.c: No such file or directory.
in typeobject.c
(tgdb) bt
#0 0xb7ea10ea in PyType_IsSubtype (a=0x0, b=0xb7f37a80) at typeobject.c:821
#1 0xb7e728e5 in PyFile_WriteObject (v=0x82225d8, f=0xb7a640b0, flags=1) at fileobject.c:2026
#2 0xb7ef312c in PyErr_Display (exception=0x82225d8, value=0xb62ce8cc, tb=0xb62f15cc) at pythonrun.c:1167
#3 0xb7ef5200 in sys_excepthook (self=0x0, args=0xb62a6b94) at sysmodule.c:137
#4 0xb7e8c25f in PyCFunction_Call (func=0xb7a61c6c, arg=0xb62a6b94, kw=0x0) at methodobject.c:73
#5 0xb7e6164d in PyObject_Call (func=0xb7a61c6c, arg=0xb62a6b94, kw=0x0) at abstract.c:1795
#6 0xb7ecde83 in PyEval_CallObjectWithKeywords (func=0xb7a61c6c, arg=0xb62a6b94, kw=0x0) at ceval.c:3430
#7 0xb7ef2bfc in PyErr_PrintEx (set_sys_last_vars=1) at pythonrun.c:1066
#8 0xb7ef2815 in PyErr_Print () at pythonrun.c:965
#9 0xb7ef23f0 in PyRun_SimpleFileExFlags (fp=0x804a008, filename=0xbf8c7120 "./splinerace.py", closeit=1, flags=0xbf8c6d70) at py
thonrun.c:864
#10 0xb7ef1c7d in PyRun_AnyFileExFlags (fp=0x804a008, filename=0xbf8c7120 "./splinerace.py", closeit=1, flags=0xbf8c6d70) at pytho
nrun.c:664
#11 0xb7efa5f5 in Py_Main (argc=4, argv=0xbf8c6e74) at main.c:493
#12 0x0804865e in main (argc=4, argv=0xbf8c6e74) at python.c:23

Is this fixable? If yes, how? If not, is there a more reliable way to do GUIs with Python in Ogre?

Thank you for your time,
Arrummzen

dermont

13-01-2007 20:41:15

You probably need to copy the following to your directory:
TaharezLook.tga
Commonv2c.ttf

and edit the following files:

i) edit TaharezLook Imageset file
#Imagefile="../datafiles/imagesets/TaharezLook.tga"
Imagefile="TaharezLook.tga"


ii) Edit Commonwealth-10.font
#Filename="../datafiles/fonts/Commonv2c.ttf"
Filename="Commonv2c.ttf"



Your media directory should look something like:

Commonwealth-10.font
TaharezLook.imageset
TaharezLook.looknfeel
TaharezLook.scheme
TaharezLookSkin.scheme
TaharezLook.tga
Commonv2c.ttf


Note if you OgreCEGUIRenderer constructor with just self.renderWindow you must call setTargetSceneManager before rendering, e.g:

a)
self.guiRenderer = cegui.OgreCEGUIRenderer(self.renderWindow)
..
self.guiRenderer.setTargetSceneManager(self.sceneManager)


Alternatively you can:

b) self.guiRenderer = cegui.OgreCEGUIRenderer(self.renderWindow,ogre.RENDER_QUEUE_OVERLAY, False, self.sceneManager)


For (a) take a look at LayoutCreationDemo.py and (b) the other demos.

arrummzen

14-01-2007 04:43:26

I added a line akin to
self.guiRenderer.setTargetSceneManager(self.sceneManager)

I believe I have setup my data directory the way you have described, however, I still get Segmentation Faults.

This is what my CEGUI.log looks like:

13/01/2007 20:36:02 (InfL1) +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
13/01/2007 20:36:02 (InfL1) + Crazy Eddie's GUI System - Event log +
13/01/2007 20:36:02 (InfL1) + (http://www.cegui.org.uk/) +
13/01/2007 20:36:02 (InfL1) +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

13/01/2007 20:36:02 (InfL1) CEGUI::Logger singleton created.
13/01/2007 20:36:02 (InfL1) ---- Begining CEGUI System initialisation ----
13/01/2007 20:36:02 (InfL1) CEGUI::ImagesetManager singleton created
13/01/2007 20:36:02 (InfL1) CEGUI::FontManager singleton created.
13/01/2007 20:36:02 (InfL1) CEGUI::WindowFactoryManager singleton created
13/01/2007 20:36:02 (InfL1) CEGUI::WindowManager singleton created
13/01/2007 20:36:02 (InfL1) CEGUI::SchemeManager singleton created.
13/01/2007 20:36:02 (InfL1) CEGUI::MouseCursor singleton created.
13/01/2007 20:36:02 (InfL1) CEGUI::GlobalEventSet singleton created.
13/01/2007 20:36:02 (InfL1) CEGUI::WidgetLookManager singleton created.
13/01/2007 20:36:02 (InfL1) WindowFactory for 'DefaultWindow' windows added.
13/01/2007 20:36:02 (InfL1) WindowFactory for 'DragContainer' windows added.
13/01/2007 20:36:02 (InfL1) WindowFactory for 'ScrolledContainer' windows added.
13/01/2007 20:36:02 (InfL1) Window type alias named 'DefaultGUISheet' added for window type 'DefaultWindow'.
13/01/2007 20:36:02 (InfL1) CEGUI::System singleton created.
13/01/2007 20:36:02 (InfL1) ---- CEGUI System initialisation completed ----
13/01/2007 20:36:02 (InfL1) ---- Version 0.4.1 ----
13/01/2007 20:36:02 (InfL1) ---- Renderer module is: CEGUI::OgreRenderer - Official Ogre based renderer module for CEGUI ----
13/01/2007 20:36:02 (InfL1) ---- XML Parser module is: CEGUI::TinyXMLParser - Official tinyXML based parser module for CEGUI ----
13/01/2007 20:36:02 (InfL1) ---- Scripting module is: None ----
13/01/2007 20:36:02 (InfL1) Attempting to load Scheme from file 'TaharezLook.scheme'.
13/01/2007 20:36:02 (InfL2) Started creation of Scheme 'TaharezLook' via XML file.
13/01/2007 20:36:02 (InfL2) Finished creation of Scheme 'TaharezLook' via XML file.
13/01/2007 20:36:02 (InfL2) Loaded GUI scheme 'TaharezLook' from data in file 'TaharezLook.scheme'.
13/01/2007 20:36:02 (InfL2) ---- Begining resource loading for GUI scheme 'TaharezLook' ----
13/01/2007 20:36:02 (InfL1) Attempting to create an Imageset from the information specified in file 'TaharezLook.imageset'.
13/01/2007 20:36:02 (InfL2) Started creation of Imageset 'TaharezLook' via XML file.
13/01/2007 20:36:02 (InfL2) Finished creation of Imageset 'TaharezLook' via XML file.
13/01/2007 20:36:02 (Error) Exception: FactoryModule::FactoryModule - Failed to load module 'libCEGUITaharezLook.so'.

dermont

14-01-2007 08:55:20

Which versions of pyOgre , Ogre and media are you using?.

The error from your log appears to suggest that you are trying to load TaharezLook.scheme instead of TaharezLookSkin.scheme. I've tested the above on Windows and linux and it works ok for me. Here are the steps I took:

1) copied across media to media/test and edited as outlined in above posts

2) Edited resources.cfg

#FileSystem=../media/gui/datafiles/fonts
#FileSystem=../media/gui
#FileSystem=../media/gui/datafiles
#FileSystem=../media/gui/datafiles/schemes
#FileSystem=../media/gui/datafiles/imagesets
#FileSystem=../media/gui/datafiles/layouts
#FileSystem=../media/gui/datafiles/looknfeel
FileSystem=layouts/
FileSystem=../media/test

3) Copy DragnDropDemo.py to test.py, and updated as follows:

# load TaharezLook scheme
#cegui.SchemeManager.getSingleton().loadScheme("TaharezLook.scheme")
#self.system.defaultMouseCursor=("TaharezLook", "MouseArrow")
#cegui.FontManager.getSingleton().createFont("Iconified-12.font")

# load TaharezLookSkin scheme
cegui.SchemeManager.getSingleton().loadScheme("TaharezLookSkin.scheme")
self.system.defaultMouseCursor=("TaharezLook", "MouseArrow")
cegui.FontManager.getSingleton().createFont("Commonwealth-10.font")

4) Ran test.py, log output:

14/01/2007 16:10:16 (InfL1) ---- Scripting module is: None ----
14/01/2007 16:10:16 (InfL1) Attempting to load Scheme from file 'TaharezLookSkin.scheme'.
14/01/2007 16:10:16 (InfL2) Started creation of Scheme 'TaharezLookSkin' via XML file.
14/01/2007 16:10:16 (InfL2) Finished creation of Scheme 'TaharezLookSkin' via XML file.
14/01/2007 16:10:16 (InfL2) Loaded GUI scheme 'TaharezLookSkin' from data in file 'TaharezLookSkin.scheme'.

5) Changed test.py

#cegui.SchemeManager.getSingleton().loadScheme("TaharezLookSkin.scheme")
cegui.SchemeManager.getSingleton().loadScheme("TaharezLook.scheme")

Reran, it segfaults "Failed to load module 'libCEGUITaharezLook.so" as per log posted above. This is due to a problem with swig/cegui which meant that you had to statically link against the individial *Look.so's. As a workaround the build process for pyOgre1.2.0 was updated to compile against the FalgardBase and use the *LookSkins. So you shouldn't be getting this error if your loading TaharezLookSkin.scheme, see:
http://www.ogre3d.org/phpBB2addons/view ... aharezlook

arrummzen

15-01-2007 01:45:46

It is working now, Thank you for the help.

I truly appreciate it.

Thank you for your time,
Arrummzen