using GLUT and calling an infinite loop routine won't work ?

I wrote a C program, using SDL for graphics, to plot periodic graphs. The plotting of the graph is done in an infinite WHILE loop - the SDL rendering statements are in line in the infinite loop. Now I want to do it using OpenGL and GLUT. The only way I can think to do this is to incorporate the infinite loop with the OpenGL rendering routine called by the GLUT timer function. So far I haven’t been able to do it. As I understand it many video games use an infinite loop. Any suggestions? TIA. Bill S.

If you’re using GLUT, the main loop (and the switch statement inside it) are provided for you, by glutMainLoop().

This calls the callbacks registered with glutDisplayFunc(), glutIdleFunc(), etc when appropriate.

If you want continuous animation, you would typically call glutPostRedisplay() at the end of the display function, or in a timer function.

glutMainLoop() is also a infinite while loop. When some massage like keybord, mouse etc toggle it the program will jump out of the while loop, when finish, it will return to the while loop again.
so that you can design your callback program, and in the main program to call them before glutMainLoop();