You have to register the function that handles the callback function to be executed when a button is mouse pressed during your display() loop. This has to be done before running the main loop, when you are initialising everything that GLUT requires.
glutMouseFunc (MouseButton);
Then you need to define the callback function itself, for example, something like this.
void MouseButton(int button, int state, int x, int y)
{
// Respond to mouse button presses.
// If button1 pressed, mark this state
if (button == GLUT_LEFT_BUTTON)
{
g_bButton1Down = (state == GLUT_DOWN) ? TRUE : FALSE;
}
}
Note that g_bButton1Down is the global variable that you have to check to see if the mouse button is being pressed or not inside your main display() GLUT loop.
Take a loop at the glutMouseFunc specifications.