Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Graphics

Submission + - Book Review OpenGL Programming Guide (7th Edition)

Martin Ecker writes: Statistics
Title: OpenGL Programming Guide (Seventh Edition) – The Official Guide to Learning OpenGL, Versions 3.0 and 3.1
Authors: Dave Shreiner, The Khronos OpenGL ARB Working Group
Pages: 883
Rating: 8/10
Publisher: Addison-Wesley Professional http://www.informit.com/opengl
ISBN-10: 0-321-55262-8
ISBN-13: 978-0-321-55262-4
Price: $59.99 US
Summary: The Red Book remains the authoritative guide to OpenGL.

The Red Book, also known as the OpenGL Programming Guide published by Addison-Wesley Professional, returns in its seventh edition, now covering OpenGL up to and including version 3.1. The Red Book, so called because of its deep red cover, is the most-well known, authoritative introduction to the OpenGL graphics API. In this review I want to take you on a whirlwind tour through the pages of this book to see what it has to offer.

The Red Book is aimed at the beginning to intermediate graphics programmer that is not yet familiar with OpenGL. It assumes a basic background in computer graphics theory and working knowledge of the C programming language. Just as the previous edition of the book, the seventh edition is incredibly comprehensive and thorough. It contains explanations of pretty much every feature OpenGL has to offer, even the more obscure and rarely used ones. This is good in the sense that it's a fairly complete book, but it can also be somewhat overwhelming for a beginner when confronted with a book that weighs in at almost 900 pages. However, the good news is that the material is presented in a logical progression and even a novice will get up to speed with the basics of OpenGL after reading only the first few chapters of the book. Some of the early chapters in the book contain a few more advanced sections mostly explaining new features that got introduced with OpenGL 3.1. These sections are conveniently marked as advanced and can probably be skipped on a first read-through of the material.

The first chapter gives a brief introduction to the basic concepts of OpenGL and describes the rendering pipeline model used in the API. GLUT, a cross-platform library that allows easily creating OpenGL applications, is also shortly discussed together with a program that shows GLUT in action. The following chapters proceed to explain the basic geometric primitives, such as lines and polygons, supported by OpenGL and how to render them in different positions and from different viewpoints using the various OpenGL matrix stacks. Also the basics of using colors, lighting, framebuffer blending, and fog are discussed.

Chapter seven contains a description of display lists, a unique and with OpenGL 3.1 deprecated feature of OpenGL that allows to store OpenGL API calls for efficient multiple uses later on in a program. Chapter eight then moves on to discuss what an image is for OpenGL, and most notably covers pixel buffer objects, a somewhat recent addition to OpenGL. The discussion of images in chapter eight brings us straight to chapter nine on texture mapping, one of the largest and arguably most important chapters in the book. Everything you need to know about textures is discussed, from specifying texture images in uncompressed and compressed form to applying textures to triangles using the various kinds of supported texture filters. Also depth textures and their application in the form of shadow maps and – new in the seventh edition – floating-point textures and texture arrays added in OpenGL 3.0 are presented.

In chapter ten the authors discuss the buffers that make up the framebuffer, such as the color buffer, depth buffer, and stencil buffer. This chapter summarizes some of the things already presented in the earlier chapters and then describes the various framebuffer operations in more detail. Chapter eleven and twelve are on the tools provided by GLU, the GL utility library, in particular tesselators, quadrics, evaluators, and NURBs. GLU is nowadays rarely ever used in production code, so these chapters mostly demonstrate just how complete the Red Book is in its coverage of OpenGL. This also applies to chapter thirteen on selection and feedback, which are rarely used features, mostly because of the lack of hardware acceleration in today's GPUs.

Finally, chapter fourteen is a collection of topics that didn’t fit into the other chapters, such as error handling and the OpenGL extension mechanism. Additionally, this chapter presents various higher level techniques and tricks, for example how to implement a simple fade effect, how to render antialiased text, and some examples of using the stencil buffer. The final chapter of the book is a discussion of the OpenGL Shading Language (GLSL, for short). In the seventh edition this chapter has been updated to version 1.30 and 1.40 of GLSL, as required by OpenGL 3.0 and 3.1, respectively. Even though the OpenGL API functions required to use GLSL are presented, this is only a rough overview of how programmable shaders are used in OpenGL. For a more detailed description of GLSL the reader is referred to the book "OpenGL Shading Language. Third Edition" also called the Orange Book.

