Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL Superbible first program crashes

Tags:

c++

c

opengl

glut

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.

like image 413
Bacu Avatar asked Jul 24 '26 11:07

Bacu


1 Answers

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.

like image 96
karlphillip Avatar answered Jul 26 '26 02:07

karlphillip



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!