The latest version of the GLFW links against some new external libraries. If
you are linking against the static build you'll need to update your Makefiles
Dynamic libraries on 64-bit GNU/Linux with C99:
Frameworks on OS X:
7 August 2015
I got a Mac Mini and personally tested all the demos on OS X Yosemite.
I updated the Makefiles to make Apple builds easier - you no longer have to
uncomment the version hint section, it's defined in the Makefile.
I found and
fixed one or two bugs that only the Apple implementation picked up - the
Kernel demo used an undefined shader variable, for some reason shader
validation requires that a valid VAO is bound (!!), one or two shaders had
keywords in the wrong order, and the texture shadows demo had some shader
uniform location variables mixed up (that accidentally had correct values on
other implementations!). The geometry shader demo was using a deprecated
vertex count variable instead of gl_in.length().
Note that one or two demos are designed for GLSL 420, which isn't supported by
Apple - I added some commented-out code blocks to make it easy to see how to
retrograde these so that they run on OS X with 410.
28 January 2015
Added explicit glReadBuffers (GL_NONE) to 38_texture_shadows to
protect against invalid framebuffer error on Apple. Note that this isn't
actually valid in GL4 (seems to be from ES2/3).
26 November 2014
Updated all the shaders' version tags to #version 410 to properly
support layout (location=x) keywords for attributes. The Hello
Triangle demo is also updated to run OpenGL 4.1 instead of 4.0. I have not
tested the Visual Studio demos yet.
I also noticed that the texture coordinates for 15_phong_textures were
wrong, so generated a new mesh, and a new ambient occlusion map. I left the
.blend file in that folder.
26 August 2014
Updated the code for Extension Checking and the Debug Callback to use switches
to get error strings rather than arrays, which were slightly wrong (thanks
I have a few updates to make and small issues to fix, so expect this to change a
bit over the next week.
4 July 2014
Found some shader calls to deprecated texture2D() and replaced with
texture(). Also removed texture binding keywords from the
#version 400 shaders (required 420). Left a few shaders at 420 for
comparison - note at top of shader files in question.
3 July 2014
My hosted server is occasionally aborting downloads too early - it might
take a few attempts to get the files. Sorry about that - I'll move the code
over to a reliable host after the holidays!
Uploaded quite a few Makefiles for Apple OSX. I haven't been able to
test all of the demos on Apple yet (I don't have a Macbook myself), but most of
them should work! There is no Apple build of the Freetype library. I'll get
Found and fixed a bug in 02_shaders - thanks Andrea!
2 July 2014
The original code download was getting download errors (finishing too early)
from my web host, Godaddy. Their support people said that it was too large
(107MB), and getting time-outs, which I think is probably rubbish. I got rid of
the protected download settings, which I suspect Godaddy was mis-managing. In
any case, to get around this for now I have made the download smaller,
and moved the Blender mesh files and Visual Studio project files into separate
After the summer holidays I'll look at moving all the code to a more stable
host (potentially on Github or a professional source-code host). I'll also be
revising my main OpenGL website so that the book is the main source of content
for tutorials, and the site has articles for new and interesting things that
I work on - I have Compute Shaders and some low-level optimisation techniques
on my "after summer" list, powered by all the coffees that get :D. By all means
30 June 2014
I updated the source code download and revised and tested all
of the project files. You should now find:
Linux Makefiles for 64-bit GCC for all projects
Windows Makefiles for 32-bit MinGW GCC for all projects
32-bit Visual Studio 2012 Solution for all projects
Linux Makefiles for 32-bit GCC for some projects
I intend to add a set of OS X Makefiles, but I need to borrow an Apple machine
first to make sure that they work properly. For now, this is the general format
that you should expect for an OS X Makefile. Note the use of Apple frameworks
for the OS libraries, as well as for OpenGL itself:
errata - Extended Init - Frame Rate Counter - "70Hz" is no longer true - all
modern flat-panel displays use 60Hz. the next paragraph needs a clarification,
and I should really suggest adding millisecond timers and mention GPU timer
errata/typos - Extended Init - talking about texture dimensions: 16384x16384
etc. The numbers are wrong here - must have had much larger dims originally.
The bit about not fitting into memory .: does not hold. The biggest size there
(16k) is 1GB, everything else is just big.
errata - Vertex Buffer Objects - "bottleneck is the bus" → "bottleneck created by queuing commands to send to
gpu" (bus is actually very large)
errata - Phong - explain why I did the dot_p = max (0.0, dot_p),
add it to the Blinn code sample, and add it to the Common Mistakes list.
18 January 2016 (Edition 5 → Edition 6)
Re-drew the first diagram for clarity
Clarified the paragraphs too - removed the overly-specific advice
A complete shader programme controls comprises → -controls
shader slots → processors on the GPU
table says slots - cores
"For example:..." → just delete this paragraph, it's misleading
attribute or uniform variables → variable
shader slots will be empty → GPU cores will be idle
would completely replaces → replace
13 January 2016 (Edition 4 → Edition 5)
Extended Init; Anti-Aliasing: "the edges our meshes and triangles" --> "of"
Kindle Location: 1377 ; Description: "The are all" should be "They are all "
Kindle Location: 1206 ; Description: "It you want " should be "If you want "
Kindle Location: 252 ; Description: "ask GLFW is the " should be "ask GLFW if the "
Fonts from Files - A code snippet is missing line breaks
Fonts from Files - "we us a" → "we use a"
Particles - "is which lets" → "which lets"
Skinning Pt.1 - "The are used" → "These are used"
Skinning Pt.1 - "Will that the" → delete
Skinning Pt.1 - "and my copy" → -my
Skinning Pt.3 - "TODO explain SLERP fix here." → "This is a problem with
explained in the Quaternions article. We correct this by checking if the dot
product of the 2 versors is negative before calling SLERP. If so we negate one
Skinning Pt.3 - Finalising the animation, animation matrix maths is incorrect
→ correct in
demo code, needs update.
Shadows - "Hello World example" → "Hello Triangle example"
Building Larger Programmes - Code comment in first snippet about GL
versions can be deleted