Skip to content

sarvottamananda/gltut-cpp

Repository files navigation

GLTut - Simple Code Bits for OpenGL/Linux/C++

PRs welcome First timers only friendly Open Source Love License: MIT

master:Build Status

develop:Build Status


This project contains beginner level OpenGL code snippets. The purpose is to learn OpenGL through practical programming.

The code snippets use OpenGL 4.0+

Compiling snippets in Linux

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.

Running all snippets

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.

Testing all targets

To run all the snippets from the directory do the following too.

$ meson test -C build

Examples

Tutorial 0 - OpenGL Sap Green window

$ ./build/src/cs0/cs0-window 

Tutorial 0

Tutorial 1 - Simple OpenGL Triangles

$ ./build/src/cs1/cs1-triangles

Tutorial 1

Tutorial 2 - Moving Triangles

$ ./build/src/cs2/cs2-moving

Tutorial 2

Tutorial 3 - Skybox

$ ./build/src/cs3/cs3-skybox

Tutorial 3

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

Tutorial 4 - Terrain

$ ./build/src/cs4/cs4-ground

Tutorial 4

Same options and controls as before.

Tutorial 5 - Lighting

$ ./build/src/cs5/cs5-lighting

Tutorial 5

Tutorial 6 - Reflection

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

Tutorial 6

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.


  Frequently Asked Questions

About

OpenGL Code Snippets

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published