Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Example code for the OpenGL Shading Language Cookbook

branch: master
README.md

Example code from the OpenGL Shading Language Cookbook

The example code from the OpenGL Shading Language Cookbook, by David Wolff.

Requirements

To use these examples, you'll need the following:

Compiling the examples

All recipes have been tested on Linux. I hope to have them working on Windows soon. Your help is welcome! Fork this project on github.

  1. Install GLFW by following the instructions on their web site.
  2. Install the latest version of GLM.
  3. Download the example code from github, or clone using git.
  4. Run cmake. If cmake has difficulties finding the GLFW or GLM installations, you can set the variables GLFW3_ROOT and/or GLM_ROOT_DIR to help cmake find them.
  5. Compile by running make.

Any problems, create an issue on github.

Compiling for Windows with Visual Studio 2012

  1. Install CMake win32 installer
  2. Download GLFW 32-bit Window Libraries and extract to C:\Program Files (x86)\GLFW
  3. Download GLM and extract to C:\Program Files (x86)\GLM
  4. Download the example code from github, or clone using git.
  5. Run CMake GUI, point the Source Code directory to the location of the code you downloaded in the previous step (i.e. C:/Users/hp/Git/glslcookbook)
  6. Point the Build Binaries directory to the location of the code with CMakeFiles appended to it (i.e. C:/Users/hp/Git/glslcookbook/CMakeFiles)
  7. Click 'Configure'
  8. Click yes when prompted to create the Build Directory
  9. Specify Visual Studio 11 (VS 11 == VS 2012, VS10 == VS 2010) with 'Use default native compilers', then click 'Finish'
  10. Once CMake has finished configuring the Project, click 'Generate'
  11. Now open CMakeFiles\GLSLCOOKBOOK.sln
  12. Build the Project
  13. I've found the easiest way to run the examples inside Visual Studio is to right click the chapter that you are interested in and click 'Set as Startup Project', and then right click the chapter again and click 'Properties'. Under Configuration Properties, click the Debugging option group. Type the 'Command Argument' of the specific example you are trying to run (i.e. 'ads' for the ambient-diffuse-specular example from Chapter 2). Now you can Run the Local Windows Debugger and everything should behave as expected.

If you are having trouble with CMake generating the files, double check where you have the libraries installed. If you used a different location to extract GLFW and GLM, then you will have to edit 'cmake\modules\FindGLFW3.cmake' and/or 'cmake\modules\FindGLM.cmake' making sure that you change all back slashes to forward slashes in each path

OpenGL Function Loading

The OpenGL header file and a function loader for a 4.4 core profile are included with this project. They were generated using the OpenGL Loader Generator.

The code has been fully tested with OpenGL 4.4 and compiles under Linux with the latest NVIDIA drivers, and will soon (hopefully) be tested with MinGW on Windows.

Something went wrong with that request. Please try again.