Adding text to a widget causes a Segfault

libolt

26-11-2007 07:35:00

First of all, I am not using ExampleApplication.h or ExampleFramelistener.h in any way in my code.

Right now what I am trying to do is just get a basic understanding of how QuickGUI works and how I can use it in my game. For all the work I've done on making it compile and run on Linux I still have a ways to go in understanding how to use it.

My problem is that anytime I call setText like:


loginButton->setText("Login");


A segfault ensues. However if I call it without any text like the following it doesn't crash and draws the button with a blank caption:


loginButton->setText("");


This is all the code in the function where loginButton->setText is called:


renderSystems *render = renderSystems::Instance();

using QuickGUI::Rect;
using QuickGUI::Point;
using QuickGUI::Size;

QuickGUI::SkinSetManager::getSingleton().loadSkin("qgui", QuickGUI::SkinSet::IMAGE_TYPE_PNG, render->getMResourceGroup());
QuickGUI::GUIManager* mGUIManager = new QuickGUI::GUIManager(render->getMCamera()->getViewport());
mGUIManager->setSceneManager(render->getMSceneMgr());

mSheet = mGUIManager->getDefaultSheet();

QuickGUI::Button* loginButton = mSheet->createButton();
loginButton->setDimensions(Rect(100,420,200,42));
loginButton->setText("Login");

mSheet->setFont("acmesa.10",true);
mGUIManager->setActiveSheet(mSheet);



I know I have all the code jumbled together, but I'm trying to do the most basic setup as possible to test that it works then I shall refactor the code later.

I'm probably missing something basic here, but I've pounded away at the problem for a while and can't figure it out. Any pointers are appreciated. If you need more from me, just ask.

Mike

kungfoomasta

26-11-2007 08:01:18

First glance, nothing obvious sticks out. I don't think this is related, but you are calling "QuickGUI::registerScriptParser();" before initialization of your resources, right?

Is there an error produced in ogre.log? What was the last QuickGUI line executed during the crash? If you remove the last two lines of your sample code, (mSheet->setFont... setActiveSheet) does the crash still occur?

libolt

26-11-2007 08:23:12

First glance, nothing obvious sticks out. I don't think this is related, but you are calling "QuickGUI::registerScriptParser();" before initialization of your resources, right?


Yes I believe so. I'm calling it as follows:

QuickGUI::registerScriptParser();

ResourceGroupManager *rsm = ResourceGroupManager::getSingletonPtr();
rsm->createResourceGroup(mResourceGroup);
// load the basic resource location(s)
rsm->addResourceLocation("Media", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/fonts", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/gui", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/models", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/materials/textures", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/materials/programs", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/materialss/scripts", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/materials", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/overlays", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/packs", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/skins", "FileSystem", mResourceGroup);
rsm->addResourceLocation("Media/skins/qgui", "FileSystem", mResourceGroup);

rsm->initialiseResourceGroup(mResourceGroup);




Is there an error produced in ogre.log? What was the last QuickGUI line executed during the crash? If you remove the last two lines of your sample code, (mSheet->setFont... setActiveSheet) does the crash still occur?


There's no error at the end of the log but I do get the following related to StarWars font:


