Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 internet speed test! ×
Book Reviews

Submission + - Book Review: C++ Primer (Fifth Edition) (amazon.com)

asgard4 writes: "Title: C++ Primer (Fifth Edition)
Authors: Stanley B. Lippman, JoséeLajoie, Barbara E. Moo
Publisher: Addison-Wesley
976 pages
ISBN-13: 978-0-321-71411-4
ISBN-10: 0-321-71411-3
Price: $59.99

The updated C++ language ISO standard released in September 2011 (called C++11 by most people instead of its full, glorious name ISO/IEC 14882:2011) extends C++ in a myriad of ways, both at a language and at a library level. Even though there aren’t any compilers that fully support all the new language extensions yet, C++ books are already getting updated to include the new features. Quite possibly one of the best books to learn C++ is the classic book C++ Primer by Lippman, Lajoie, and Moo, which received a significant facelift in its fifth edition to include most (but not all) new C++11 features.

Unlike other books that start with discussing the C subset of C++ and the more low-level, procedural features of the language, C++ Primer immediately introduces various higher-level features, such as classes and the use of the standard library types string and vector. I think this is a good choice, considering that the book is written for a target audience that is already familiar with programming, but just not in C++. The book is also a very good introduction to the new C++11 features for programmers that already have experience with the “old” C++98. To aid this subset of readers, the authors have kindly added little icons next to the text that discusses C++11.

After presenting a quick and simple example program, the book introduces how to define variables of different types and how to create compound data structures, followed by a brief look at the standard library string and vector classes. Almost all later examples in the book will use at least these basic types. This is followed by the usual tour through most of the different types of expressions and statements C++ offers.The book continues with a detailed discussion of functions, how they can be overloaded, how default arguments work, how the new C++11 constexpr functions work, and how argument types are converted when functions are called. The authors do a great job at covering almost all possible argument types, from passing C-style arrays as references, to functions that accept the new C++11 initializer lists or old-style ellipsis parameters. In general, I think this thoroughness is a good thing. At the same time, it shows the complexity of the language when it takes almost 60 pages to describe how functions are defined and called.The book concludes its first part with a basic look at classes and some hints to object-oriented programming in C++.

Part II of the book is a brief tour of parts of the C++ standard library, in particular IO streams, various sequential and associative containers (including the new C++ unordered containers) and finally dynamic memory and smart pointers. This part is almost an interlude before the book continues with more concepts with regards to classes in part III, in which the presented examples make use of the standard library facilities from part II. A whole chapter in part III is dedicated to copy control, quite an important and often not very well understood concept in C++. There is also ample discussion of the Rule of Three, which states that a class that requires a destructor also needs a copy constructor and an assignment operator. Of course, with the new C++11 rvalue references this becomes the Rule of Five, which requires that such a class should also have a move constructor and a move assignment operator. The discussion of rvalue references and moving objects in C++11 is excellent, in my opinion. Well worth the read, even for experienced C++98 developers.

The book continues with operator overloading and an in-depth look at polymorphism via virtual functions. The new C++11 keywords final and override are discussed, as well as virtual destructors and pure virtual functions. The final chapter in this part of the book is about templates. The discussion is quite detailed, with a good coverage of class templates, function templates, template specialization and the new variadic templates that were introduced with C++11. There is also ample treatment of how rvalue reference template parameters behave in template argument deduction — quite an interesting topic that has some surprising properties. When passing an lvalue reference to an rvalue reference template parameter, the deduced type is an lvalue reference because of how references get collapsed during argument deduction. C++ guru Scott Meyers recently called this type of rvalue reference a “universal reference” in talk he gave. (http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Scott-Meyers-Universal-References-in-Cpp11)

The final part of the book deals with a few more topics that didn’t fit anywhere else in the book.In particular, there is discussion of some more standard library classes (tuples, regular expressions, and random number generators), exception handling, namespaces, overloading the new and delete operators, and some other random topics. Overall, the book’s coverage of the language is pretty thorough, but there are some things that it doesn’t discuss or even bring up at all. For one thing, there is no mention of template metaprogramming. There is a short mention of the new C++11 type traits templates, which can be considered template metaprogramming to some degree, but that’s pretty much it. I think for a primer that’s alright.However, a short chapter that shows some basic metaprogramming with types might have been nice. Also, there is no mention of the new C++11 memory model, multi-threading, or thread-local storage.