The book closes with quite a few appendices on the order of operations in the OpenGL rendering pipeline, the state variables that can be queried, the interaction of OpenGL with the operating system-specific windowing systems, a brief discussion of homogeneous coordinates as used in OpenGL, and some programming tips. Also a reference of the built-in GLSL variables and functions is included.

The book contains a large number of images and diagrams, all of them in black and white except for 32 color plates in the middle of the book. The illustrations are of high quality and generally help make the explained concepts and techniques easier to understand. Most of the color plates depict spheres, teapots, and other simple geometric objects, so they aren’t overly eye-catching but do serve their purpose of showing what can be achieved with OpenGL.

With OpenGL 3.1 deprecating many older API features of OpenGL in favor of more modern alternatives, the seventh edition of the Red Book seems to have a bit of a split personality at times. If you're only interested in functionality not deprecated in 3.1 you can skip entire chapters, such as the chapter on display lists or fixed-function lighting. Of course, the knowledge of matrix stacks and how to use transformations is still relevant, but the corresponding OpenGL functions have been deprecated in favor of doing all the transformation math in the vertex shader or, what most people have been doing anyway, using your own matrix structures/classes on the CPU. The situation is similar for many of the other deprecated features (such as fixed-function lighting, color index mode, immediate mode, ...) that are still described in the book. I think the time is right to combine the Red Book with the Orange Book, removing any discussion of deprecated features, to have a book that focuses solely on the modern approach to graphics programming, which is mostly based on shaders. I can only hope such an OpenGL 3.1-only focused book will see the light of day soon.

All in all, the Red Book remains the definitive guide to OpenGL. Apart from being a good introduction, it also contains many interesting tips and tricks that make the experienced OpenGL programmer come back to it often. If you’ve read through the Red Book and the Orange Book in their entirety you pretty much know everything there is to know about OpenGL.

About the review author:
The author has been involved in real-time graphics programming for more than 10 years and works as a professional game developer for High Moon Studios http://www.highmoonstudios.com/ in sunny California.
Graphics

Submission + - Book Review: OpenGL Shading Language (3rd Edition)

Martin Ecker writes: Statistics
Title: OpenGL Shading Language (Third Edition)
Author: Randi J. Rost, Bill Licea-Kane
Pages: 743
Rating: 9/10
Publisher: Addison-Wesley Professional http://www.informit.com/opengl
ISBN-10: 0-321-63763-1
ISBN-13: 978-0-321-63763-5
Price: $59.99 US
Book Website: http://www.3dshaders.com/
Summary: A solid introduction to developing shaders in the OpenGL Shading Language GLSL.

The “OpenGL Shading Language” (also called the Orange Book because of its orange cover) is back in its meanwhile third edition with updated discussions of the OpenGL shading language up to version 1.40 introduced with OpenGL 3.1. Like the previous edition, the third edition of the book is one of the best introductions to GLSL — the OpenGL Shading Language — that not only teaches the ins and outs of GLSL itself but also explains in-depth how to develop shaders in GLSL for lighting, shadows, animation, and other topics relevant to real-time computer graphics.

Not unexpectedly the book starts out with a brief review of OpenGL basics. However, I would not recommend diving into this book without having prior experience with OpenGL, or at least with some other kind of 3D API, such as Direct3D. The book targets an audience that is already familiar with computer graphics and with OpenGL. Furthermore, knowledge of the C programming language is expected.

The next few chapters introduce the syntax and semantics of GLSL. At its core, GLSL is very similar to C. All the usual control flow statements, such as if statements and for loops, are available. However, the language adds some graphics-specific types, such as vectors and matrices. Even though this material is fairly dry, the writing is easy to follow and all concepts are presented with plenty of examples. Also uniform blocks — a new feature of GLSL version 1.40 — are discussed. Uniform blocks are used to efficiently send a block of variables via a uniform buffer to the GPU.

