This page contains a mosaic of renderings and animations that you can explore to master the fundamentals of using OpenGL in your project.
For the newcomer to OpenGL, it is recommended that you progress in a step-by-step fashion (001, 002, 003 and so on). For the experienced OpenGL ninja, feel free to jump in directly to something you like.
001: Open GLFW Window
|
002: Moving Triangle
|
003: Zooming In and Out
|
004: Moving Camera
|
005: Using Vertex Arrays
|
006: Using Vertex Arrays & Indices
|
007: STL Geometry Viewer
|
Let's look at an OpenGL application that reads in a 3D geometry from an STL file and allows the user to rotate the geometry in real time using the arrow keys on the keyboard. This was one of my motivations for learning OpenGL, apart from writing computer games. Spend some time going through the code and you will learn how to
|
008: Rolling Without Slipping
|
This OpenGL project simulates a circular disc that rolls without slipping on a larger disc. The question is this: If the smaller (rolling) disc has half the radius of the larger (stationary) disc, how many complete rotations of the smaller disc will occur by the time it completes one run around the bigger disc? Play the movie to find out the answer. Then take a look at the source code. |
009: Exploring the Mandelbrot Set
|
The Mandelbrot set is, of course, one of the most famous fractals invented. You can essentially keep zooming in and discover a glorious world of endlessly wonderful geometric patterns. The idea is to check all pixels in your display window for membership in the set and devise a practical criterion to distinguish points inside the set (black), points outside the set (blue) and points close to the border (smooth color gradient). Because this is just a C++ code, I refer to this as the CPU-version. Later on, you will learn how to use CUDA and OpenCL to accelerate both the calculations that check for membership in the set and the graphics for rendering the image in the display window. |
010: Driven Cavity Flow
|
Flow inside a lid-driven cavity remains one of the most widely used benchmarks for validating new computational fluid dynamics (CFD) codes. This simulation uses the lattice Boltzmann method (LBM) for simulating high Reynolds number flow in a square cavity. The core LBM algorithm is based on a single-relaxation-time approach that uses the Smagorinsky model for changing fluid viscosity as a function of the rate-of-strain. In this tutorial, OpenGL is used for visualizing the flow field in real-time, while the code is running. Specifically, we plot the vorticity field to show rotating eddies:
This simulation was run using a 128 x 128 lattice for Re = 1,000,000. Because the lattice is coarse compared to the pixel counts along X and Y, bilinear interpolation is used to find the vorticity magnitude at each pixel location, based on vorticity values at the 4 nearest lattice points. |