Need help with gpu-fluid?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

443 Stars 36 Forks zlib License 6 Commits 1 Opened issues


High performance OpenGL fluid solver in C++

Services available


Need anything else?

Contributors list

# 74,927
4 commits
# 105,402
2 commits


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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.