Skip to content
Anton's OpenGL 4 Tutorials book - Demo Code
C C++ Other
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
00_hello_triangle fixed up OSX Makefiles after fixing header paths on my Mojave-updated… Mar 29, 2019
00_hello_triangle_gl2.1 c demos with c99 Sep 19, 2018
01_extended_init simlifed osx makefile for Mojave builds Mar 28, 2019
02_shaders changed to 4.1 hints - all tested Mar 13, 2020
03_vertex_buffer_objects changed to 4.1 hints - all tested Mar 13, 2020
04_mats_and_vecs changed to 4.1 hints - all tested Mar 13, 2020
05_virtual_camera changed to 4.1 hints - all tested Mar 13, 2020
06_vcam_with_quaternion changed to 4.1 hints - all tested Mar 13, 2020
07_ray_picking changed to 4.1 hints - all tested Mar 13, 2020
08_phong changed to 4.1 hints - all tested Mar 13, 2020
09_texture_mapping changed to 4.1 hints - all tested Mar 13, 2020
10_screen_capture changed to 4.1 hints - all tested Mar 13, 2020
11_video_capture changed to 4.1 hints - all tested Mar 13, 2020
12_debugging_shaders changed to 4.1 hints - all tested Mar 13, 2020
13_mesh_import changed to 4.1 hints - all tested Mar 13, 2020
14_multi_tex changed to 4.1 hints - all tested Mar 13, 2020
15_phongtextures changed to 4.1 hints - all tested Mar 13, 2020
16_frag_reject changed to 4.1 hints - all tested Mar 13, 2020
17_alpha_blending changed to 4.1 hints - all tested Mar 13, 2020
18_spotlights changed to 4.1 hints - all tested Mar 13, 2020
19_fog changed to 4.1 hints - all tested Mar 13, 2020
20_normal_mapping changed to 4.1 hints - all tested Mar 13, 2020
21_cube_mapping changed to 4.1 hints - all tested Mar 13, 2020
22_geom_shaders changed to 4.1 hints - all tested Mar 13, 2020
23_tessellation_shaders changed to 4.1 hints - all tested Mar 13, 2020
24_gui_panels changed to 4.1 hints - all tested Mar 13, 2020
25_sprite_sheets changed to 4.1 hints - all tested Mar 13, 2020
26_bitmap_fonts changed to 4.1 hints - all tested Mar 13, 2020
27_font_atlas changed to 4.1 hints - all tested Mar 13, 2020
28_uniform_buffer_object changed to 4.1 hints - all tested Mar 13, 2020
29_particle_systems changed to 4.1 hints - all tested Mar 13, 2020
30_skinning_part_one changed to 4.1 hints - all tested Mar 13, 2020
31_skinning_part_two changed to 4.1 hints - all tested Mar 13, 2020
32_skinnng_part_three changed to 4.1 hints - all tested Mar 13, 2020
33_extension_check changed to 4.1 hints - all tested Mar 13, 2020
34_framebuffer_switch changed to 4.1 hints - all tested Mar 13, 2020
35_image_kernel changed to 4.1 hints - all tested Mar 13, 2020
36_colour_picking changed to 4.1 hints - all tested Mar 13, 2020
37_deferred_shading changed to 4.1 hints - all tested Mar 13, 2020
38_texture_shadows changed to 4.1 hints - all tested Mar 13, 2020
39_texture_mapping_srgb changed to 4.1 hints - all tested Mar 13, 2020
40_compute_shader changed to 4.1 hints - all tested Mar 13, 2020
41_shader_hot_reload Fix CMake output bins' names for 05-07 and 41 folders Apr 8, 2019
blender first check-in of extant code Jul 31, 2014
common more win64 makefiles Nov 28, 2019
visual_studio Simplified perspective matrix calculation May 20, 2019
.clang-format updated clang format Mar 19, 2019
.gitignore Update .gitignore and fix a typo Jan 1, 2018
.travis.yml removed osx path until can test on mac mini Sep 20, 2018
Assimp32.dll first check-in of extant code Jul 31, 2014
CHANGELOG.txt gcc win32 updated libs Jan 19, 2016
LICENCE.md Update LICENCE.md Sep 2, 2019
README.md Update README.md Mar 13, 2020
build_all_linux_osx.sh added osx support to build script Sep 20, 2018
glew32.dll first check-in of extant code Jul 31, 2014
glfw3.dll first check-in of extant code Jul 31, 2014
libstdc++-6.dll gcc win32 updated libs Jan 19, 2016