Most of the changes introduced with C++11 are certainly useful in a lot of contexts and allow us to write more concise and modern C++ programs. However, I can’t shake the feeling that C++ — already an incredibly complex language to learn and even more difficult to master — has become so cluttered with features that it’s becoming a herculean task to teach the language. C++ Primer reinforces that feeling. While an excellent book at giving the reader a thorough introduction to the language, the book’s more than 900 densely information-packed pages confirm that learning C++11 takes a lot of dedication. Nevertheless, the book is a great guide along the journey, if the reader is willing to immerse herself in the intricacies of the C++ programming language. I highly recommend C++ Primer to any programmer interested in starting to learn the ropes of C++."

Book Reviews

Submission + - Book Review: OpenCL Programming Guide

asgard4 writes: Statistics
Title: OpenCL Programming Guide
Author: Aaftab Munshi, Benedict R. Gaster, Timothy G. Mattson, James Fung, Dan Ginsburg
Pages: 603
Rating: 9/10
Publisher: Addison-Wesley Pearson Education
ISBN-10: 0-321-74964-2
ISBN-13: 978-0-321-74964-2
Price: $54.99 US
Book Website: http://openclprogrammingguide.com/
Summary: A solid introduction to programming with OpenCL.

In recent years GPUs have become powerful computing devices whose power is not only used to generate pretty graphics on screen but also to perform heavy computation jobs that were exclusively reserved for high performance super computers in the past. Considering the vast diversity and rapid development cycle of GPUs from different vendors, it is not surprising that the ecosystem of programming environments has flourished fairly quickly as well, with multiple vendors, such as NVIDIA, AMD, and Microsoft, all coming up with their own solutions on how to program GPUs for more general purpose computing (also abbreviated GPGPU) applications.
With OpenCL (short for Open Computing Language) the Khronos Group provides an industry standard for programming heavily parallel, heterogeneous systems with a language to write so-called kernels in a C-like language. The OpenCL Programming Guide gives you all the necessary knowledge to get started developing high-performing, parallel applications for such systems with OpenCL 1.1.

The authors of the book certainly know what they are talking about. Most of them have been involved in the standardization effort that went into OpenCL. Munshi, for example, is the editor of the OpenCL specification. So all the information in the book is first-hand knowledge from experts in OpenCL. The reader is expected to be familiar with the C programming language and basic programming concepts. Some experience in parallelizing problems is a benefit but not a requirement.

The book consist of two major parts. The first part is a detailed description of the OpenCL C language and the API used by the host to control the execution of programs written in that language. The second part is comprised of various case studies that show OpenCL in action.
The authors get straight to the point in the introduction, discussing the conceptual foundations of OpenCL in detail. They explain what kernels are (basically functions that are scheduled for execution on a compute device), how the kernel execution model works, how the host manages the command queues that schedule memory transfers or kernel execution on compute devices, and the memory model.

While this first chapter is all prose, the second chapter dives right in with some code and a first HelloWorld example. The following chapters introduce more and more of the OpenCL language and API step-by-step. All API functions are described in somewhat of a reference style with a lot of detail, including possible error codes. However, the text is not a reference. There is always a good explanation with examples or short code listings, the only notable exception being chapter three, which presents the OpenCL C language. A few more examples would have made the text less dry in this chapter.

An important chapter is chapter nine on events and synchronization between multiple compute devices and the host. This chapter is important because — as any experienced parallel programmer knows — getting synchronization right is often tricky but obviously essential for correct execution of a parallel program.

An interesting feature in OpenCL is the built-in interoperability with OpenGL and, surprisingly, Direct3D. Various functions in the OpenCL API allow creating buffers from OpenGL/Direct3D objects, such as textures or vertex buffers, that can be used by an OpenCL kernel. This opens up interesting possibilities for doing a lot more work on the GPU in graphics applications, such as running a fluid simulation on the GPU in OpenCL, which directly writes its results into vertex buffers or textures to be used directly for rendering without the host CPU having to intervene.