01:05:21: Font StarWarsusing texture size 512x512
01:05:21: Info: Freetype returned null for character 35 in font StarWars
01:05:21: Info: Freetype returned null for character 37 in font StarWars
01:05:21: Info: Freetype returned null for character 38 in font StarWars
01:05:21: Info: Freetype returned null for character 42 in font StarWars
01:05:21: Info: Freetype returned null for character 43 in font StarWars
01:05:21: Info: Freetype returned null for character 60 in font StarWars
01:05:21: Info: Freetype returned null for character 62 in font StarWars
01:05:21: Info: Freetype returned null for character 64 in font StarWars
01:05:21: Info: Freetype returned null for character 94 in font StarWars
01:05:21: Info: Freetype returned null for character 96 in font StarWars
01:05:21: Info: Freetype returned null for character 126 in font StarWars
01:05:21: Info: Freetype returned null for character 127 in font StarWars
01:05:21: Info: Freetype returned null for character 128 in font StarWars
01:05:21: Info: Freetype returned null for character 129 in font StarWars
01:05:21: Info: Freetype returned null for character 130 in font StarWars
01:05:21: Info: Freetype returned null for character 131 in font StarWars
01:05:21: Info: Freetype returned null for character 132 in font StarWars
01:05:21: Info: Freetype returned null for character 133 in font StarWars
01:05:21: Info: Freetype returned null for character 134 in font StarWars
01:05:21: Info: Freetype returned null for character 135 in font StarWars
01:05:21: Info: Freetype returned null for character 136 in font StarWars
01:05:21: Info: Freetype returned null for character 137 in font StarWars
01:05:21: Info: Freetype returned null for character 138 in font StarWars
01:05:21: Info: Freetype returned null for character 139 in font StarWars
01:05:21: Info: Freetype returned null for character 140 in font StarWars
01:05:21: Info: Freetype returned null for character 141 in font StarWars
01:05:21: Info: Freetype returned null for character 142 in font StarWars
01:05:21: Info: Freetype returned null for character 143 in font StarWars
01:05:21: Info: Freetype returned null for character 144 in font StarWars
01:05:21: Info: Freetype returned null for character 145 in font StarWars
01:05:21: Info: Freetype returned null for character 146 in font StarWars
01:05:21: Info: Freetype returned null for character 147 in font StarWars
01:05:21: Info: Freetype returned null for character 148 in font StarWars
01:05:21: Info: Freetype returned null for character 149 in font StarWars
01:05:21: Info: Freetype returned null for character 150 in font StarWars
01:05:21: Info: Freetype returned null for character 151 in font StarWars
01:05:21: Info: Freetype returned null for character 152 in font StarWars
01:05:21: Info: Freetype returned null for character 153 in font StarWars
01:05:21: Info: Freetype returned null for character 154 in font StarWars
01:05:21: Info: Freetype returned null for character 155 in font StarWars
01:05:21: Info: Freetype returned null for character 156 in font StarWars
01:05:21: Info: Freetype returned null for character 157 in font StarWars
01:05:21: Info: Freetype returned null for character 158 in font StarWars
01:05:21: Info: Freetype returned null for character 159 in font StarWars
01:05:21: Info: Freetype returned null for character 160 in font StarWars
01:05:21: Info: Freetype returned null for character 161 in font StarWars
01:05:21: Info: Freetype returned null for character 162 in font StarWars
01:05:21: Info: Freetype returned null for character 163 in font StarWars
01:05:21: Info: Freetype returned null for character 164 in font StarWars
01:05:21: Info: Freetype returned null for character 165 in font StarWars
01:05:21: Info: Freetype returned null for character 166 in font StarWars
01:05:21: Texture: StarWarsTexture: Loading 1 faces(PF_BYTE_LA,512x512x1) with hardware generated mipmaps from Image. Internal format is PF_BYTE_LA,512x512x1.
01:05:21: Texture: SkinSet.qgui.png: Loading 1 faces(PF_A8R8G8B8,1024x1024x1) with 10 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,1024x1024x1.


Removing the setFont and setActiveSheet make no difference. they are the last lines of QuickGUI code that are called currently. Perhaps there's more that I need to setup before rendering.

The rest of the code I'm using after the QuickGUI code is:


while (!ubc->quitGame)
{
// ubc->processUnbufferedKeyInput();

// ubc->frameStarted();
// run the message pump (Eihort)
Ogre::WindowEventUtilities::messagePump();

render->getMRoot()->renderOneFrame();

}



I have disabled pretty much all other code while I concentrate on this problem.

