These programs show complete sample programs for using Modern OpenGL. These programs are based on older legacy OpenGL programs which were written for the book 3D Computer Graphics: A mathematical approach with OpenGL, by Sam Buss, Cambridge University Press, 2003. It is hoped that in the near future, all of those legacy OpenGL programs will be translated to Modern OpenGL, to support the course Math155A/B at UCSD during Winter and Spring 2017.

These programs are still UNDER DEVELOPMENT. Corrections or improvements (minor and major) will be very much welcomed!

The programs will be supplied with Visual Studio 2015 project and workspace files; however, the source files should work with other compilers and on other systems as well. You will need to have OpenGL, GLFW, and GLEW installed: namely, the header files to compile programs and the object libraries to link and run the programs.

  1. SimpleDrawModern shows how to draw points, lines, line strips, line loops, and triangles. It includes simple vertex and fragment shaders. It accepts keyboard inputs to update the scene.
  2. SimpleAnimModern shows how to draw triangles, triangle strips, and triangle fans; how to use an orthographic projection matrix, how to use model view matrices, and to do a simple rotational animation.
  3. SolarModern animates a simple solar system with a sun, an earch and a moon. It uses a perspective projection matrix and implements a hierarchical use of modelview matrices. It contains simple animation controls, and uses GlGeomSphere to render spheres. (COMING SOON)
  4. BasicDrawModes illustrates drawing multiple triangle strips in four of the basic drawing modes for OpenGL: glDrawArrays, glDrawElements, glMultiDrawElements, and glDrawElements with Primitive Restart.
  5. GlGeomShapes. C++ classes encapsulating some simple grometric shapes. (COMING SOON)
  6. SimpleLightModern. illustrates Phong with Gouraud shading, and Phong Lighting with Phong shading. Allow several viewing options, including seeing the different light components separately.
If you have a compiler installed on your computer, it very likely comes with the needed OpenGL headers and libraries, but you still need the GLFW and GLEW headers and libraries. GLFW provides a platform-independent (more-or-less) interface to OpenGL so that the same code can be used for different operating systems, including Windows, Macs, and Linux. GLEW is the "OpenGL Extension Wrangler Library": it tracks which features ("extensions") of OpenGL are available in your computer system, and is simplifies the interface to OpenGL.

Obtaining GLFW. GLFW files are available from http://www.glfw.org. For Windows machines, the header files and binary files (library files) are available for direct download, by clicking on the "Download" header on that web page. After you obtain the header files (.h) and the Windows library files (.lib), install them on your system (as administrator) in the same location as GL/glu.h and glu32.lib. Installing the .dll files should not be necessary, as it is recommended to use static linkage. If you do not have administrator privileges, you may instead store the files locally.
For non-Windows machines, you will need to compile GLFW from its source code: this is also available at http://www.glfw.org/ along with CMake files.
If you compile and link with makefiles instead of using Visual Studio projects, you may wish to remove the #pragma commands in the .cpp files.

Obtaining GLEW. GLEW files are available from http://glew.sourceforge.net. Installation directions are the same as for GLFW above.

Acknowledgements: I initially started learning Modern OpenGL primarily from the OpenGL Programming Guide, Ninth Edition (Kindle version), and the Learn OpenGL website by Joey de Vries. Books on Modern OpenGL include the OpenGL Programming Guide and the OpenGL Super Bible; if you get one, be sure it is for OpenGL 4.2 or later. The LearnOpenGL website also a PDF version of itself available for download as a complete online book. For somewhat denser reading, the official specification of OpenGL 4.5 is available online at https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf.