Bacu
Bacu

Reputation: 539

OpenGL Superbible first program crashes

It doesn't run, obviously. Code is copied directly from the provided source. I put the libraries and headers where I was told. Running it results in some sort of crash.

I asked a few people to run it, they all said that it gave them an error concerning missing .dlls and didn't attempt to run the program, completely different from what's happening to me.

from the "x.exe has stopped working" dialog:

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

Build:

    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 ==========

Code in question:

    #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;
}

I asked a few people to run it, they all said that it gave them an error concerning missing .dlls and didn't attempt to run the program, completely different from what's happening to me.

Upvotes: 3

Views: 2183

Answers (4)

Benjamin Schnur
Benjamin Schnur

Reputation: 11

The LNK4098 warnings have to do with your runtime settings - in most cases I believe you can quash them by going into the project properties and changing Configuration Properties > C/C++ > Code Generation > Runtime Library from Multi-threaded Debug DLL to Multi-threaded Debug. (For the Debug configuration. The Release setting would change from Multi-threaded DLL to Multi-threaded.)

The LNK4099 warnings arise because the .pdb files are not present, as the warnings say. You can generate the .pdb files by recompiling the libraries from their source - make sure you compile the right version for each configuration (Debug or Release) and exclude the Debug versions from the Release build, and vice versa.

All of that said, these warnings aren't fatal. I prefer not to have warnings clogging up my error list, but the project should still compile when they are present.

Upvotes: 1

Bacu
Bacu

Reputation: 539

I chalk this one up to bad drivers.

Upvotes: 0

shybovycha
shybovycha

Reputation: 12275

Really confused with your code - GLUT and WGL in one project... Try using just glut as shown in these examples http://www.lighthouse3d.com/opengl/glut/ Worked perfectly on my Ubuntu laptop and Win7x64 desktop.

Upvotes: 0

karlphillip
karlphillip

Reputation: 93478

Actually, the info you provided show that the application was in fact compiled:

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

The rest of the messages were just warnings.

Upvotes: 4

Related Questions