Before delving into the case studies the book briefly discusses the embedded profile that is available for OpenCL and the standardized C++ API that the Khronos Group provides in addition to the regular OpenCL API (which is defined exclusively as C functions). The C++ API makes using some of the OpenCL objects a little bit easier and somewhat nicer.

The second part of the book contains various interesting case studies that show off what OpenCL can be used for, such as computing a sobel filter or a histogram for an image, computing FFTs, doing cloth simulation, or multiplying dense and sparse matrices. The choice and variety of case studies is definitely interesting and most will be immediately applicable to the reader when going forward developing applications using OpenCL. All the code for the examples and the case studies in the book are available for download on the book's website.

Overall, the OpenCL Programming Guide succeeds in being a great introduction to OpenCL 1.1. The book covers all of the specification and more, has an easy to read writing style and yet provides all the necessary details to be an all-encompassing guide to OpenCL. The good selection of case studies makes the book even more appealing and demonstrates what can be done with real-life OpenCL code (and also how it needs to be optimized to get the best performance out of current OpenCL platforms, such as GPUs).

About the review author:
Martin Ecker has been involved in real-time graphics programming for more than 15 years and works as a professional game developer for Sony Computer Entertainment America in sunny San Diego, California.
Book Reviews

Submission + - Book Review: The Art of Computer Programming 4A

asgard4 writes: Statistics
Title: The Art of Computer Programming. Volume 4A: Combinatorial Algorithms Part 1
Author: Donald E. Knuth
Pages: 883
Rating: 9/10
Publisher: Addison-Wesley Publishing http://www.awl.com/
ISBN-10: 0-201-03804-8
ISBN-13: 978-0-201-03804-0
Price: $74.99 US
Summary: Knuth's latest masterpiece. Almost all there is to know about combinatorial search algorithms.

Decades in the making, Donald Knuth presents the latest few chapters in his by now classic book series "The Art of Computer Programming". The computer science pioneer's latest book on combinatorial algorithms is just the first in an as-of-yet unknown number of parts to follow. While these yet-to-be-released parts will discuss other combinatorial algorithms, such as graph and network algorithms, the focus of this book titled "Volume 4A Combinatorial Algorithms Part 1" is solely on combinatorial search and pattern generation algorithms. Much like the other books in the series, this latest piece is undoubtedly an instant classic, not to be missing in any serious computer science library or book collection.

The book is organized into four major parts, an introduction, a chapter on Boolean algebra, a chapter on algorithms to generate all possibilities (the main focus of the book), and finally 300 pages of answers to the many exercises at the end of every section in the book. These exercises and answers make this work an excellent companion for teachers of a university course.

The book begins with some introductory examples of combinatorial searching and then gives various definitions of graphs and directed acyclic graphs (DAGs) since a lot of combinatorial algorithms conveniently use graphs as the data structures they operate on. Knuth's writing style is terse and to the point, especially when he presents definitions and proofs. However, the text is sprinkled with toy problems and puzzles that keep it interesting.

After the introduction, the first chapter of the book (out of only two) is titled "Zeros and Ones" and discusses Boolean algebra. Most readers that have studied computer science in some form should be intimately familiar with most of the discussed basics, such as disjunctive normal forms and Boolean functions and their evaluation. The reader might be surprised to find a discussion of such an elemental foundation of computer science in a book on combinatorial algorithms. The reason is that storage efficiency is especially important for these types of algorithms and understanding the basic storage unit of computer systems nowadays (as the decimal computer is a definite thing of the past) is of importance.

After covering the basics of Boolean algebra and Boolean functions in quite some detail, Knuth gets to the most fun part of this chapter in my opinion: the section on bitwise tricks and techniques on integer numbers. Being a software engineer in the video games industry, I recognized a lot of the techniques from my day-to-day work, such as bit packing of data and various bit shifting and bit masking tricks. There is also a discussion of some interesting rasterization-like algorithms, such as the shrinking of bitmaps using Levialdi's transformation or filling of regions bounded by simple curves. The chapter concludes with Binary Decision Diagrams that represent an important family of data structures for representing and manipulating Boolean functions. This topic was also quite interesting to me since I have never been exposed to it before.

