periodically calling a function

I have a framework from a very simple OpenGL program, written the way I want for now from a software project structure perspective. However, I don’t know what’s the rendering rate of my program. I didn’t register any callback for glutTimerFunc(), so would it be safe to assume the rendering would refresh at the rate of the hardware (video card, display monitor, etc.)?

The reason that I’m asking this question is I would like to run a routine within a for loop or while loop like I used to before introducing OpenGL rendering routines into my project. In other words, after introducing the OpenGL GLUT related codes and after glutMainLoop function is called, I would still like to be able to execute the following in the background or just before rendering the points:

for(i = 0; i < until I want this loop to stop; i++)
myfunc(inputs, outputs);

 // other actions I want here

 // render the points


What would you suggest to do to ensure this happens with my logic? Is there a standard callback where I can call this generic function to calculate the outputs? Thanks.

Try FRAPS for a quick FPS info.


all you want is to call a function periodically using GLUT? If so, what is the problem with glutTimerFunc()? glutTimerFunc register a callback function and you can use it to get something called after some defined time.

In case you just want to get rid of glutMainLoop(), you can just try other toolkit, for example SDL. SDL makes use ot no such thing as a main loop function, neither it uses callback functions. You define your very own coded loop just like you said in the end of your post. SDL is not hard to learn at all.

For calculating FPS, you can just google a bit.

Thanks for pointing out SDL. I’m learning it right now as I speak. I was not just trying to call a function periodically using GLUT. I also wanted to render/update the new vertex buffer object contents after each of that computation function call. Once again, thanks for the suggestion.