2013-07-11 56 views
0

這裏不能打開文件可以是代碼:與魔鬼

public void LoadTexture(string textureId, string path) 
    { 
     int devilId = 0; 
     Il.ilGenImages(1, out devilId); 
     Il.ilBindImage(devilId); // set as the active texture 

     if (!Il.ilLoadImage(path)) 
     { 
      System.Diagnostics.Debug.Assert(false, "Could not open file, [" + path + "]."); 
     } 
     // The files we'll be using need to be flipped before passing to OpenGL 
     Ilu.iluFlipImage(); 
     int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); 
     int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); 
     int openGLId = Ilut.ilutGLBindTexImage(); 

     System.Diagnostics.Debug.Assert(openGLId != 0); 
     Il.ilDeleteImages(1, ref devilId); 

     _textureDatabase.Add(textureId, new Texture(openGLId, width, height)); 
    } 

我越來越無法斷言,無法打開文件[face.tif]錯誤。我確信face.tif文件位於項目文件夾,解決方案文件夾,bin文件夾,bin \ debug文件夾中,但仍然無法打開它。

我正在嘗試遵循C#遊戲編程的書籍來製作嚴肅的遊戲。

回答

0

它正在尋找與您的代碼運行在同一目錄中的文件face.tif

什麼是設置path被傳入方法LoadTexture

+0

在Form1.cs我有一個_textureManager.LoadTexture( 「臉」,「 face.tif「); – Liam15

+0

文件'face.tif'與你的應用程序運行的地方('.exe')在哪裏? –

+0

它們都位於bin \ debug文件夾中。換句話說,它們在同一個文件夾中 – Liam15

-1

Form主類(例如:Form.cs),把這兩行構造頂部:

public Form1(){ 

    InitializeComponent(); 
    _openGLControl.InitializeContexts(); 
+1

確實「Ex:」是指「例如:」?請用反引號包裝所有代碼位,就像在我建議的編輯中一樣(我不確定所有的部分是因爲您是以很短的方式編寫的)。你確定OP很清楚「Form」是什麼,它的問題是什麼? – YakovL