The second and main chapter of the book is titled "Generating All Possibilities". In this particular volume of the "The Art of Computer Programming" series, the only subsection of the chapter in this volume is on generating basic combinatorial patterns, or more specifically generating all n-tuples, permutations, combinations, partitions, and trees. We can expect more on this topic from Knuth in his continuation in Volume 4B and beyond.

The discussion on n-tuples starts out with a lengthy focus on Gray codes, which are binary strings of n bits arranged in an order such that only one bit changes from string to string.
A quite fun example for generating all permutations presented in this part of the book is alphametics, also sometimes known as verbal arithmetic — a kind of puzzle where every letter of a word stands for a digit and words are used in equations. The goal is to assign digits to letters in such a way that the equation is correct. A classic example is SEND + MORE = MONEY (the solution is left as an exercise for the reader).

The next section deals with generating all combinations. Given a set of n elements, the number of all possible combinations of distinct subsets containing k elements is the well-known binomial coefficient, typically read as "n choose k". One of the more interesting algorithms in this section of the book to me was generating all feasible ways to fill a rucksack, which can come in quite handy when going camping :P

After combinations, Knuth moves on to briefly discuss integer partitions. Integer partitions are ways to split positive integer numbers into sums of positive integers, disregarding order. So, for example 3, 2+1, and 1+1+1 are the three possible partitions of the integer 3. Knuth, in particular, focuses on generating all possible integer partitions and determining how many there are for a given number. The book continues with a concise presentation of the somewhat related topic of set partitions, which refer to ways of subdividing a set of elements into disjoint subsets. Mathematically, a set partition defines an equivalence relation and the disjoint subsets are called equivalence classes; concepts that should be familiar to any mathematics major. Again, the focus is on generating all possible set partitions and determining how many partitions can be generated.

The main part of the book closes with a discussion of how to exhaustively generate all possible trees, which is a topic that I have never given much thought to. I am familiar with generating permutations, combinations, and partitions, but have never really been confronted with generating all possible trees that follow a certain pattern. One main example used throughout this part of the book is generating all possible strings of nested parentheses of a certain length. Such strings can be represented equivalently as binary trees.

Knuth's latest book is comprehensive and almost all encompassing in its scope. It compiles an incredible amount of computer science knowledge on combinatorial searching from past decades into a single volume. As such, it is an important addition to any computer science library. This book is not necessarily an easy read and requires a dedicated reader with the intention of working through it from front to back and a considerable amount of time to fully digest. However, for those with patience, this book contains a lot of interesting puzzles, brain teasers, and almost everything there is to know on generating combinatorial patterns.

On a final note, if you don't have volumes 1-3 yet you can get all volumes in a convenient box set (http://www.amazon.com/Computer-Programming-Volumes-1-4A-Boxed/dp/0321751043).

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

Submission + - Book Review: OpenGL SuperBible (Fifth Edition)

asgard4 writes: Statistics
Title: OpenGL SuperBible (Fifth Edition)
Author: Richard S. Wright, Jr., Nicholas Haemel, Graham Sellers, Benjamin Lipchak
Pages: 969
Rating: 9/10
Publisher: Addison-Wesley Publishing http://www.awl.com/
ISBN-10: 0-32-171261-7
ISBN-13: 978-0-32-171261-5
Price: $59.99 US
Book Website: http://www.opengl.org/superbible, www.informit.com/title/9780321712615
Summary: Quite possibly the best introduction to OpenGL 3.3 programming that focuses exclusively on graphics programming using shaders.

The OpenGL SuperBible (www.informit.com/title/9780321712615) in its fifth edition is almost a complete rewrite. The authors threw out the discussion of old-style, fixed-function programming and replaced it with an introduction to OpenGL that is exclusively focused on using shaders from the very beginning. All the things that got deprecated with the advent of OpenGL 3 got removed, making it a more relevant and up-to-date book than the previous editions. The OpenGL SuperBible still strives to be the "world's best introduction to OpenGL" according to the authors. Let's see if it can keep that promise.

