Handling Window and Input Events

After the window is created, but before you enter the main loop, you should register callback functions using the following routines. Callback functions are routines you write that you present to GLUT as a function pointer, and that GLUT will call when the right circumstances occur. You will specify certain callback functions once, and never change them throughout the execution of your program. Others, however, you may specify when a certain event occurs (like when a mouse button is pressed), and disable that callback function by specifying NULL (or zero) as the new callback function.

The most important routine is glutDisplayFunc(), which is where you will do all of your rendering in your application. It’s required ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.