OpenGL Superbible第一个程序崩溃

时间:2010-12-11 01:46:30

标签: c++ c opengl glut

显然,它没有运行。代码直接从提供的源复制。我把库和标题放在我被告知的地方。运行它会导致某种崩溃。

我问了几个人来运行它,他们都说它给了他们关于丢失.dlls的错误,并没有尝试运行程序,完全不同于我发生的事情。

来自“x.exe已停止工作”对话框:

Problem signature:
  Problem Event Name:   BEX
  Application Name: OpenGLtutorialCh2.exe
  Application Version:  0.0.0.0
  Application Timestamp:    4d02d634
  Fault Module Name:    StackHash_0a9e
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   00000000
  Exception Offset: 00000000
  Exception Code:   c0000005
  Exception Data:   00000008
  OS Version:   6.1.7600.2.0.0.256.48
  Locale ID:    1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

构建

    1>------ Rebuild All started: Project: OpenGLtutorialCh2, Configuration: Debug Win32 ------
1>  triangle.cpp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>gltools.lib(GLBatch.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLBatch.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>gltools.lib(glew.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(glew.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>gltools.lib(GLShaderManager.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLShaderManager.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>gltools.lib(GLTools.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLTools.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>gltools.lib(GLTriangleBatch.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLTriangleBatch.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>gltools.lib(GLBatch.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLBatch.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>gltools.lib(glew.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(glew.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>gltools.lib(GLShaderManager.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLShaderManager.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>gltools.lib(GLTools.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLTools.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>gltools.lib(GLTriangleBatch.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLTriangleBatch.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
1>  OpenGLtutorialCh2.vcxproj -> C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\OpenGLtutorialCh2.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

有问题的代码:

    #include <GLTools.h>
#include <GLShaderManager.h>

#ifdef __APPLE__
#include <glut/glut.h>
#else
#define FREEGLUT_STATIC
#include <GL/glut.h>
#endif

GLBatch triangleBatch;
GLShaderManager shaderManager;


///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
{
    glViewport(0,0,w,h);
}

///////////////////////////////////////////////////////////////////////////////
// This function does any needed initialization on the rendering context.
// This is the first opportunity to do any OpenGL related tasks.
void SetupRC()
{
    glClearColor(0.0f,0.0f,1.0f,1.0f);

    shaderManager.InitializeStockShaders();

    GLfloat vVerts[]= {
        -0.5f,  0.0f,   0.0f,
        0.5f,   0.0f,   0.0f,
        0.0f,   0.5f,   0.0f };

    triangleBatch.Begin(GL_TRIANGLES, 3);
    triangleBatch.CopyVertexData3f(vVerts);
    triangleBatch.End();
}

///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
{
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    GLfloat vRed[] = {1.0f, 0.0f, 0.0f, 1.0f};
    shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
    triangleBatch.Draw();
    glutSwapBuffers();
}

///////////////////////////////////////////////////////////////////////////////
// Main entry point for GLUT based programs
int main(int argc, char* argv[])
{
    gltSetWorkingDirectory(argv[0]);

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
    glutInitWindowSize(800,600);
    glutCreateWindow("Triangle");
    glutReshapeFunc(ChangeSize);
    glutDisplayFunc(RenderScene);

    GLenum err = glewInit();
    if (GLEW_OK != err) {
        fprintf(stderr, "GLEW ERROR: %s\n", glewGetErrorString(err));
        return 1;
    }

    SetupRC();
    glutMainLoop();
    return 0;
}

我问了几个人来运行它,他们都说它给了他们关于丢失.dlls的错误,并没有尝试运行程序,完全不同于我发生的事情。

4 个答案:

答案 0 :(得分:4)

实际上,您提供的信息表明该应用程序实际上已编译:

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

其余消息只是警告。

答案 1 :(得分:1)

LNK4098 警告与您的运行时设置有关 - 在大多数情况下,我相信您可以通过进入项目属性并更改配置属性&gt;来撤消它们。 C / C ++&gt;代码生成&gt;运行时库多线程调试DLL 多线程调试。 (对于Debug配置.Release设置将从多线程DLL 更改为多线程。)

出现 LNK4099 警告,因为.pdb文件不存在,如警告所示。您可以通过从源代码重新编译库来生成.pdb文件 - 确保为每个配置(调试或发布)编译正确的版本,并从发布版本中排除调试版本,反之亦然。

所有这些都说,这些警告不是致命的。我不希望警告会阻塞我的错误列表,但项目在存在时仍应编译。

答案 2 :(得分:0)

真的与你的代码混淆 - 在一个项目中使用GLUT和WGL ...尝试使用过剩,如这些例子中所示http://www.lighthouse3d.com/opengl/glut/ 在我的Ubuntu笔记本电脑和Win7x64桌面上完美运行。

答案 3 :(得分:0)

我把这个问题归咎于坏司机。