Also for anyone else that might be using linux or familiar with GDB, I have run it on my game and gotten the following output:


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47229963724208 (LWP 21009)]
0x00002af48dceae33 in QuickGUI::VertexBuffer::_renderVertexBuffer () from /usr/local/lib/libQuickGUI.so.0
(gdb) bt
#0 0x00002af48dceae33 in QuickGUI::VertexBuffer::_renderVertexBuffer () from /usr/local/lib/libQuickGUI.so.0
#1 0x00002af48dcd0fd4 in QuickGUI::QuadContainer::render () from /usr/local/lib/libQuickGUI.so.0
#2 0x00002af48dcc1083 in QuickGUI::GUIManager::renderQueueStarted () from /usr/local/lib/libQuickGUI.so.0
#3 0x00002af48d6be5c5 in Ogre::SceneManager::fireRenderQueueStarted (this=<value optimized out>, id=<value optimized out>,
invocation=@0x6568c0) at OgreSceneManager.cpp:3284
#4 0x00002af48d6bf0d8 in Ogre::SceneManager::renderVisibleObjectsDefaultSequence (this=0x1193e70) at OgreSceneManager.cpp:1839
#5 0x00002af48d6beca3 in Ogre::SceneManager::_renderScene (this=0x1193e70, camera=0x119daa0, vp=0x119e0a0,
includeOverlays=<value optimized out>) at OgreSceneManager.cpp:1277
#6 0x00002af48d69666c in Ogre::RenderTarget::update (this=0x10ccbb0) at OgreRenderTarget.cpp:111
#7 0x00002af48d69a678 in Ogre::RenderWindow::update (this=0x0, swap=false) at OgreRenderWindow.cpp:73
#8 0x00002af48d690c81 in Ogre::RenderSystem::_updateAllRenderTargets (this=<value optimized out>) at OgreRenderSystem.cpp:106
#9 0x00002af48d6b12d7 in Ogre::Root::renderOneFrame (this=0x6608e0) at OgreRoot.cpp:751
#10 0x00000000004382bb in main (argc=1, argv=0x7fff1daea1f8) at /home/libolt/Projects/ubc/src/ubcapp.cpp:727


Thanks for the help.

Mike

kungfoomasta

26-11-2007 08:29:15

Is it possible to step inside _renderVertexBuffer and see where is crashes? Sorry I'm not being very helpful, I wish I could load up your setup and figure it out, but I don't have any problems calling setText. :?

libolt

26-11-2007 08:48:21

Well I wasn't able to dig deeper into _renderVertexBuffer, but I did recompile QuickGUI with debugging symbols. For some reason I had it set to Release mode.

Anyways, I now get the following backtrace from GDB with some more info:


ubc: /usr/local/include/OGRE/OgreSharedPtr.h:134: T* Ogre::SharedPtr<T>::operator->() const [with T = Ogre::Material]: Assertion `pRep' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 47005499884976 (LWP 21597)]
0x00002ac04c23e765 in raise () from /lib/libc.so.6
(gdb) bt
#0 0x00002ac04c23e765 in raise () from /lib/libc.so.6
#1 0x00002ac04c2401c0 in abort () from /lib/libc.so.6
#2 0x00002ac04c237c2f in __assert_fail () from /lib/libc.so.6
#3 0x00002ac04ab55daa in Ogre::SharedPtr<Ogre::Material>::operator-> (this=0x7fff60cbff70)
at /usr/local/include/OGRE/OgreSharedPtr.h:134
#4 0x00002ac04ab65c06 in QuickGUI::VertexBuffer::_renderVertexBuffer (this=0x11a6180)
at /home/libolt/builds/quickgui/QuickGUI/src/QuickGUIVertexBuffer.cpp:224
#5 0x00002ac04ab65f2e in QuickGUI::VertexBuffer::render (this=0x11a6180)
at /home/libolt/builds/quickgui/QuickGUI/src/QuickGUIVertexBuffer.cpp:297
#6 0x00002ac04ab46eed in QuickGUI::QuadContainer::render (this=0x11a60c0)
at /home/libolt/builds/quickgui/QuickGUI/src/QuickGUIQuadContainer.cpp:287
#7 0x00002ac04ab3394e in QuickGUI::GUIManager::renderQueueStarted (this=0x11a3580, id=100 'd', invocation=@0x6568c0,
skipThisQueue=@0x7fff60cc015f) at /home/libolt/builds/quickgui/QuickGUI/src/QuickGUIManager.cpp:746
#8 0x00002ac04a4e65c5 in Ogre::SceneManager::fireRenderQueueStarted (this=<value optimized out>, id=<value optimized out>,
invocation=@0x6568c0) at OgreSceneManager.cpp:3284
#9 0x00002ac04a4e70d8 in Ogre::SceneManager::renderVisibleObjectsDefaultSequence (this=0x1193e60) at OgreSceneManager.cpp:1839
#10 0x00002ac04a4e6ca3 in Ogre::SceneManager::_renderScene (this=0x1193e60, camera=0x119da90, vp=0x119e090,
includeOverlays=<value optimized out>) at OgreSceneManager.cpp:1277
#11 0x00002ac04a4be66c in Ogre::RenderTarget::update (this=0x10ccbb0) at OgreRenderTarget.cpp:111
#12 0x00002ac04a4c2678 in Ogre::RenderWindow::update (this=0x545d, swap=93) at OgreRenderWindow.cpp:73
#13 0x00002ac04a4b8c81 in Ogre::RenderSystem::_updateAllRenderTargets (this=<value optimized out>) at OgreRenderSystem.cpp:106
#14 0x00002ac04a4d92d7 in Ogre::Root::renderOneFrame (this=0x6608e0) at OgreRoot.cpp:751
#15 0x00000000004382bb in main (argc=1, argv=0x7fff60cc03c8) at /home/libolt/Projects/ubc/src/ubcapp.cpp:727


Maybe this will help?

Mike

kungfoomasta

26-11-2007 08:57:50

Maybe.

Its odd, but getByName doesn't seem to throw an Ogre exception, when used to get a material. My guess is that you do not have the material definition "QuickQuiSkinTemplate" in an Ogre Resource location. It comes in a file called skinTemplate.material, make sure that is in an ogre defined resource path, and see if you still get problems. Why this crashes when setting the text, I don't know.. (hopefully this is the problem..)

libolt

26-11-2007 09:20:33

okay well it seems I omitted skinTemplate.material from the copy I made of the quickgui media directory into my own.

However now that I have it there, the program dies in a new way:


Initialising resource group
Parsing scripts for resource group
Parsing script 1.material
Parsing script 1.material
Parsing script skinTemplate.material
ubc: OgreGpuProgramManager.cpp:42: static Ogre::GpuProgramManager& Ogre::GpuProgramManager::getSingleton(): Assertion `ms_Singleton' failed.


