2011-01-19 20 views
4

私はIrrlichtを使ってゲームを書いています。そして私には問題があります。Irrlichtが間違ったパスのファイルを探しています

私は/home/m4tx/Projects/Discoverer/Discoverer/bin/Debug/のゲームを持っており、/home/m4tx/Projects/Discoverer/Discoverer/bin/Debug/media/のモデルです。それを修復する方法...

#include <irrlicht/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(video::EDT_OPENGL, dimension2d<u32>(640, 480), 32, 
    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 OpenGL!", 
    rect<s32>(10,10,260,22), true); 

IAnimatedMesh* mesh = smgr->getMesh("./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; 
} 

しかしイルリヒトだけ/home/m4tx/中のモデルを探している:私は最初のイルリヒトの例からコードを変更しましたか?

+0

あなたはどのようにプログラムを呼びますか?起動時に作業ディレクトリとは何ですか? –

+0

プログラムの作業ディレクトリは '/ home/m4tx/Projects/Discoverer/Discoverer /'ですが、/ media /ディレクトリにもすべての必須ファイルがあります。私は '/ home/m4tx/Projects/Discoverer/Discoverer/bin/Debug /'でも試しましたが、うまくいきません... – m4tx

+0

なぜそれが動作しないのですか?私はCode :: BlocksやDolphin(ファイルマネージャ)から起動していますが、それは動作しません。私はターミナルやbashスクリプトから起動しています。 – m4tx

答えて

3

作業ディレクトリを正しく取得する必要があります。

コードのデバッグ行は、現在のパスを表示するか、ログに記録するのが良いでしょう。 私は通常それをメインの最初の行に入れました。

<Option working_dir="." /> 

し、必要に応じて変更します。

#include <unisdt.h> 
#include <stdlib.h> 

char cwd[1024] = ""; 
getcwd(cwd, 1024); 
printf("Current path: %s\n", cwd); 

はまたのために

表情を提出あなたのコードブロックのプロジェクトで確認してください。

http://wiki.codeblocks.org/index.php?title=Project_file#Working_directory

関連する問題