This project contains beginner level OpenGL code snippets. The purpose is to learn OpenGL through practical programming.
The code snippets use OpenGL 4.0+
To compile all the code snippets in the directory run the following
$ meson build
$ meson compile -C build
The executables are created as ${projectdir}/build/src/*/*
Run individual execuatable for each snippet.
The destination for compiled programs is mirrored structure in build directory. You can just change directory to the required location and run the compiled programs.
To run all the snippets from the directory do the following too.
$ meson test -C build
$ ./build/src/cs0/cs0-window
$ ./build/src/cs1/cs1-triangles
$ ./build/src/cs2/cs2-moving
$ ./build/src/cs3/cs3-skybox
Contol the camera and the cube with following keys
0, 1, ..., 9 : change cubemap
w, s : move camera to / away from cube
a, d : rotate cube clockwise / counter-clockwise
left, right, up, down : move camera
space : Reset camera and cube
Options :
- --fullscreen for fullscreen
- --windowed for window
- --height h for window height h
- --width w for window width w
$ ./build/src/cs4/cs4-ground
Same options and controls as before.
$ ./build/src/cs5/cs5-lighting
The reflections are not perfect, for example, we do not clip the cubes properly at the ground, though it can be done using clip and culling planes in OpenGL.
$ ./build/src/cs6/cs6-reflection
Keypresses 1, 2, 3 and 4 toggle ground, skybox, cubes and cubes reflection respectively. You will be able to see all the hacks with the ground and skybox.
We need clipping planes on the mirror to get rid of the hacks. The hacks are just convenience and cover for laziness, they are not necessary, but for tutorials it might suffice.