[SOLVED] Issue with getSceneManager()
Posted: Sat May 04, 2019 2:04 am
Hi all, I have recently been on the lookout for a 3D rendering engine and have found Irrlicht. It's appealing to me and I'm trying it out to see if it suits my needs. Accordingly, I've started my journey with the first tutorial (http://irrlicht.sourceforge.net/docu/example001.html).
I've followed the tutorial and understood everything successfully.
However, when I compiled the complete code and executed it, it crashed after the program created the Irrlicht device.
Using a debugger, I was able to identify that a segmentation fault occurred on this line of code:
And using the watch list I noticed something funny about the addresses stored in the smgr and mesh pointers:
(The node pointer is as such because it hasn't been defined yet, but I suppose y'all would know that).
(This is just a specific example: debugging multiple times results in different addresses but the same 'effect' of the smgr appearing 'out of sync' still occurs).
From this, I'm quite certain that the address stored in smgr doesn't actually point to the scene manager. I'm guessing that there is something wrong with this line of code, where I attempt to retrieve the address pointing to the scene manager, but I have no clue why it is acting inconsistently.
I know for a fact that the other two calls work correctly because I removed the mesh and scene manager components from the program and it executes as expected (without the mesh parts ofc) with no adverse side effects.
I have searched the forum but I haven't found anything that solved this specific problem.
Here is the full code which I typed up, in Code::Blocks, following the tutorial:
My questions
1. Why is the getSceneManager() method returning what appears to be a faulty address?
2. What exactly does the <onexit+58> portion of the mesh pointer's address mean?
3. Is the 'faulty' scene manager address the root cause of the segmentation fault, or is it something else entirely?
Thanks for your time
I've followed the tutorial and understood everything successfully.
However, when I compiled the complete code and executed it, it crashed after the program created the Irrlicht device.
Using a debugger, I was able to identify that a segmentation fault occurred on this line of code:
Code: Select all
IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
Code: Select all
Locals Values
device 0x29f3a08
driver 0x29f5978
smgr 0xf32a288
guienv 0x29f76d0
mesh 0x754f6bba <onexit+58>
node 0xfffffffe
(This is just a specific example: debugging multiple times results in different addresses but the same 'effect' of the smgr appearing 'out of sync' still occurs).
From this, I'm quite certain that the address stored in smgr doesn't actually point to the scene manager. I'm guessing that there is something wrong with this line of code, where I attempt to retrieve the address pointing to the scene manager, but I have no clue why it is acting inconsistently.
Code: Select all
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager(); //<- this line
IGUIEnvironment* guienv = device->getGUIEnvironment();
I have searched the forum but I haven't found anything that solved this specific problem.
Here is the full code which I typed up, in Code::Blocks, following the tutorial:
Code: Select all
#include "include/irrlicht.h"
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
int main() {
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(640, 480), 16, false, false, false, 0);
if (!device) {return 1;}
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World! This is the Irrlicht engine demo!", rect<s32>(10, 10, 260, 22), true);
IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
if (!mesh) {
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
if (node) {
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(EMAT_STAND);
node->setMaterialTexture(0, driver->getTexture("sydney.bmp"));
}
smgr->addCameraSceneNode(0, vector3df(0, 30, -40), vector3df(0, 5, 0));
while (device->run()) {
driver->beginScene(true, true, SColor(255, 100, 101, 140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
1. Why is the getSceneManager() method returning what appears to be a faulty address?
2. What exactly does the <onexit+58> portion of the mesh pointer's address mean?
3. Is the 'faulty' scene manager address the root cause of the segmentation fault, or is it something else entirely?
Thanks for your time