With the removal of the fixed-function pipeline, the OpenGL SuperBible is no longer quite the heavy-weight it used to be. It shrunk from more than 1200 to about 970 pages, which is not necessarily a bad thing. The book starts out with a basic introduction to 3D graphics, coordinate systems, and some basic math concepts, followed by short rundown of the history of OpenGL and a first little example program that renders a triangle. The authors even provide instructions on how to setup the C/C++ projects to build the example on Windows and MacOS. The writing is to the point but still verbose enough to easily follow the text. The authors analyze the example program in detail making it easy for a beginner to follow and understand the code. Overall, I really like the writing style and the flow of the book.

The next few chapters gradually introduce more and more OpenGL API functionality intermixed with new 3D graphics concepts, such as rendering points, lines, and polygons in various ways, alpha blending, how to use geometric transformations and projections, and how to move objects and the camera. Eventually, basic texture mapping is introduced with most of the basic things you need to know about the topic. In particular, specifying textures coordinates, sampling textures in the fragment shader, the various filtering modes (even anisotropic filtering), and texture compression are discussed. In a later chapter the authors do another deep dive into the topic of textures, in particular rectangle textures, cube maps, multitexturing, point sprites, and using texture arrays

Until this point the authors used haven't really talked much about shader programming yet. Most of the examples use simple pre-made shaders that don't really do much. This changes with chapter six titled "Nonstock Shaders" where we get a first glimpse of how to write our own shaders in GLSL, the OpenGL Shading Language. In particular, a fragment shader that uses a simple lighting model to light objects is developed.

After these introductory chapters presenting the basics of OpenGL programming, the next part of the book focuses on more advanced topics, beginning with buffer objects and how to use them to make your OpenGL programs run much more efficiently on modern hardware. Some of the examples presented in this part of the book include using render-to-texture to do reflections, tone mapping, and bloom. This part of the book closes with two fairly long chapters on advanced usage of the shader pipeline, in particular the transform feedback and the geometry shader stages. There is also some discussion on more advanced effects achievable with fragment shaders, in particular applying filters to images, such as a Gaussian blur or a Sobel filter. Finally, rendering geometry efficiently with vertex buffer objects and rendering many objects via geometry instancing is presented.

The final part of the book consists of 4 chapters explaining how to integrate OpenGL with the underlying operating system, in particular with Windows, Mac OS X, and Linux plus various other Unix flavors. The last chapter of this part of the book is about OpenGL ES, which is a version of OpenGL designed to be used especially on embedded system devices, in particular mobile phones and PDAs, to render real-time, interactive 3D graphics.

The book has a lot of images and diagrams throughout, though unfortunately not all of them are in color. There are however 24 color plates of the most interesting images in the middle of the book. The complete source code of the book, and even precompiled binaries for Windows and Mac OS X, can be downloaded from the book’s webpage http://www.opengl.org/superbible.

If you are new to both 3D graphics programming and OpenGL with a bit of C/C++ programming experience and you are eager to learn how to develop interactive programs with OpenGL, then this book is exactly right for you. The book is written in an easy to understand style without skimming the details (or even more advanced topics). It is the most comprehensive introduction to OpenGL that doesn’t require a lot of previous knowledge I have seen to date. The decision to completely drop any discussion of the fixed-function pipeline turned out to be an excellent choice. Finally there is a book that no longer wastes the reader's time with the parts of OpenGL that nobody who does serious graphics development uses and instead presents up-to-date information on how to do 3D graphics on modern graphics hardware.

All in all, the OpenGL SuperBible in its fifth edition succeeds very well in keeping its promise to be the best introduction to OpenGL and 3D graphics programming. Even after you’re done working your way through the main parts of the book you will always come back to the handy OpenGL API reference in the appendix of the book.

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.

Submission + - Book Review: The Design of Design