The new backtrace is:


Program received signal SIGABRT, Aborted.
[Switching to Thread 47681491658160 (LWP 21942)]
0x00002b5db063c765 in raise () from /lib/libc.so.6
(gdb) bt
#0 0x00002b5db063c765 in raise () from /lib/libc.so.6
#1 0x00002b5db063e1c0 in abort () from /lib/libc.so.6
#2 0x00002b5db0635c2f in __assert_fail () from /lib/libc.so.6
#3 0x00002b5dae7a0b47 in Ogre::GpuProgramManager::getSingleton () at OgreGpuProgramManager.cpp:42
#4 0x00002aaaaab26f05 in Ogre::CgProgram::isSupported (this=<value optimized out>) at OgreCgProgram.cpp:477
#5 0x00002b5dae7ee8ca in Ogre::MaterialSerializer::finishProgramDefinition (this=0x6647c0) at OgreMaterialSerializer.cpp:3000
#6 0x00002b5dae7f0048 in Ogre::MaterialSerializer::parseScriptLine (this=0x6647c0, line=@0x7ffffc8c1730)
at OgreMaterialSerializer.cpp:2874
#7 0x00002b5dae7f0923 in Ogre::MaterialSerializer::parseScript (this=0x6647c0, stream=@0x7ffffc8c1850,
groupName=<value optimized out>) at OgreMaterialSerializer.cpp:2736
#8 0x00002b5dae8cb7c3 in Ogre::ResourceGroupManager::parseResourceGroupScripts (this=0x6614d0, grp=<value optimized out>)
at OgreResourceGroupManager.cpp:787
#9 0x00002b5dae8cc1c2 in Ogre::ResourceGroupManager::initialiseResourceGroup (this=0x6614d0, name=@0x660870)
at OgreResourceGroupManager.cpp:119
#10 0x000000000042ed82 in renderSystems (this=0x660820) at /home/libolt/Projects/ubc/src/rendersystems.cpp:82
#11 0x000000000042f80c in renderSystems::Instance () at /home/libolt/Projects/ubc/src/rendersystems.cpp:14
#12 0x000000000043827b in main (argc=1, argv=0x7ffffc8c1fc8) at /home/libolt/Projects/ubc/src/ubcapp.cpp:712



Thanks again for your help. I'm going to head to bed and try and work on this tomorrow with a clear mind.

Mike

kungfoomasta

26-11-2007 18:23:20

So its saying Ogre is dieing during initialization of a resource group. We should find out what resource group its trying to initialize. I'm guessing we have a few possibilities:

