Skip to main content
gamedev.net
🔒 Locked

Closing GLUT windows

Started by adam17 Jan 6, 2004 at 5:43 PM 0 replies 400+ views
Original Post
adam17
adam17
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.
auLucifer
auLucifer
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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.