asgard4 writes: Statistics
Title: The Design of Design. Essays from a Computer Scientist
Authors: Frederic P. Brooks, Jr.
Pages: 432
Rating: 8/10
Publisher: Pearson Education
ISBN-10: 0201362988
ISBN-13: 9780201362985
Summary: Inspiring new book by Fred Brooks.

Coming up with sound, elegant, and easy to implement designs is not a
trivial matter, as Fred Brooks, author of the classic book "The
Mythical Man-Month", acknowledges in his latest book "The Design of
Design". In many disciplines — especially in software development -
the design process and how to produce good designs is relatively
poorly understood. Teaching the design process to students is even
more difficult. In the form of opinionated essays, Brooks attempts to
summarize what we know about the design process, how it has changed
over time, and how we can produce better and more elegant designs.
Brooks has decades of experience designing large systems and is well
known for his involvement in the design of IBM's OS/360.
Even though Brooks is a computer scientist, the book applies equally
well to many other disciplines outside of software development that
have a formal design process, such as architecture. A lot of his
examples come from other engineering disciplines and architecture. But
of course he presents the obligatory OS/360 case study as well.

The book is divided into six parts, the first three of which I
consider the most relevant and most interesting. In part one, Brooks
starts out with a discussion of models for the design process. In
particular, he presents his take on how the traditional Rational Model
(or the Waterfall Model — its offspring that is better known to
computer scientists) is not sufficient to achieve greatness in design
because it has a too simplistic and idealistic view of the design
process. Brooks then proceeds to discuss better, more iterative models
for designing, for example, Boehm's Spiral Model used in software
development, which much of the newer so-called agile methodologies are
based on. He argues that it is important to have a clear, concise
model that can be accompanied by an easy to understand graphical
representation, such as a diagram, in order to be able to teach the
design process to novice designers.

Part two of the book is about collaboration and team design. On large
projects there will usually be multiple designers that are forced to
work together to produce a single, coherent design. The major
stumbling block in team design is achieving conceptual integrity.
Brooks suggests that the most important way of achieving this is by
empowering a single software architect that has a high-level overview
and can make the final call on different, competing design
alternatives. I totally agree with this from my own experience of
working on large projects where multiple people held design
responsibilities. In this part of the book, the author also has a
timely chapter on telecollaboration and on the impact of modern
technologies, such as videoconferencing via the internet, on team

Part three, titled Design Principles, contains various essays on
budgeting, constraints, and user involvement in the design process.
There is also some interesting material on what Brooks calls exemplars
in design, i.e. the reuse of previous designs as a whole or in part in
creating new designs. My favorite chapter in this section of the book
is the one on good style. I find that a good design doesn't just need
to be coherent and functional, it also needs to be elegant. Brooks's
definition of design style is quite good in my opinion: "Style is a
set of different repeated microdecisions, each made the same way
whenever it arises, even though the context may be different". Well put.

Part four of the book, in which the author outlines his dream software
system for designing houses, is the by far weakest part of the book
for me. The presented "design" of the dream system is simply a list of
high-level features without going into any detail, which is pretty
pointless in my opinion. Part five gets more interesting again with
two essays on great designers and how to foster an environment at a
company to make designers great. In particular, I like the idea of
having designers "eat their own dog food", i.e. forcing them to use
the end products of their designs out in the wild (maybe in form of a
sabbatical at one of the system's customers). The book concludes with
seven chapters on various case studies. While these are certainly
interesting, they don't contain any additional essential thoughts on
the design process that weren't already presented in the previous
parts of the book.

"The Design of Design" is an excellent book from one of the pioneers
in computer science. Brooks's writing style is as elegant and
enjoyable as ever. While he dates himself in some of his examples, the
overarching ideas of the book are timeless and important. Not many
books have been written about the design of the design process itself
and this book is a valuable addition. It is mostly aimed at designers
and people that have spent some time reflecting on the design process
itself. The casual reader and people that are more concerned with
implementing designs rather than creating the designs themselves might
find it somewhat intangible. However, even designers in disciplines
other than computer science or software development can gain a lot
from the insights in this book.

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.

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

No amount of careful planning will ever replace dumb luck.