Slashdot Mirror


OpenGL Programming Guide 6th Ed.

Martin Ecker writes "The Red Book, also known as the OpenGL Programming Guide published by Addison-Wesley Professional, returns in its sixth edition with additions covering OpenGL 2.1. The Red Book, so called because of its nice, red cover, is probably the most-well known, standard introduction to the OpenGL graphics API. Let me take you on a tour through the pages of this book to see what it has to offer." Read on for the rest of Martin's review. OpenGL Programming Guide (Sixth Edition) - The Official Guide to Learning OpenGL, Version 2.1 author Dave Shreiner, Mason Woo, Jackie Neider, Tom Davis pages 862 publisher Addison-Wesley Professional rating 8/10 reviewer Martin Ecker ISBN 0-321-48100-3 summary The Red Book is the authoritative guide to OpenGL. Just as the previous, fifth edition of the book, the sixth edition is incredibly complete and thorough. It contains explanations of pretty much every feature of OpenGL, even the rarely used ones. You want to know about the fairly new occlusion query support of OpenGL? It's in this book. You want to know about the accumulation buffer and its uses? It's in this book. You want to know about the (mostly deprecated) use of indexed color buffers? It's in this book. The sixth edition also covers vertex and fragment shaders and recent additions to the GLSL, the OpenGL Shading Language, such as the preprocessor. Even though the coverage was expanded, the authoritative guide to shader programming in OpenGL still remains the Orange Book aka The OpenGL Shading Language (see my previous Slashdot review).

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. The book consists of 15 chapters and 9 appendices that together span approximately 860 pages.

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, fixed-function lighting, framebuffer blending, and fog are discussed.

Chapter seven contains a description of display lists, a unique 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. Most notably this chapter now covers pixel buffer objects, a fairly recent addition to OpenGL, which the fifth edition of the book did not mention. The discussion of images in chapter eight bring us straight to chapter nine on texture mapping, one of the largest chapters in the book. This chapter discusses everything you need to know about textures, 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 sixth edition — sRGB format textures added in OpenGL 2.1 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. Also the accumulation buffer and its uses, such as motion blur and depth of field effects, are discussed. 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 (Graphics Processing Units).

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 sixth edition this chapter has been updated to version 1.20 of GLSL as required by OpenGL 2.1. 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 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.

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.

Martin has been involved in real-time graphics programming for more than 10 years and works as a professional game developer for High Moon Studios in sunny California.

You can purchase OpenGL Programming Guide (Sixth Edition) - The Official Guide to Learning OpenGL, Version 2.1 from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

