我想實現一個程序,可以使用Assimp(link of Assimp)將3D模型加載到OpenGL中。程序在使用Assimp編譯和執行Qt5項目時崩潰了
我的Qt版本是5.3.2。 我使用Qt Creator和修改.pro
文件導入Assimp庫:
INCLUDEPATH += H:\Study\assimp-3.1.1-win-binaries\assimp-3.1.1-win-binaries\include\assimp
LIBS += -lH:\Study\assimp-3.1.1-win-binaries\assimp-3.1.1-win-binaries\lib32\assimp
然後我試着在我的程序讀取box.obj
:
#include <scene.h>
#include <postprocess.h>
#include <Importer.hpp>
int main(){
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile("box.obj", NULL);
if (!scene)
{
qDebug() << "Error loading file: (assimp:) " << importer.GetErrorString();
return false;
}
.....// Other code to create a window
return 0;
}
然後編譯完成沒有錯誤。 然後程序剛剛啓動後崩潰。
Starting G:\QtProject\QtTest\build-MyOpenGL-Desktop_Qt_5_3_MSVC2010_OpenGL_32bit-Debug\debug\MyOpenGL.exe...
G:\QtProject\QtTest\build-MyOpenGL-Desktop_Qt_5_3_MSVC2010_OpenGL_32bit-Debug\debug\MyOpenGL.exe crashed
我嘗試調試但斷點看起來不起作用。
我刪除一些代碼,只需要聲明scene
:
#include <scene.h>
#include <postprocess.h>
#include <Importer.hpp>
int main(){
//Assimp::Importer importer;
const aiScene* scene; // = importer.ReadFile("box.obj", NULL);
/*if (!scene)
{
qDebug() << "Error loading file: (assimp:) " << importer.GetErrorString();
return false;
}*/
.....// Other code to create a window
return 0;
}
程序可以再次運行!
我現在很困惑。誰能幫我?
我的編譯器是微軟的Visual C++編譯器10.0 – Paler 2014-11-06 13:42:34