README.md

Anton's OpenGL 4 Tutorials book demo code

Build Status

This series of demos accompanies the e-book "Anton's OpenGL 4 Tutorials": antongerdelan.net/opengl

Copyright Dr Anton Gerdelan, Trinity College Dublin, Ireland. email: antonofnote AT gmail

Info

See "LICENCE.txt" for licence information.

Each chapter with major demonstration code has a corresponding demo here. There is also an example of code for Hello Triangle for OpenGL 2.1 for reference.

Each demo has easy-to-read Makefiles for Linux, OS X, and 32-bit Windows. There are also Visual Studio projects, but you may have to download newer versions of the libraries in the common/ folder to match your version of VS.

This code is some years old now and builds may fall out of date. I try to maintain this so that it functions but be aware that Makefiles and build details may differ slightly from book text for this reason. If you have a [tidy] CMake setup or updated build feel free to submit a pull request here.

Compiling

The libraries depended on reside in the common/ folder

  • common/include - Header files.
  • common/linux_i386 - 32-bit GNU/Linux libraries.
  • common/linux_x86_64 - 64-bit GNU/Linux libraries.
  • common/msvc110 - 32-bit Windows Visual Studio libraries.
  • common/osx_64 - 64-bit Apple OS X libraries.
  • common/win32 - 32-bit Windows GCC (MinGW) libraries.
  • common/win64_gcc - 64-bit Windows GCC (MinGW-w64) libraries.

Linux

  • Install a C and C++ compiler - usually by installing a "build-essential" bundle package via the package manager on your distribution:
sudo apt-get install build-essential
  • Install the GLFW3 and FreeType libraries:
sudo apt-get install libglfw3-dev
sudo apt-get install libfreetype6-dev
  • Open a terminal and cd to the demo of choice, then

64-bit systems:

make -f Makefile.linux64

32-bit systems:

make -f Makefile.linux32

Apple OS X

  • Install Clang or GNU compiler and tools - usually by installing Apple XCode through the App Store. It's free.
  • Open a terminal and cd to the demo of choice:
make -f Makefile.osx

Windows with GCC

If you have trouble linking supporting libraries you may need to recompile GLFW, GLEW, AssImp, and Freetype.

  • Install the GNU Compiler Collection - usually by installing MinGW (32-bit or the 64-bit alternative).

  • Open a console and cd to the demo of choice.

  • make -f Makefile.win32 (MinGW may have renamed make.exe to mingw-make32.exe or similar).

  • Copy the .dll files from the main folder to the demo folder

  • Or make -f Makefile.win64 for the 64-bit build.

Windows with Visual Studio

I provided some Visual Studio 2012 project files. You can find an overarching solution file in the main folder. This should convert well to most versions of Visual Studio. I used 32-bit versions of the libraries, but there's no reason that you can't add 64-bit versions if you prefer.

VS 2013 seems to work, but with 2015+ you'll probably need to download a newer version of the supporting libraries used to get around linking errors.

Caveats

  • Code is directly copy-pasted from book sections. This means that there will be redundant OpenGL calls to bind things etc. but I think it's easier to follow along like this.
  • Code explained in prior examples is moved to a file called gl_utils.cpp to avoid cluttering main.cpp. This means that gl_utils.cpp is not necessarily the same in each demo, but is built up gradually.

SDL2 Port

Dr Aidan Delaney at the University of Brighton has made an SDL2 port (as an alternative to using GLFW), which you can find on GitHub https://github.com/AidanDelaney/antons_opengl_tutorials_book/

Credits

Special thanks to all the readers over the years that have submitted additions, bug reports, fixes, and feedback. If you have submitted a correction and don't mind having your name/@ printed here please let me know (or if you'd like to change these details).

Contributors

You can’t perform that action at this time.