After familiarizing the reader with the language itself, chapter four delves into the integration of the shader-programmable units into the OpenGL pipeline, in particular the vertex and fragment shader units. Note that geometry shaders are not discussed in this book since they are a fairly recent addition to the OpenGL 3.2 specification.
The next chapter goes over all the built-in, common functions that GLSL provides, such as sin, cos, abs, fract, and so on. Being more of a visual learner, what I really like about this chapter that the authors provide function graphs for each of the functions introduced.
After all the basics of the shading language have been laid out in previous chapters, chapter six is dedicated to a full-fledged example that uses GLSL to procedurally render a brick pattern. If you're already familiar with other shading languages, such as Direct3D's HLSL or Cg, and you want to switch over to OpenGL/GLSL, I recommend jumping straight to this chapter to see how much you can grasp and then going back to the preceding pages to fill in the blanks if necessary.

The somewhat lengthy chapter seven contains detailed descriptions of the entry points provided by OpenGL to create and set up shader programs. Among other things, it describes how shader objects are created, compiled, and then linked to form shader programs that can then be used to render objects. Chapter seven concludes the dry, technical part of the book that introduced both the shading language and the necessary infrastructure to use it from a host program running on the CPU. The remainder of the book concentrates on numerous graphics techniques that can be achieved with shaders, such as bump mapping, lighting, shadows, animation, procedural effects, and many more. In short, it's the real fun part of the book where all the theory gets put into practice.

One of the highlights for me is the chapter on writing lighting shaders that discusses hemi-sphere lighting, image-based lighting using environment maps as light probes, and spherical harmonics lighting. The chapter on lighting is concluded by a discussion of the ÜberLight shader, a shader for a very versatile lighting model initially presented as RenderMan shader by Pixar Animation Studios.
Where there's no light there's shadow and so the book has an interesting chapter on various shadowing techniques, in particular ambient occlusion, shadow maps, and an interesting technique for rendering shadow volumes using deferred shading. The latter technique can be used to render soft shadows convincingly.

The most interesting chapter for me in the book is the one on surface characteristics. It discusses and develops shaders to render surface materials that exhibit complex light interaction. The authors start out with a discussion of refraction and present shaders to achieve the classic Fresnel reflection/refraction and chromatic aberration effects. Then diffraction, i.e. light bending around sharp edges, is discussed and a shader that renders a vinyl record realistically is developed. Finally, the chapter focuses on BRDF-based lighting and develops various material shaders using the BRDF model, a quite important topic nowadays since more and more video games now actually use BRDF-based lighting models.

Another important chapter in the book in my opinion is chapter seventeen about antialiased procedural textures. I consider it important because it is often ignored that shaders that procedurally create textures usually suffer from aliasing artifacts. This chapter shows a number of anti-aliasing techniques to diminish these issues. Chapter eighteen is a fun chapter on non-photorealistic rendering, discussing hatching, Gooch shading, and how to render the Mandelbrot set in a shader. Finally, the book closes with a comparison of GLSL with other shading languages, in particular RenderMan, HLSL, and Cg. This is mostly of interest to real geeks and language lawyers ;)

As in the previous edition, all images and diagrams in the book are in black and white, except for a few pages that contain 34 color plates in the middle of the book. Most of the images are not overly "flashy" but do give a practical idea of the types of rendered images a particular shader can produce.

The book’s accompanying website at http://www.3dshaders.com/ offers the source code to all the shaders presented in the book for download. Also available are other shaders not mentioned in the book and a demo application including source code, which nicely demonstrates the shaders in action. Most of the shaders are available under a very liberal BSD-style open source license.

The third edition of "OpenGL Shading Language" is an excellent introduction to shader programming with GLSL. It provides an in-depth and comprehensive discussion of the shading language itself as well as the C shader API used to create and manage shaders in the host program. The best and largest part of the book focuses on developing shaders for various applications, such as lighting, shadows, animation, and other areas of real-time computer graphics. If you’re interested in learning GLSL and shader programming in OpenGL, this is the book to get.

About the review author:
The author has been involved in real-time graphics programming for more than 10 years and works as a professional game developer for High Moon Studios http://www.highmoonstudios.com/ in sunny California.

Slashdot Top Deals

Our business in life is not to succeed but to continue to fail in high spirits. -- Robert Louis Stevenson

Working...