close glut window

Does anyone know how to close a Glut opened window from a program without getting out of the program?

Thanx.

try…

glutDestroyWindow( int handle);

Thanx, i’ll try.

Sorry, but You now why I use glutDestroyWindow the program close the Window but give me the segmentation fault error? I must close something before? Thanks.

i’m not absolutely sure, but i guess you should remove any glutDisplayFunc (and other functions which access the gl context) before destroying the window.

Thanks, but how I can remove glutDisplayFunc? Thanks a lot.

i googled a bit around- it seems that a once registered display func cannot be removed.

you could define a global variable like this:

int window_valid = 1;

void destroy_window() {

 // whatever

 window_valid = -1;
}

void display_func() {

 if(window_valid == -1)
   return;

 // draw your stuff
}

by the way, you do you really want to destroy the window? if you only want it to disappear, you can also use glutHideWindow()

I have a similar problem. When I close the GLUT-window, I get an error, and the programm kills itself. Only If I dont start GLUT, I can close my application. Any idea?

Using a debugger, this crash is resolved in 2 minutes (: It’ll show you where there is a crap

Originally posted by Gollum:
Using a debugger, this crash is resolved in 2 minutes (: It’ll show you where there is a crap
You love debuggers, isn’t it :wink: