【问题标题】:Can't run scene using AssImp on OpenGl无法在 OpenGL 上使用 AssImp 运行场景
【发布时间】:2013-11-25 11:02:19
【问题描述】:

我正在使用 AssImp 解析一个简单的多维数据集(作为测试示例)以在 OpenGL 上使用。但是当 OpenGL 启动时,我看到了我的场景,里面有立方体,然后是我的 Nvidia 驱动程序上的这个错误:

http://nvidia.custhelp.com/app/answers/detail/a_id/3007

OpenGl 关闭,并且在我开始使用 AssImp 后总是发生这种情况。

我的 Nvidia 是 GeForce 9300M GS。 绘制立方体的代码很简单:

    #include "Object.h"

Object::Object(string filename){

    scene = importer.ReadFile(filename,aiProcess_CalcTangentSpace|aiProcess_Triangulate|aiProcess_JoinIdenticalVertices|aiProcess_SortByPType);

    if(!scene){
        cout << importer.GetErrorString();
    }

}

void Object::draw(){

    if(!scene)
        return;

    if(!scene->mNumMeshes){
        cout << "NO PRIMITIVES" << endl;
        return;
    }


    for(int i = 0; i < scene->mNumMeshes ; i++){
        for (int j = 0; j < scene->mMeshes[i]->mNumFaces ; j++)
        {
            glBegin(GL_TRIANGLES);

            glVertex3f(scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[0]].x,
                scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[0]].y,
                scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[0]].z);
            glVertex3f(scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[1]].x,
                scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[1]].y,
                scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[1]].z);
            glVertex3f(scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[2]].x,
                scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[2]].y,
                scene->mMeshes[i]->mVertices[scene->mMeshes[i]->mFaces[j].mIndices[2]].z);

            glEnd;
        }
    }
}

有没有人在使用 AssImp 的 Nvidia 驱动程序上遇到过这种崩溃?

我不知道问题可能是什么。我已经在这台计算机中多次使用 OpenGl,用更复杂的形状构建整个场景,但我从来没有得到过这个。

【问题讨论】:

  • 你用过调试器吗?它在哪一行崩溃?
  • 我有,我正在使用 Visual Studio,它没有说哪一行是崩溃,简单地关闭显示。

标签: c++ opengl crash nvidia assimp


【解决方案1】:

在双 for 循环中,您可能想要编写 glEnd(); 而不是 glEnd;(这是有效的 C++,但编译器会发出警告)

【讨论】:

  • 谢谢!由于它没有发出错误,所以我最终没有意识到它是错误的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多