Executable runs, but not when run from command line...

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
Concrete Pants
Posts: 2
Joined: Sat Jan 08, 2011 1:33 am

Executable runs, but not when run from command line...

Post by Concrete Pants »

Hello! I'm on Ubuntu 10.4 running irrlicht with code blocks, I followed the tutorials for getting irrlicht to compile in code blocks under linux and everything went fine. Simple scripts compile and run fine but when i tried to add a mesh things went a little odd.

Code: Select all

#include <irrlicht.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

int main(int argc, char** argv)
{
    IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(640, 480), 16, false, false, false, 0);

    device->setWindowCaption(L"Second Run");

    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();

    guienv->addStaticText(L"Box", rect<int>(10,10,200,22), true);

    IAnimatedMesh* mesh = smgr->getMesh("../../resources/sydney.md2");
    IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

    if (node)
    {
        node->setMaterialFlag(EMF_LIGHTING, false);
        node->setFrameLoop(0, 310);
        node->setMaterialTexture( 0, driver->getTexture("../../resources/sydney.bmp"));
    } else {
        device->drop();
        return 1;
    }

    smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

    while(device->run())
    {
        driver->beginScene(true, true, SColor(0,200,200,200));

        smgr->drawAll();
        guienv->drawAll();

        driver->endScene();
    }

    device->drop();
    return 0;
}
This is one of the example scripts, it compiles fine but when it tries to run it...

Code: Select all

Irrlicht Engine version 1.7.2
Linux 2.6.35-24-generic #42-Ubuntu SMP Thu Dec 2 01:41:57 UTC 2010 i686
Creating X window...
Visual chosen: : 41
Using renderer: OpenGL 3.3.10237
ATI Radeon 3100 Graphics : ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
GLSL version: 3.3
Could not load mesh, because file could not be opened: : ../../resources/sydney.md2
However, when I go into bin/debug and run the executable it works fine and the model shows, I can open a terminal and launch it in there and it will again complain about not finding the model.

I had my friend, who has been using irrlicht for a year now, to have a look and he couldn't find anything out of place. So we're rather confused as to what is going. Any help or ideas would be great, thanks
macron12388
Posts: 126
Joined: Wed Sep 29, 2010 8:23 pm

Post by macron12388 »

I don't have much experience, but I think since the paths you set to the modals are static, whichever directory the program runs from, it tries to use the path relative to that location.

Try to set a more absolute path ( i.e. C:/path/path/file.file ), if it works, then that above paragraph states the problem. I ran into this when running from my IDE, and when running from the /bin directory.

EDIT: If that is the problem, look around for a setting, I forgot what setting I changed to solve it myself.... sorry....
Concrete Pants
Posts: 2
Joined: Sat Jan 08, 2011 1:33 am

Post by Concrete Pants »

Very good! that was the problem, works fine now when running from the ide and the bin folder. Haven't yet found the option to set to relative, but still looking. Thanks again!
Post Reply