Slashdot is powered by your submissions, so send in your scoop


Forgot your password?

Submission + - Book Review: OpenGL 4.0 Shading Language Cookbook (

Tommer writes: "Hi ... the last time I wrote a book review, it was called a book report. Let me know if you have any suggestions, I would be happy to revise or add anything important that I have left out.

-- cut --

OpenGL 4.0 Shading Language Cookbook
"Over 60 highly focused, practical recipes to maximize your use of the OpenGL Shading Language"
by David Wolff

Packt Publishing
ISBN 978-1-849514-76-7
340 page PDF + example code ZIP

The OpenGL Shading Language (GLSL) is evolving rapidly in tandem with
GPU hardware. Briefly, a shader is a compiled program which runs on
the massively-parallel GPU as part of the render process to determine
the colour of a pixel, the position of a vertex, or in GLSL 4.0,
pretty much anything. Older versions of OpenGL provided fixed shading,
lighting, and geometry-transformation functions. I was interested to
learn that these methods are deprecated in favour of ubiquitous GLSL.

OpenGL 4.0 Shading Language Cookbook (I'll call it "the Cookbook")
aims to get experienced OpenGL programmers up to speed using GLSL 4.0
to implement common rendering techniques, from those previously
provided by the fixed-function pipeline to more advanced variants
never before possible without CPU intervention.

To this end, the Cookbook is well-organized. The first chapter
"Getting Started with GLSL 4.0" covers the prerequisite libraries used
in the examples, how to pass data to a shader, and how to compile
C/C++ programs to use shaders. The second chapter "The Basics of GLSL
Shaders" covers simple "hello world" shaders. After that, it's
possible to skip forward into the remaining chapters to find the
recipe you're after:
        3: Lighting, Shading Effects, and Optimizations
        4: Using Textures
        5: Image Processing and Screen Space Techniques
        6: Using Geometry and Tessellation Shaders
        7: Shadows
        8: Using Noise in Shaders
        9: Animation and Particles

GPU hardware is evolving so quickly that my nVidia GeForce 9600M GT
doesn't even support OpenGL 4.0, so I couldn't test any of the sample
code. However, I had no trouble compiling the programs in the first
chapter with my old Ubuntu 10.10 system and a bit of fudging of OpenGL
4.0 constants. I was willing to presume that the code actually works
given the right GPU and produces output like the figures. All code
examples are available for download, and use qmake and the Qt OpenGL
bindings. Alternative libraries are mentioned where relevant, but I
found SDL conspicuous by its absence since it's more lightweight and
focused than the do-all Qt set.

The Cookbook organizes each recipe into 5 sections:
        Getting Ready — ingredients list
        How to do it ... — specific steps and example code
        How it works ... — explanation of the code
        There's more ... — variations on the example
        See also — links to related sections
This arrangement makes it very easy to flip to an example and find the
level of detail you need.

The code sections are mercifully brief, showing only the parts
relevant to the GLSL features being covered. The code download
includes all of these examples filled into the framework described in
the second chapter, so you can focus on reading the important stuff
but still see how it runs in context. The "See also" links aren't
hyperlinked in the PDF, but it's no big deal — most of the time this
references the previous or next section!

I'm interested in textures, so I gave chapter 4 a closer read. The
progression of examples was quite logical, covering basic texturing,
using textures for surface and lighting effects, and finally rendering
to textures. Techniques found in earlier chapters were referenced in
the "See also" sections, so I never felt lost. The requisite matrix
mathematics were covered enough to jog my memory, but not enough to
enlighten a neophyte, which is fine for a book of this level.

OpenGL 4.0 Shading Language Cookbook offers essential information for
OpenGL programmers entering the world of GLSL. Despite not being able
to run the examples, I feel like I'm ready to dive in to GLSL 4.0 once
I replace my antique GPU."

This discussion was created for logged-in users only, but now has been archived. No new comments can be posted.

Book Review: OpenGL 4.0 Shading Language Cookbook

Comments Filter:

At work, the authority of a person is inversely proportional to the number of pens that person is carrying.