So I am trying to read sensor data from an IMU and update angles accordingly. I open the sensor data file, read line by line, convert quaternion to rotations and then update my model. The problem is that when calling the glutPostRedisplay() from the while loop the loop continues while glutPostRedisplay() operates in paralell. This makes it appear that everything happens instantly. What I want to do is to force the program to halt until the display is updated.
I can’t think of another way to do this because I don’t want to constantly open and close a file or keep track of where in the file I currently am. It would be easier if I could just read the line, process it, then force OpenGL to render, then read the next line etc.
Does anyone have any suggestions?
Note: Currently the while loop fully executes by the time I am able to render. I have tried using glutSwapBuffers() directly after the glutPostRedisplay()
GLUT doesn’t work that way. You will have to stop your loop and return from whatever function you want in order for GLUT to issue a rendering command. Generally you put this kind of stuff in an idle func.
Or you could use GLFW, which allows you to have ownership of the rendering loop. Or you could use FreeGLUT’s
glutMainLoopEvent, which allows you to have ownership of the rendering loop (though you need a bit of code rewriting to make this work).