When I run my test JOGL app, it says that I only have GL2 available on the thread when my system supports up to OpenGL 4.1 according to the OpenGl Extensions Vi
For running the book's examples on a Mac, I have placed instructions on this website: http://athena.ecs.csus.edu/~gordonvs/errataMac.html
In summary, you need to:
If more idiosyncrasies are identified, I'll add them to the instructions in the website.
It turns out that OSX falls back to OpenGL 2.1 so you need to set the core profile yourself.
$ glxinfo | grep OpenGL
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: AMD Radeon R9 M370X OpenGL Engine
OpenGL version string: 2.1 ATI-1.42.15
OpenGL shading language version string: 1.20
I was able to set the core version (OpenGL 4.1) by passing GLCapabilities into the GLCanvas constructor.
Here is the new, fixed constructor:
public Code() {
setTitle("Chapter 2 - program1");
setSize(600, 400);
setLocation(200, 200);
// This was the fix
GLProfile glp = GLProfile.getMaxProgrammableCore(true);
GLCapabilities caps = new GLCapabilities(glp);
myCanvas = new GLCanvas(caps);
myCanvas.addGLEventListener(this);
this.add(myCanvas);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}