13 of 86 comments (clear)

  1. I'd wait! by Grisha · · Score: 5, Informative

    OpenGL 3.0 is due to be released in short order, and it's pretty much a complete redesign of the API.

    Out with state machines and in with OO abstractions.

    1. Re:I'd wait! by krgallagher · · Score: 3, Interesting
      "OpenGL 3.0 is due to be released in short order, and it's pretty much a complete redesign of the API."

      I am not a programmer but I play one on TV.

      So help out a N00b. Is Open GL strictly for graphics, or does it cover other system calls like sound and user IO? What I am getting at here is that most of the times when I see a windows game that also runs on Linux, it uses Open GL. Those that do not use Direct X. Is the problem that the Open GL standard does not include sufficient API's to deliver all the standard calls need to write a game? Is it that other standards like ALSA (I am guessing that is a sound API) do not have windows ports? Why oh why is there nothing out there that allows programmers to write some kind of ANSI coded games that will compile on mutiple operating systems without error or modification?

      OK I admit I am ignorant in this area, so please don't call me ignorant, I have already done so myself. It just seems to me that if Microsoft can do it with Direct X, the rest of the world should be able to do it better, more cross compliant, and portable.

      --

      Insert Generic Sig Here:

    2. Re:I'd wait! by Abcd1234 · · Score: 4, Informative

      So help out a N00b. Is Open GL strictly for graphics, or does it cover other system calls like sound and user IO?

      Graphics only.

      Why oh why is there nothing out there that allows programmers to write some kind of ANSI coded games that will compile on mutiple operating systems without error or modification?

      I take it you've never heard of SDL? Just use an OpenGL-enabled surface for graphics, and the standard SDL APIs for sound and input.

  2. Re:Gah. by pilgrim23 · · Score: 2, Funny
    --
    - Minutus cantorum, minutus balorum, minutus carborata descendum pantorum.
  3. Re:Gah. by Intruger · · Score: 2, Informative

    I don't know about the latest edition. But you can take a look at an older edition here:
    http://www.glprogramming.com/red/
    I learned OGL mostly from this book (along with NeHe's tutorial on gamedev.net).

  4. Re:Comparison to DirectX by nate+nice · · Score: 5, Informative

    DirectX has had an "easier" and "more pleasant" API for years. OpenGL is a state machine, programmed in good 'ol C. DirectX has an OO API and what some would argue a more complete library.

    OpenGL 3.0 will move to a an OO API. It should make programming in OpenGL a lot more attractive. I've heard from people they feel it's easier to do a lot more things in DirectX than OpenGL. It's all opinion, of course.

    I'm not a graphics programmer but I have played one on TV.

    --
    "If you are a dreamer, a wisher, a liar, A hope-er, a pray-er, a magic bean buyer ..."
  5. Re:Comparison to DirectX by Xiph · · Score: 4, Interesting

    MicroSoft subsidizes training.
    DirectX is the native API to the OS on most peoples computers.
    Microsoft has experienced technical writers publish books about DirectX the day it comes out.
    OpenGL books are being written mostly by developers, which aren't always good technical writers.
    Microsoft managed to mastermind OpenGL standard development to halt to a freeze for several years, they no longer hold the same influence.

    My opinion:
    OpenGL is a more logical language, with a few features that are far better.
    OpenGL makes me happy, no clue why, but I enjoy coding up against it, DirectX makes me concentrate and for some reason, I never manage to dispose properly of all my "managed" objects in DirectX. That being said, one thing i like about directX is DirectView.
    OpenGL + Cg makes me happy

    My captcha was porters, proving that there is not necessarily a direct link between what you write and what captcha you get :P (to me a porter is a beer)

    --
    Blah blah sig blah blah blah irony blah blah
  6. I've been waiting for Perl 6 to come out... by krog · · Score: 3, Funny

    ...before I replace my Camel Book, 2nd Edition. It hasn't worked out as well as I thought it might, 5 or 6 years ago.

  7. Re:For those not wanting to RTFS... by An+ominous+Cow+art · · Score: 2, Funny

    It's in this book. It's in this book. It's in this book. Is it really in this book?
  8. Re:Comparison to DirectX by edwdig · · Score: 4, Insightful

    DirectX has had an "easier" and "more pleasant" API for years.

    DirectX is a nightmare of ActiveX/COM objects. It's anything but pretty to look at it. It takes a lot of code to get started before you can do anything. There's a very steep learning curve to fight through before you can do anything at all with it. It gets easier once you've managed to get it going, but it still isn't pretty.

    OpenGL is a state machine, programmed in good 'ol C.

    Which makes it very straightforward to work with. You don't find yourself wondering how something will work. If you have any background in 3D graphics theory, things work in OpenGL exactly as you'd expect.

    DirectX has an OO API and what some would argue a more complete library.

    The OO API doesn't make things easier, as it's COM based. It's advantage is integration with Windows.

    The library is where DirectX has an advantage. It's got some higher level functionality built in that OpenGL doesn't have.

  9. Re:Comparison to DirectX by Anonymous Coward · · Score: 2, Interesting

    OpenGL is a state machine, programmed in good 'ol C.

    Or any other language you want. I've used it from Python, and it's great. It's portable, fast enough for me (though I'm not writing Doom3 here), close enough to the C API that I can use any C reference, but still Pythonic enough that it's pleasant to work with. Plus, if you can put something (or everything) into a display list, it *really* flies.

    It's trivial to wrap a state machine. It took me about 2 minutes to wrap glBegin/glEnd with a Python 2.5 context manager, so I never have to write glBegin/glEnd again, and my code is indented to show the structure of my graphics. Very nice.

    I guess if you're writing games at iD (or to compete with them), C is the way to go. For the rest of us, a higher-level language is much less painful. If my boss wants a new visualization of some data in 3D, I can whip it up really quick in Python, and he won't care that it's only N fps instead of 2N fps, as long as N > 50. Or if he decides he really wants it faster, I can probably port it to C without much trouble.

    From what I've seen, Direct3D is not simpler than OpenGL with a HLL.

  10. Re:Q about book by mike260 · · Score: 2, Informative

    It's a genuine how-to book, and a pretty good one at that. That, plus NeHe, are excellent ways to get started.

  11. Re:Q about book by the_greywolf · · Score: 2, Informative

    Believe it or not, it's actually both. It is the official standard API documentation, but it's written for the benefit of both implementers and users. Because the standard describes very specific behavior (including side-effects) of implementations, it's the most important and useful resource for users of the API. That, and the book describes in very clear terms how to use the API. It's not a beginner's HOWTO manual, but it's very, very close.

    I own 5th edition, and it's the OpenGL reference I use the most.

    --
    grey wolf
    LET FORTRAN DIE!