The purpose of this post is to explain how to compile the code explained in the paper “Real-Time Fluid Dynamics for Games” by Jos Stam.
CLICK HERE to download the paper.
CLICK HERE to download code. The complete code consists of two files, source.c and demo.c. They are zipped in one file code.zip.
In order to compile the code, you first need to have a compiler. I use MinGW which you can get HERE. Please take the time to carefully follow the instructions provided at the MinGW site. Personally, I use something called Qt which is a nice way to create GUIs, the installation of which also installs MinGW.
The code by Jos Stam uses a think called GLUT. GLUT is an interface that allows you to easily use OpenGL to render graphics. GLUT is not open source, but there is an open source alternative to it called freeglut. I use GLUT. A great tutorial on how to set up GLUT with MinGW can be found HERE.
First unzip code.zip to any folder. Copy glut32.dll to the same folder. Open up windows command line and navigate your way to this folder.
We then create object files out of the source code files solver.c and demo.c:
gcc -c -o solver.o solver.c -I”D:\Dropbox\Code\GLUT\include”
gcc -c -o demo.o demo.c -I”D:\Dropbox\Code\GLUT\include”
The folder where you have put your GLUT files might of course not be the same as mine.
Finally, to generate an .exe file, we must link the two object files and tell the linker where our GLUT libraries are and which ones to use:
gcc -o demo.exe demo.o solver.o -L”D:\Dropbox\Code\GLUT\lib” -lglut32 -lopengl32 -lglu32 -WL,–subsystem,windows