這是我在spacesimulator上下載的導入3ds文件的程序,但是我把程序作為一個單獨的函數加入到我的工程后,就一直無法打開文件。調用時的寫法是:object.id_texture=LoadBitmap("spaceshiptexture.bmp"); 并且在messagebox彈窗顯示的也確實是spaceshiptexture.bmp,望高人指點迷津!char Load3DS (obj_type_ptr p_object, const char *p_filename){int i; //Index variable/* handle file stream */FILE *l_file; //File pointerunsigned short l_chunk_id; //Chunk identifierunsigned int l_chunk_lenght; //Chunk lenghtunsigned char l_char; //Char variableunsigned short l_qty; //Number of elements in each chunkunsigned short l_face_flags; //Flag that stores some face information/* fopen() "rb" means open a binary files & only read it */if ((l_file=fopen (p_filename, "rb"))== NULL){MessageBox(NULL,"model open failed", "Zetadeck",MB_OK | MB_ICONERROR);return 0; //Open the file}...}
1 回答

繁花如伊
TA貢獻2012條經驗 獲得超12個贊
沒看懂你的問題,調用時的寫法是:object.id_texture=LoadBitmap("spaceshiptexture.bmp");與Load3DS有什么關系?
不過文件打開失敗后會設置errno,你可以檢查下errno的值來看是什么問題。
常見的一些問題包括給的是文件相對路徑而不是全路徑,有時候路徑問題會影響?;蛘呤俏募谄渌胤奖淮蜷_并且deny read。比如這個文件本身是你的程序寫出來的,但是你的程序忘了close這個文件。
- 1 回答
- 0 關注
- 115 瀏覽
添加回答
舉報
0/150
提交
取消