High performance OpenGL fluid solver in C++
Switch branches/tags
Nothing to show
Clone or download
agrif fixed shader compile error on nvidia GTX580, linux driver 310.19
error before fix:
0(34) : error C7011: implicit cast from "int" to "uint"
Latest commit 9a4fe4a Aug 2, 2013
Failed to load latest commit information.
src fixed shader compile error on nvidia GTX580, linux driver 310.19 Aug 2, 2013
.gitignore Initial commit Jul 21, 2013
Header.png Initial commit Jul 21, 2013
LICENSE Initial commit Jul 21, 2013
Makefile Initial commit Jul 21, 2013
README.md Tweaked readme Jul 21, 2013



OpenGL GPU Fluid Solver

This project implements a 2D fluid solver completely on the GPU using OpenGL 4.3.

The solver features a marker-and-cell grid, vorticity confinement, fluid implicit particle, 3rd order Runge-Kutta advection, a conjugate gradient solver with incomplete Poisson preconditioner, and a heat diffusion/buoyancy model.

Videos rendered with this code:


Compilation requires freeglut and a recent version of GLEW. The makefile in the repository should work on Windows (tested with MinGW) and Linux.


A recent GPU with fresh drivers is necessary to run this application. Support for OpenGL 4.3 core profile is required. Tested on a GTX480.

When run, the program will open a graphics window and display a preview of the current simulation progress. If the macro RECORD_FRAMES in Main.cpp is set, the program will save out the individual frames as pngs using lodepng.

Note that the window resolution is independent of the fluid resolution; they are controlled individually using the constants GWidth/GHeight for the graphics window and FWidth/FHeight for the fluid grid resolution in Main.cpp. This is to allow for fluid resolutions much larger than the screen resolution. Frames will always be saved at the fluid resolution.


Main.cpp controls the application setup and invokes the fluid solver. Fluid.cpp, along with all the shader files, performs all of the fluid related work. All the remaining files are utilities to deal with OpenGL.

Scene setup and inflows are controlled in Fluid::initScene and at the end of Fluid::update. These can be modified to get more interesting looking simulations.