1. Duplicate Material definitions. Check Ogre log for any exceptions, and review your resource locations on disk for duplicates.
2. Corrupt Material definition. Doesn't want to parse for some reason. Try running a working Ogre demo with the material listed in a resource location.
3. CG plugin. Not sure about this one, but I see it mentioned in the call stack. Do you have CG plugin listed in your plugins.cfg, or have it added via code? (if not, add it!)

libolt

26-11-2007 19:36:37

So its saying Ogre is dieing during initialization of a resource group. We should find out what resource group its trying to initialize. I'm guessing we have a few possibilities:

1. Duplicate Material definitions. Check Ogre log for any exceptions, and review your resource locations on disk for duplicates.

I think I have this narrowed down to the skinTemplate.material that I placed in my Media/skins directory (I actually copied the entire contents of QuickGUI's media/skins to my Media directory).


2. Corrupt Material definition. Doesn't want to parse for some reason. Try running a working Ogre demo with the material listed in a resource location.


I copied the skins directory over to my ogrenew/Samples/Media directory from which I built Ogre and added its resource location to the Demos resources.cfg.
From here I found that skinTemplate.material was trying to load: positiontoUv.cg instead of positionToUv.cg which caused it to throw an Exception that was caught in Ogre.log. I fixed skinTemplate.material to reflect the proper file name. After that skinTemplate.material loaded fine without any exceptions being thrown.

However my program still bails out with:


ubc: OgreGpuProgramManager.cpp:42: static Ogre::GpuProgramManager& Ogre::GpuProgramManager::getSingleton(): Assertion `ms_Singleton' failed.


So obviously there's some sort of error in my code somewhere. QuickGUIDemo runs fine as well, loading skinTemplate.material without issue.


3. CG plugin. Not sure about this one, but I see it mentioned in the call stack. Do you have CG plugin listed in your plugins.cfg, or have it added via code? (if not, add it!)


I have the CG plugin loaded directly in code. Without it I get a different backtrace. :) I don't use any of the Demos .cfg files.

Well I'll keep plugging away, there's got to be something I"m not doing right :)

Mike

libolt

27-11-2007 05:36:04

Okay I have managed to create a simple Ogre/QuickGUI program that recreates the same problem I have within the game.

This is all of the code:


#include "Ogre.h"

#include "OgreWindowEventUtilities.h"

#include "QuickGUI.h"

#if defined(WIN32)
#include "windows.h"

using namespace Ogre;

WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
#else
int main (int argc, char *argv[]) {
#endif

Ogre::Root *ogre;
Ogre::RenderWindow *window;
Ogre::SceneManager *sceneMgr;
Ogre::Camera *camera;
QuickGUI::Sheet* mSheet;
using QuickGUI::Rect;
using QuickGUI::Point;
using QuickGUI::Size;

// fire up an Ogre rendering window. Clearing the first two (of three) params will let us
// specify plugins and resources in code instead of via text file
ogre = new Ogre::Root("", "");


// This is a VERY minimal rendersystem loading example; we are hardcoding the OpenGL
// renderer, instead of loading GL and D3D9. We will add renderer selection support in a
// future article.

// I separate the debug and release versions of my plugins using the same "_d" suffix that
// the Ogre main libraries use; you may need to remove the "_d" in your code, depending on the
// naming convention you use
// EIHORT NOTE: All Ogre DLLs use this suffix convention now -- #ifdef on the basis of the _DEBUG
// define
#if defined(_DEBUG)
ogre->loadPlugin("RenderSystem_GL_d");
#else
ogre->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL");
#endif

Ogre::RenderSystemList *renderSystems = NULL;
Ogre::RenderSystemList::iterator r_it;

// we do this step just to get an iterator that we can use with setRenderSystem. In a future article
// we actually will iterate the list to display which renderers are available.
renderSystems = ogre->getAvailableRenderers();
r_it = renderSystems->begin();
ogre->setRenderSystem(*r_it);
ogre->initialise(false);

// load common plugins
#if defined(_DEBUG)
ogre->loadPlugin("Plugin_CgProgramManager_d");
ogre->loadPlugin("Plugin_OctreeSceneManager_d");
#else
ogre->loadPlugin("/usr/local/lib/OGRE/Plugin_CgProgramManager");
ogre->loadPlugin("/usr/local/lib/OGRE/Plugin_ParticleFX");
// ogre->loadPlugin("Plugin_OctreeSceneManager");
#endif

QuickGUI::registerScriptParser();
// load the basic resource location(s)
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
"resource", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
"resource/gui.zip", "Zip", "GUI");

Ogre::ResourceGroupManager::getSingleton().addResourceLocation("skins", "FileSystem", "GUI");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("skins/qgui", "FileSystem", "GUI");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("materials", "FileSystem", "GUI");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("materials/textures", "FileSystem", "GUI");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("fonts", "FileSystem", "GUI");


#if defined(WIN32)
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
"c:\\windows\\fonts", "FileSystem", "GUI");
#endif

Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("GUI");
// setup main window; hardcode some defaults for the sake of presentation
Ogre::NameValuePairList opts;
opts["resolution"] = "1024x768";
opts["fullscreen"] = "false";
opts["vsync"] = "false";

// create a rendering window with the title "CDK"
window = ogre->createRenderWindow("CDK", 1024, 768, false, &opts);

// since this is basically a CEGUI app, we can use the ST_GENERIC scene manager for now; in a later article
// we'll see how to change this
sceneMgr = ogre->createSceneManager(Ogre::ST_GENERIC);
camera = sceneMgr->createCamera("camera");
// Position it at 500 in Z direction
camera->setPosition(Ogre::Vector3(0,0,500));
// Look back along -Z
camera->lookAt(Ogre::Vector3(0,0,-300));

camera->setNearClipDistance(5);
Ogre::Viewport* vp = window->addViewport(camera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

// most examples get the viewport size to calculate this; for now, we'll just
// set it to 4:3 the easy way
camera->setAspectRatio((Ogre::Real)1.333333);

// this next bit is for the sake of the input handler
unsigned long hWnd;
window->getCustomAttribute("WINDOW", &hWnd);

// set up the input handlers
// Simulation *sim = new Simulation();
// InputHandler *handler = new InputHandler(sim, hWnd);
// sim->requestStateChange(SIMULATION);


// MY CODE
sceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
Ogre::Light* l = sceneMgr->createLight("MainLight");
l->setPosition(20,80,56);

QuickGUI::SkinSetManager::getSingleton().loadSkin("qgui", QuickGUI::SkinSet::IMAGE_TYPE_PNG, "GUI");
QuickGUI::GUIManager* mGUIManager = new QuickGUI::GUIManager(camera->getViewport());
mGUIManager->setSceneManager(sceneMgr);
mSheet = mGUIManager->getDefaultSheet();


QuickGUI::Button* loginButton = mSheet->createButton();
loginButton->setDimensions(Rect(100,420,200,42));
loginButton->setText("Login");

Ogre::SceneNode *playerNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Entity *playerModel = sceneMgr->createEntity("player", "Player.mesh");
playerNode->attachObject(playerModel);
playerNode->setPosition(0.0f,-20.0f,400.0f);

bool QUIT;
QUIT = false;
while (!QUIT)
{

// handler->capture();

// run the message pump (Eihort)
Ogre::WindowEventUtilities::messagePump();

ogre->renderOneFrame();
}

// clean up after ourselves
// delete handler;
// delete sim;
delete ogre;

return 0;
}


With the above code the program crashes loading skinTemplate.material.

Here's the backtrace:


Initialising resource group GUI
Parsing scripts for resource group GUI
Parsing script skinTemplate.material
ogretest: OgreGpuProgramManager.cpp:42: static Ogre::GpuProgramManager& Ogre::GpuProgramManager::getSingleton(): Assertion `ms_Singleton' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 47681428581440 (LWP 30313)]
0x00002b5dabebc765 in raise () from /lib/libc.so.6
(gdb) bt
#0 0x00002b5dabebc765 in raise () from /lib/libc.so.6
#1 0x00002b5dabebe1c0 in abort () from /lib/libc.so.6
#2 0x00002b5dabeb5c2f in __assert_fail () from /lib/libc.so.6
#3 0x00002b5daab17b47 in Ogre::GpuProgramManager::getSingleton () at OgreGpuProgramManager.cpp:42
#4 0x00002aaaab2d0f05 in Ogre::CgProgram::isSupported (this=<value optimized out>) at OgreCgProgram.cpp:477
#5 0x00002b5daab658ca in Ogre::MaterialSerializer::finishProgramDefinition (this=0x61c490) at OgreMaterialSerializer.cpp:3000
#6 0x00002b5daab67048 in Ogre::MaterialSerializer::parseScriptLine (this=0x61c490, line=@0x7fff00343280)
at OgreMaterialSerializer.cpp:2874
#7 0x00002b5daab67923 in Ogre::MaterialSerializer::parseScript (this=0x61c490, stream=@0x7fff003433a0,
groupName=<value optimized out>) at OgreMaterialSerializer.cpp:2736
#8 0x00002b5daac427c3 in Ogre::ResourceGroupManager::parseResourceGroupScripts (this=0x6191c0, grp=<value optimized out>)
at OgreResourceGroupManager.cpp:787
#9 0x00002b5daac431c2 in Ogre::ResourceGroupManager::initialiseResourceGroup (this=0x6191c0, name=@0x7fff00343810)
at OgreResourceGroupManager.cpp:119
#10 0x000000000040711d in main (argc=1, argv=0x7fff00343a58) at /home/libolt/Projects/ogretest/main.cpp:94



