Page 1 of 1

smgr->getMesh problem (runtime error)

Posted: Thu Jul 06, 2017 11:58 am
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

Re: smgr->getMesh problem (runtime error)

Posted: Thu Jul 06, 2017 12:09 pm
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;
}
 

Re: smgr->getMesh problem (runtime error)

Posted: Thu Jul 06, 2017 1:03 pm
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.

Re: smgr->getMesh problem (runtime error)

Posted: Thu Jul 06, 2017 10:32 pm
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.

Re: smgr->getMesh problem (runtime error)

Posted: Fri Jul 07, 2017 1:07 pm
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?

Re: smgr->getMesh problem (runtime error)

Posted: Sun Jul 09, 2017 2:06 am
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

Re: smgr->getMesh problem (runtime error)

Posted: Mon Jul 10, 2017 1:14 pm
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?

Re: smgr->getMesh problem (runtime error)

Posted: Tue Jul 11, 2017 11:27 am
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).