OpenGL window immediately closes with error -1073740777 (0xc0000417)

0

I'm using Visual Studio 2013 and OpenGL to create a simulation. Ideally, the window that I'm creating should stay open so that I can make changes using the keys and I can view a different result on the same window. But the window closes immediately after it launches with error code

program.exe' has exited with code -1073740777 (0xc0000417)

I did some debugging and tried commenting on various lines and saw that if I made 'glutSwapBuffers()' as a comment, the window stays open but empty.

Can someone please shed any light on this?

void keyboard (unsigned char key, int x, int y)
{
 switch (key)
 {
    case 'r': case 'R':
    if (filling==0)
    {
        glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); 
        filling=1;
    }
    else
    {
        glPolygonMode (GL_FRONT_AND_BACK, GL_POINT); 
        filling=0;
    }
    break;
    case 27:
    exit(0);
    break;
 }
}

.

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
glMatrixMode(GL_MODELVIEW); 
glLoadIdentity(); 
glRotatef(-90,0.0,1.0,0.0); 
glRotatef(-90,1.0,0.0,0.0); 

rotation_x = rotation_x + (rotation_x_increment - rotation_x)/50;
rotation_y = rotation_y + (rotation_y_increment - rotation_y)/50;
rotation_z = rotation_z + rotation_z_increment;

if (rotation_x > 359) rotation_x = 0;
if (rotation_y > 359) rotation_y = 0;
if (rotation_z > 359) rotation_z = 0;

if(rotation_x_increment > 359) rotation_x_increment = 0;
if(rotation_y_increment > 359) rotation_y_increment = 0;
if(rotation_z_increment > 359) rotation_z_increment = 0;

glRotatef(rotation_x,1.0,0.0,0.0); 
glRotatef(rotation_y,0.0,1.0,0.0);
glRotatef(rotation_z,0.0,0.0,1.0);

glTranslatef(x_translate,0.0,0.0);
glTranslatef(0.0,y_translate,0.0);
glTranslatef(0,0,z_translate); 

glFlush(); // This force the execution of OpenGL commands
glutSwapBuffers(); 
glFinish();
}

.

int main(int argc, char **argv)
{
IntroDisplay();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(screen_width,screen_height);
glutInitWindowPosition(0,0);
glutCreateWindow("Ultrasonic Testing");
glutDisplayFunc(display);
glutIdleFunc(display);
glutReshapeFunc (resize);
glutKeyboardFunc (keyboard);
glutSpecialFunc (keyboard_s);
glutMouseFunc(mouse);
glutMotionFunc(mouseMove);
init();
glutMainLoop();
return 0;
}
c++
visual-studio
opengl
asked on Stack Overflow Jul 7, 2016 by Rahul K • edited Jul 7, 2016 by Rahul K

2 Answers

0

Did you try compiling and running an absolutely minimal, bare bones program that does nothing except creating a window with GLUT, registering a display function that just clears and swaps the buffers and that's it. I.e. this

#include <GL/glut.h>
static void display(void)
{
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    glutSwapBuffers();
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutCreateWindow("test");
    glutDisplayFunc(display);
    glutIdleFunc(glutPostRedisplay);
    glutMainLoop();
    return 0;
}

My guess at the cause of your troubles is, that some library you're using was built with a different compiler than the one you're using and differences in the expected runtimes cause some hickups for you. If the minimal program given above crashes, then this is the most likely cause.

Note that in your code the calls to glFinish and glFlush are superfluous, because flushing and finishing is implied by a buffer swap. Also it's usually not a good idea to register the display function as GLUT idle handler; register glutPostRedisplay instead if you need a continuous display update.

answered on Stack Overflow Jul 7, 2016 by datenwolf
0

The problem was something to do with my drivers. It worked fine after I reinstalled everything.

I think it's because swap function also depends on the system and not the just the library. I read that somewhere.

answered on Stack Overflow Jul 15, 2016 by Rahul K

User contributions licensed under CC BY-SA 3.0