Archived

This topic is now archived and is closed to further replies.

adam17

Closing GLUT windows

Recommended Posts

i just made a small app that use glut to start the window. my app also takes control of the mouse so i cant close it easily. now i just need to know how to destroy the window with the keyboard.

Share this post


Link to post
Share on other sites
Use the glut function glutKeyboardFunc() with the name of the function calling on withing the brackets.

eg
void Keyboard(unsigned char key, int x, int y)
{
// use a case statement when you use multiple keys
if(key == 'q') exit(0);
}

int main( int argc, char* argv[] )
{
// all of your draw commands
glutKeyboardFunc(Keyboard);
// glutDisplayFunc here
glutMainLoop();
return 0;
}

Hope that helps
I would highly suggest you get a copy of the RedBook (OpenGL Programming Guide) which uses GLUT throughout the entire book.
Also download the GLUT specifications from opengl.org. That will help also.

[edited by - auLucifer on January 15, 2004 6:52:34 PM]

Share this post


Link to post
Share on other sites