You were already given 3 answers. And each of them did completely miss the actual problem (I added the same comment on each of those answers):
The problem you have is that 'glutPostRedisplay` is not actively displaying anything. All it does is setting some flag, that upon the next iteration of the event loop, the display function call be called. I.e. like this:
bool do_display = false;
void glutPostRedisplay()
{
do_display = true;
}
void glutMainLoop()
{
while(running) {
...
if( do_display ) call_display_callback();
do_display = false;
...
}
}
Setting that do_display
flag, will of course not do anything in a loop, other than reduantly setting it.
What you have to do is treating the idle
function itself as the loop body and incrementing the loop variable there. I.e.
float i = 190.0;
void anim_idle()
{
if( i >= 200 ) { glutIdleFunc(NULL); }
viewMatrix = glm::lookAt(
glm::vec3(i, 70.0f, 200.0f), // eye position
glm::vec3(0), // look at position
glm::vec3(0.0f, 1.0f, 0.0f)); // up vect0r
glutPostRedisplay();
i += 0.02;
}
Also you should not sleep there, so that the program stays interactive. Instead measure the time between iterations and adjust the increment by the time internval passed.