Any help is greatly appreciated.

Mike

kungfoomasta

27-11-2007 05:50:02

Sorry for all the trouble getting it up and running. :(


bool CgProgram::isSupported(void) const
{
if (mCompileError || !isRequiredCapabilitiesSupported())
return false;

StringVector::const_iterator i, iend;
iend = mProfiles.end();
// Check to see if any of the profiles are supported
for (i = mProfiles.begin(); i != iend; ++i)
{
CRASH-----> if (GpuProgramManager::getSingleton().isSyntaxSupported(*i))
{
return true;
}
}
return false;

}



GpuProgramManager& GpuProgramManager::getSingleton(void)
{
CRASH-----> assert( ms_Singleton ); return ( *ms_Singleton );
}


For some reason your GpuProgramManager instance is not being created. I'm not sure where this gets created, or by who. What video card do you have? Are you able to run the Ocean Demo?

[edit]
More tracking..

OgreGLRenderSystem.cpp : void GLRenderSystem::initGL(RenderTarget *primary):

// XXX Need to check for nv2 support and make a program manager for it
// XXX Probably nv1 as well for older cards
// GPU Program Manager setup
mGpuProgramManager = new GLGpuProgramManager();


I think the problem is that your card doesn't support Pixel Shader 1.1, or 2.0. I see both in use, in the material definitions tuan provided. I'm not sure what these do, they may be an integral part of the material rendering.

Here is some reference code:

if(GLEW_ARB_vertex_program)
{
mCapabilities->setCapability(RSC_VERTEX_PROGRAM);

// Vertex Program Properties
mCapabilities->setMaxVertexProgramVersion("arbvp1");
mCapabilities->setVertexProgramConstantBoolCount(0);
mCapabilities->setVertexProgramConstantIntCount(0);

GLint floatConstantCount;
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &floatConstantCount);
mCapabilities->setVertexProgramConstantFloatCount(floatConstantCount);

mGpuProgramManager->_pushSyntaxCode("arbvp1");
mGpuProgramManager->registerProgramFactory("arbvp1", createGLArbGpuProgram);
if (GLEW_NV_vertex_program2_option)
{
mCapabilities->setMaxVertexProgramVersion("vp30");
mGpuProgramManager->_pushSyntaxCode("vp30");
mGpuProgramManager->registerProgramFactory("vp30", createGLArbGpuProgram);
}


Basically the card is queried to see what vertex/fragment programs it can support, and for each one that is supported, a *program* is created and registered. In your case, the program is never created. I will look into what these fragment/vertex programs are doing..
[/edit]

[edit2]

Try removing the following material definitions from your ogre resource path:

1. qguiMaterialWithRTTBackground
2. quickgui/PositiontoUvVP
3. quickgui/PositiontoUvFP

These are used in the demo and not the library. I'm hoping that the problem is just when parsing the definitions (this is what is seems like), so removing them will stop the crash from occurring.
[/edit2]

libolt

27-11-2007 06:19:31

Sorry for all the trouble getting it up and running. :(


Don't worry, I'm too stubborn to give up until I have this fixed. :) I'm sure my code and possibly quickgui will be better for it.



bool CgProgram::isSupported(void) const
{
if (mCompileError || !isRequiredCapabilitiesSupported())
return false;

StringVector::const_iterator i, iend;
iend = mProfiles.end();
// Check to see if any of the profiles are supported
for (i = mProfiles.begin(); i != iend; ++i)
{
CRASH-----> if (GpuProgramManager::getSingleton().isSyntaxSupported(*i))
{
return true;
}
}
return false;

}



GpuProgramManager& GpuProgramManager::getSingleton(void)
{
CRASH-----> assert( ms_Singleton ); return ( *ms_Singleton );
}


For some reason your GpuProgramManager instance is not being created. I'm not sure where this gets created, or by who. What video card do you have? Are you able to run the Ocean Demo?


Yes the Ocean Demo works just fine, I just tried it.


[edit]
More tracking..

OgreGLRenderSystem.cpp : void GLRenderSystem::initGL(RenderTarget *primary):

// XXX Need to check for nv2 support and make a program manager for it
// XXX Probably nv1 as well for older cards
// GPU Program Manager setup
mGpuProgramManager = new GLGpuProgramManager();


I think the problem is that your card doesn't support Pixel Shader 1.1, or 2.0. I see both in use, in the material definitions tuan provided. I'm not sure what these do, they may be an integral part of the material rendering.


My card is a Nvidia Geforce 7950GT 512MB, I'm pretty sure it supports Pixel Shader 1.1 and 2.0 :)


Here is some reference code:

if(GLEW_ARB_vertex_program)
{
mCapabilities->setCapability(RSC_VERTEX_PROGRAM);

// Vertex Program Properties
mCapabilities->setMaxVertexProgramVersion("arbvp1");
mCapabilities->setVertexProgramConstantBoolCount(0);
mCapabilities->setVertexProgramConstantIntCount(0);

GLint floatConstantCount;
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &floatConstantCount);
mCapabilities->setVertexProgramConstantFloatCount(floatConstantCount);

mGpuProgramManager->_pushSyntaxCode("arbvp1");
mGpuProgramManager->registerProgramFactory("arbvp1", createGLArbGpuProgram);
if (GLEW_NV_vertex_program2_option)
{
mCapabilities->setMaxVertexProgramVersion("vp30");
mGpuProgramManager->_pushSyntaxCode("vp30");
mGpuProgramManager->registerProgramFactory("vp30", createGLArbGpuProgram);
}


Basically the card is queried to see what vertex/fragment programs it can support, and for each one that is supported, a *program* is created and registered. In your case, the program is never created. I will look into what these fragment/vertex programs are doing..
[/edit]


I see what you mean. That is certainly odd. I'm beginning to wonder if it's a driver bug or something misconfigured in my setup. I'm running Nvidia's AMD64 Linux driver revision 100.14.19 I don't have a lot of stuff that uses shaders.


[edit2]

Try removing the following material definitions from your ogre resource path:

1. qguiMaterialWithRTTBackground
2. quickgui/PositiontoUvVP
3. quickgui/PositiontoUvFP

These are used in the demo and not the library. I'm hoping that the problem is just when parsing the definitions (this is what is seems like), so removing them will stop the crash from occurring.
[/edit2]


Okay I will try this suggestion and see what happens.

Thanks for looking into this and helping.

Mike

libolt

27-11-2007 06:39:00


[edit2]
Try removing the following material definitions from your ogre resource path:

1. qguiMaterialWithRTTBackground
2. quickgui/PositiontoUvVP
3. quickgui/PositiontoUvFP

These are used in the demo and not the library. I'm hoping that the problem is just when parsing the definitions (this is what is seems like), so removing them will stop the crash from occurring.
[/edit2]


This fixed the problem. I'm guessing it's a driver issue. I have heard of others having issues with the 100.xx.xx series. I guess maybe it's my turn. :) I'll try reverting to 1.0.9755 tomorrow.

Thanks again for helping to solve the issue. :) Now I can get on to using QuicKGUI.

Keep up the good work.

Mike

kungfoomasta

27-11-2007 06:42:03

Thanks for looking into this and helping.

Of course! You've helped me so much already, its the least I could do. :)

Glad we found the culprit. Not sure of the solution, but the work around is trivial, at least for now. :wink:

Nice video card by the way. I was affraid you were using a really old card or something. :lol:

libolt

27-11-2007 07:22:04

I can always dig up a TNT2 or Ati Rage Pro, I've got them lying around somewhere and probably enough parts to cobble together a system. Then see what mayhem ensues.
:twisted:

Thanks again.

Mike