GLUT crash

I’m using GLUT under windows and my program is crashing everytime I minimize the window. Is there something I’m missing when setting up GLUT? It has to be a problem with GLUT because even with a simple GL program I can get it to crash everytime when I minimize. Here’s how I setup GLUT:

glutInitWindowPosition(0, 0);
glutInitWindowSize(640, 480);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow(“Dan”);
glutDisplayFunc(ShowScreen);
glutReshapeFunc(ChangeSize);
glutVisibilityFunc(visible);
glutSpecialFunc(special);
glutKeyboardFunc(key);

Thanks

The only diffrence I see from how I init glut is that you have glutinitdisplaymode third and not first.

Change it to this:
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(0, 0);
glutInitWindowSize(640, 480);

Here is the one I am currently using on a program.

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
glutSetWindowTitle(“GLbase”);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutTimerFunc( 10, TimeEvent, 1);
glutMainLoop();
return 0;
}

Originally posted by dpgraves:
[b]I’m using GLUT under windows and my program is crashing everytime I minimize the window. Is there something I’m missing when setting up GLUT? It has to be a problem with GLUT because even with a simple GL program I can get it to crash everytime when I minimize. Here’s how I setup GLUT:

glutInitWindowPosition(0, 0);
glutInitWindowSize(640, 480);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow(“Dan”);
glutDisplayFunc(ShowScreen);
glutReshapeFunc(ChangeSize);
glutVisibilityFunc(visible);
glutSpecialFunc(special);
glutKeyboardFunc(key);

Thanks[/b]

even with a simple GL program I can get it to crash everytime when I minimize.

Then check your “visible” function. Chances are, if you take out the “glutVisibleFunc(visible);” line, your program won’t crash anymore. Check if you did something stoopid in there

this is not a bug related to the code you’ve posted, it’s a division by zero in your re-shape function.

Look for the line where you set the aspect ratio for a perspective projection and deal with the following statement :

width/height

and replace with :

(height == 0)?1 :(float)(width/height)

or something similar…

[This message has been edited by Rob The Bloke (edited 03-05-2002).]