I'm writing some OpenGL/Glut functions for visualize the results of my fluid dynamics code (all in C++). My data is stored in a matrix declared as global.
Here is the pseudo-code:
class fluid_dynamics{
//...
void set_conditions(); // Here is my opengl init function
void solve(); // This is an iterative loop with stop criteria
void IterateLoop();
}
On the solve() function I have a Loop.
void fluid_dynamics::solve(){
glutDisplayFunc(DisplayMatrix);
IterateLoop( // here I update my data each n-steps
// and I want to update my "scene" every time I do that.
);
glutMainLoop();
I'm quite new to OpenGL, but as far as I understand using glutPostRedisplay() inside IterateLoop() function will not perform a new image until the loop finish (because glutPostRedisplay() only set a flag and wait to an idle state), so...Any ideas? (1)
It's possible to employ glutIdleFunc? or glutTimerFunc pointing to IterateLoop splitting the Loop in small ones? (in that case, how it's supposed to pass a void pointer to a class member from inside the class? :S)
NOTE; I could re-write code so I accept every suggestion, but I think it's important to have all my fluid dynamics operations inside a class.
solve()function only do one iteration? Then you just solve and display in the draw loop? - Grimmy