Animation using OpenGL (& GLUT)

Hello,

Please copy adonev@princeton.edu on any replies to this.

I have been looking at OpenGL and GLUT internals recently, and the Fortran 90 f90gl
interface by William Mitchell. My goal is to animate a molecular dynamics
simulation in real-time. Using GLUT, I guess one way to do it would be to
make the Idle callback function a timestepper, and then GLUT will advance
the time whenever the graphics engine is idle, thus keeping the speed of
the simulation and the animation in sinc. My confusion comes because of
two things:

  1. The GLUT main loop says “never to return”. I cannot understand this.
    Something must eventually return. I mean, you plot something, and then you
    need to clean up memory, close files, etc. If you can not put any code
    after the call to the GLUT main loop, how are you to do this?

  2. The GLUT callbacks do not even pass a void* argument back to the called
    procedure. How am I then to save some state data. This is a classical
    problem in Reverse Communication in Fortran and I cannot believe the GL
    people did not even think of allowing a void pointer there so one can pass
    a pointer to a data-structure holding info necessary for the plotting.

Has anyone had any experience with real-time animation of MD with OpenGL?
Any clues about how to combine scientific computation with GL animation are appreciated.

Thanks,
Aleksandar

GLUT is a tool kit to help create openGL programs fast and easy, but glut is not required to create a openGL program. you can create your own windowing and timmer routines that do not have the limitaion of GLUT.

There are some exit hacks out there for GLUT because of termination from mainloop does not return to main, just exits the program.

Here is something you could do with GLUT would be to create an exit routine which is called from keyboard.

case: ESC
glIdleFunc( NULL ); // Turn off Idle routine or any other time related call backs.
exit_clean_up(); // Close files, clear memory etc.
exit 0;
break;

As for the data, could load it from a file, or create some sort of file stream from one application to another.

Originally posted by donev:
[b]Hello,

Please copy adonev@princeton.edu on any replies to this.

I have been looking at OpenGL and GLUT internals recently, and the Fortran 90 f90gl
interface by William Mitchell. My goal is to animate a molecular dynamics
simulation in real-time. Using GLUT, I guess one way to do it would be to
make the Idle callback function a timestepper, and then GLUT will advance
the time whenever the graphics engine is idle, thus keeping the speed of
the simulation and the animation in sinc. My confusion comes because of
two things:

  1. The GLUT main loop says “never to return”. I cannot understand this.
    Something must eventually return. I mean, you plot something, and then you
    need to clean up memory, close files, etc. If you can not put any code
    after the call to the GLUT main loop, how are you to do this?
  1. The GLUT callbacks do not even pass a void* argument back to the called
    procedure. How am I then to save some state data. This is a classical
    problem in Reverse Communication in Fortran and I cannot believe the GL
    people did not even think of allowing a void pointer there so one can pass
    a pointer to a data-structure holding info necessary for the plotting.

Has anyone had any experience with real-time animation of MD with OpenGL?
Any clues about how to combine scientific computation with GL animation are appreciated.

Thanks,
Aleksandar[/b]

google search for “Open Producer”, a nice and quickly developing C++ API to replace a need for GLUT and allows you control of the rendering loop.

cheers