smgr->getMesh problem (runtime error)

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
sajuukthanatoskhar
Posts: 4
Joined: Thu Jul 06, 2017 11:36 am

smgr->getMesh problem (runtime error)

Post by sajuukthanatoskhar »

Hi

I am just starting Irllicht and I am working through the tutorials.

However, in http://irrlicht.sourceforge.net/docu/example001.html at line :

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");

This seems to hang the program and Windows cites a buffer overrun. If I remove that line and all relevant lines, the program runs with a window and the label being present.

I have tried the following things

a) ran getmesh on one of my own models
b) ran getmesh in tutorial 2
c) input an absolute reference to where 'sydney.md2' is located

None of these things show the respective model and the program hangs with a windows error 0xC0000005.

http://i.imgur.com/mCP74WQ.png

System details
1. Windows 7 Professional 64 bit
2. Nvidia GTX1060
3. Being Compiled in CodeBlocks.

Solutions that I will try

1. Updating graphics drivers
2. Turning off Data Execution Prevention (DEP) - Didn't work
sajuukthanatoskhar
Posts: 4
Joined: Thu Jul 06, 2017 11:36 am

Re: smgr->getMesh problem (runtime error)

Post by sajuukthanatoskhar »

Code is as follows

Code: Select all

 
#include <iostream>
#include <irrlicht.h>
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
int main()
{
        IrrlichtDevice *device =
        createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
            false, false, false, 0);
    if(!device) return 1;
 
    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
    gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
 
    guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
        rect<s32>(10,10,260,22), true);
 
    IAnimatedMesh* mesh = smgr->getMesh("B:\SDK\irrlicht-1.8.4\irrlicht-1.8.4\media\sydney.md2");
//    if (!mesh)
//    {
//        device->drop();
//        return 1;
//    }
//    IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
//    if (node)
//    {
//        node->setMaterialFlag(EMF_LIGHTING, false);
//        node->setMD2Animation(scene::EMAT_STAND);
//        node->setMaterialTexture( 0, driver->getTexture("../../media/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;
}
 
MartinVee
Posts: 139
Joined: Tue Aug 02, 2016 3:38 pm
Location: Québec, Canada

Re: smgr->getMesh problem (runtime error)

Post by MartinVee »

Not sure that it's actually the culprit, but in your screenshot, you seem to have forgotten to escape the '\' character in your path.

Try this :

Code: Select all

 
IAnimatedMesh* mesh = smgr->getMesh("B:\\SDK\\irrlicht-1.8.4\\irrlicht-1.8.4\\media\\sydney.md2");
 
If that doesn't fix it, try to put a breakpoint at the getMesh line, and check the values of driver and smgr, to be sure they're not NULL.
sajuukthanatoskhar
Posts: 4
Joined: Thu Jul 06, 2017 11:36 am

Re: smgr->getMesh problem (runtime error)

Post by sajuukthanatoskhar »

MartinVee wrote:Not sure that it's actually the culprit, but in your screenshot, you seem to have forgotten to escape the '\' character in your path.

Try this :

Code: Select all

 
IAnimatedMesh* mesh = smgr->getMesh("B:\\SDK\\irrlicht-1.8.4\\irrlicht-1.8.4\\media\\sydney.md2");
 
If that doesn't fix it, try to put a breakpoint at the getMesh line, and check the values of driver and smgr, to be sure they're not NULL.

I wouldn't think it would cause a problem...
In any case, that didn't work either. driver/smgr weren't NULL either.
MartinVee
Posts: 139
Joined: Tue Aug 02, 2016 3:38 pm
Location: Québec, Canada

Re: smgr->getMesh problem (runtime error)

Post by MartinVee »

That could indeed have been the problem, because the '\' character is used for the C/C++ escape sequence to represent special characters. More on that here and here.

Now, back to your problem...

What is the rest of the 0xC0000005 error? Is it a read of write access violation?

Can you paste the call stack of the program when the 0xC0000005 happens?
sajuukthanatoskhar
Posts: 4
Joined: Thu Jul 06, 2017 11:36 am

Re: smgr->getMesh problem (runtime error)

Post by sajuukthanatoskhar »

A segfault occurs there.

Image
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()
#2 0x0040154e in main () at B:\irrlicht\basicstart\main.cpp:27
B:\irrlicht\basicstart\main.cpp:27:711:beg:0x40154e
At B:\irrlicht\basicstart\main.cpp:27
#2 0x0040154e in main () at B:\irrlicht\basicstart\main.cpp:27
B:\irrlicht\basicstart\main.cpp:27:711:beg:0x40154e
I didn't read that i had a segfault - now I am getting somewhere! I will keep you updated!

Similar problem in linux(?): http://irrlicht.sourceforge.net/forum/v ... =1&t=48159
MartinVee
Posts: 139
Joined: Tue Aug 02, 2016 3:38 pm
Location: Québec, Canada

Re: smgr->getMesh problem (runtime error)

Post by MartinVee »

Hum, the problem seems to happen inside Irrlicht.dll...

Try Christian Clavet's solution in the post you linked and see if it fixes the problem.

Are you sure you're linking with the same library version as the source files?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: smgr->getMesh problem (runtime error)

Post by CuteAlien »

Did you compile Irrlicht yourself? If not - do so when using Code::Blocks. It comes with a code::blocks project file (in Irrlicht/source). So basically just open that one and compile once and you get a new dll.
Btw, for using pathes in c++ it's often easier to work with forward slashes '/' as those don't have to be escaped. Windows can handle that as well (and on Unix it's even the only way to write pathes).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply