Program crash, when I close the OpenGL window

I create a OpenGL window, which has the “normal Windows-XP red cross” on its upper right corner (to close/exit this window).

As soon as I do so, my programm crashes.
The same happens, when I want to close my program itself.

What can I do?

I tried exit(0); but sometimes it crashes also. I get this “do you want to send this error to microsoft” message then.

Any idea?

Can you give more details on your program and hardware setup ? like video card, drivers, etc
Are you using GLUT, or win32 calls, or whatever else ?
How do you handle closing events ?

I am using the following to get the thing running:


So I have a console-like windows (my application) and the OpenGL-window “Name” from above. Whatever I close -> Program crashes.

Use a debugger.

There is little we can do to help with the little information you’ve provided.
A ton of things could be causing the crash.

ensure you aren’t dereferencing an unitialized pointer, or deleting an already deleted pointer or…well, the list goes on and on.

Well, I am sure it has to do with glutMainLoop().
And so I hope, someone might have had the same problem.

I don`t have a problem to quit this application, when I did not turn OpenGL loose. As soon, as OpenGL is running, quiting does not work anymore.

Anyone an idea, better than “use a compiler, idiot” ?

awe, I wasn’t calling you an idiot :slight_smile: .

I figured since you were devoloping the app you had access to some debuf/diagnostic tools…that would have been the easiest way to rectify the issue.

Do the program print some messages or show some dialog when it crashes? I think the best way in your case is comment out most of parts of OpenGL codes and try to find which part causes the problem at application exit. It seems like you have problems with memory access and youe data rewrite some memory area and destroy one or more pointers…