Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

OpenGL Programming Guide 6th Ed.

Posted by samzenpus on Wed Sep 19, 2007 01:54 PM
from the write-it-again dept.
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.
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.
+ -
story

Related Stories

[+] OpenGL Shading Language 96 comments
Martin Ecker writes "A few months ago, the OpenGL Shading Language -- OpenGL's own high-level shading language for programming Graphics Processing Units (GPUs) -- was ratified by the Architectural Review Board (ARB) responsible for the development and extension of the OpenGL graphics API. The first real-world implementations are just becoming available in the latest graphics drivers of the big graphics hardware vendors. Now the first book that features this new shading language is available, with the intention of becoming the standard book on the subject. Randi J. Rost's OpenGL Shading Language (published by Addison-Wesley) is a good introduction to developing shaders with the new OpenGL Shading Language, and demonstrates a number of useful applications for real-time programmable shaders." Read on for the rest of Ecker's review.
This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • I'd wait! (Score:5, Informative)

    by Grisha (15132) on Wednesday September 19 2007, @01:58PM (#20671227)
    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.

    • Re:I'd wait! (Score:4, Interesting)

      by krgallagher (743575) on Wednesday September 19 2007, @02:35PM (#20671653) Homepage
      "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.

      • Re:I'd wait! (Score:5, Informative)

        by Abcd1234 (188840) on Wednesday September 19 2007, @02:41PM (#20671735) Homepage
        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 [libsdl.org]? Just use an OpenGL-enabled surface for graphics, and the standard SDL APIs for sound and input.
        • Also consider OpenAL [openal.org] for 3D sound support.
          • I'd also recommend OGRE [ogre3d.org] for graphics, which now includes OIS for I/O. It's great stuff, even if you only care about a single platform. There's really very little reason for most people to use DirectX or OpenGL directly. Steve Streeting and co. have packaged all that rendery goodness into one damn good engine.
        • I believe this is how blender still does it, the entire interface is written in openGL.
      • You can't compare OpenGL and DirectX. You can compare OpenGL and Direct3D, Microsoft's graphics interface. DirectX also includes stuff that handles keyboards/mice/joysticks, sound, and other nifty things.

        So if you want to do game programming that is cross platform, OpenGL only handles graphics. And just the low level bits - you need to write code to do higher level management of game object, like for example if you have a model of a pirate you need to know the position of each body part relative to the ne
        • Direct3D is no more advanced than OpenGL so your "lot of money into research" theory is busted. Direct3D is really no more innovative than any other Microsoft product, ie. it's a tiny bit behind everybody else but it has a lot more marketing with the words "innovation" in it.

          They do spend a lot of money on PR and taking games company bosses to lunch.

          You can definitely get the exact same speed from OpenGL as Direct3D on top end hardware - I do it every day.

          OpenGL drivers for major graphics cards (ATI/Nvidia/
    • by krog (25663) on Wednesday September 19 2007, @02:42PM (#20671751) Homepage
      ...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.
    • As far as I know only the specs will be finished soon. Will there actually be a full implementation of these specs shortly or will that still take months/years?
    • Out with state machines and in with OO abstractions.

      An object is a state machine. The whole idea of OO is to couple the state with the functions which manipulate it. So instead of having drawCircle(context, vertex[] VertexArray), you'd have context.drawPolygon(vertex[] vertexArray) or even context.draw(new Polygon(vertex[] vertexArray)). These all do the exact same thing (and the last does it inefficiently since it allocates memory), and manipulate the underlaying state machine (physical hardware) in th

    • > Out with state machines and in with OO abstractions.

      Having implemented OpenGL on the Wii, there is no reason why you can't do both. (oo abstractions under the hood.)

      Not every GPU is a stream processor. At some point you have to manage rendering states (blending,fog,etc.)
      • When they mean object orientation abstractions, they mean that every entity (eg. texture, display list, fragment, geometry, or vertex shader) registered on the graphics card will be created with a functions that returns a reference token, and all operations will operate on that token (including the removable of that object).

        This is more in line with the design of scene-graph API's.
  • The Red Book...returns in its meanwhile sixth edition with additions...


    By "meanwhile", do you mean "ho-hum"? (e.g.,, nothing new to see here?)
  • Here it is in 252 words thanks to Word's AutoSummarize feature.

    The Red Book, also known as the OpenGL Programming Guide published by Addison-Wesley Professional, returns in its meanwhile sixth edition with additions covering OpenGL 2.1. It's in this book. It's in this book. It's in this book. Even though the coverage was expanded, the authoritative guide to shader programming in OpenGL still remains the Orange Book aka The OpenGL Shading Language

    The Red Book is aimed at the beginning to intermediate graphics programmer that is not yet familiar with OpenGL. 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. 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. 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. All in all, the Red Book remains the definitive guide to OpenGL.

  • Please, please, please stop chapter by chapter summarizing of books in reviews. A summary of the book and notable points is much better. The reader doesn't care what is in the *chapters* until they have decided to read the *book!* Please. Everyone. Stop doing this. It's pedantic.

    Incidentally, I didn't realize my copy was three editions behind... Sophomore year seems so long ago.
  • Funny, I always though of the Red Book as the PostScript prgramming guide (er, Language Reference). Either that or the standard for audio CDs (CDDA).

    Then there's the old O'Reilly "Rainbow Books", the eight or nine volumes on X Windows specs and programming -- but glancing over at my bookshelf, none of them are red, exactly.

    • I'm looking at Volume 3, X Windows System User's Guide, on my bookshelf, right now, and it's most certainly red.
      • Aarrgh, somebody's swiped me volume 3 then!

        Seriously, (looking more closely at shelf) the Volume 3 X Windows System User's Guide OSF/Motif 1.2 Edition is more of a dark reddish brown. But (digs around a bit) yeah, you're right, the straight Vol 3 is indeed (mostly) red.

        Sorry about that.
        • I'm still using volume 2...

          Got it cheap a few years back. I had no idea it was so out of date.
          • Assuming you're serious, Volume 2 (Xlib Reference Manual) probably isn't very much out of date; Xlib hasn't changed very much. I have the 3rd edition (1992) with minor corrections (1993) that covers X11 R4/R5. We were on R6 for the longest time, R7 is less than two years old

            Most people use a toolkit (GTK, Qt, Motif, etc) on top of Xlib these days anyway.
    • Nothing funny about it. I second the thought.

      showpage
  • In any Linux or BSD system there is GL this, GL that. Yet the package that installs this seems to be called Mesa. Mesa I guess is still in development. Some OS versions fail to install the /usr/X11R6/include/GL Motif widget headers. I always have to go in and manually move them from the build directory to their useful location. Otherwise I have programs that won't compile.
    • OpenGL is the version produced by SGI (and now by the OpenGL consortium) and is also the name of the official reference implementation. (Nobody seriously believes that a commercial vendor would use a reference implementation of anything if they could possibly avoid doing so. Reference versions are necessarily highly generic, which usually means that the code can't be efficient anywhere.) Mesa is a third-party re-implementation of OpenGL and, as far as I know, is feature-complete to whatever version of OpenG
      • ABI? Undocumented quirks? Clones? What are you on about?

        OpenGL is the name of an API. Various companies make implementations for their hardware / OS, and then they pay SGI for the right to call their implementations 'OpenGL' (after passing a load of conformance tests).
        Mesa is an implementation of the OpenGL, it just hasn't been officially blessed by SGI (although they do support it's existance in other ways) so it can't legally call itself OpenGL.
        • OpenGL is the name of the API, which is what I said. I also said it was the name of the reference implementation provided by SGI (which it is). A reference implementation gives you an ABI and - invariably - quirks. SGI's OpenGL code provided in X11 and on their OSS pages are a reference implementation, not a commercial implementation. Even though OpenGL does not specify an ABI - it is an API specification - it is inherent in the process of having a reference implementation that people will code to the ABI p
  • Is this one of those books where the 860 pages is mostly filled with API documentation? Or is this a genuine how-to book? I'm definitely interested in learning OpenGL so that I can write a nice GUI for simple games, but it's hard to know where to start.

    Thanks,

    --Rob

    • Re: (Score:3, Informative)

      It's a genuine how-to book, and a pretty good one at that. That, plus NeHe [gamedev.net], are excellent ways to get started.
    • Re: (Score:3, 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 m

    • by nate nice (672391) on Wednesday September 19 2007, @02:39PM (#20671711) Journal
      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.
      • by edwdig (47888) on Wednesday September 19 2007, @03:19PM (#20672169) Homepage
        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.
        • DirectX is a nightmare of ActiveX/COM objects.

          When was the last time you've used DirectX? COM is nicely hidden (See the code below).

          // initialize DirectX

          m_D3D = Direct3DCreate9(D3D_SDK_VERSION);

          // uninitialize DirectX

          SAFE_RELEASE(m_D3D);

          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 i

        • >> 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.

          This has been fixed up heavily in recent years. The only remaining headache is keeping track of reference counts; in C++, you can use the CComPtr smart pointer template class
        • OpenGL is a state machine, programmed in good 'ol C.

          Which makes it very straightforward to work with.

          Linus, is that you?

          j/k :)

          --Rob

      • Re: (Score:2, Interesting)

        by Anonymous Coward
        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 con
      • 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.

        While I strongly prefer OpenGL over DirectX, on some points you just can't deny that it's easier with DirectX, being a more extensive library. Sound and multi-media along with 3d and more in "one package". It also has functions for stuff which is complex to implement, ready to be used (for example the Precomputed Radiance Transfer API [microsoft.com]).

        Another reason is that it's easier to verify that you
      • What kind of patent problems will OpenGL 3.0 have?

        The current version of OpenGL has a couple of patented bits that make a 100% open source implementation difficult. Is that going to be even worse in OpenGL 3.0 or are they avoiding such traps this time?
    • by Xiph (723935) on Wednesday September 19 2007, @02:41PM (#20671741)
      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)
      • I'd argue the hobbyist community for DirectX is bigger and better (more current, anyways). Besides NeHe, there are a few tutorials here and there for OpenGL (most of them rehashes of the same thing), but the communities for Managed DirectX recently have been popping up all over. Check out Riemers XNA Tutorial [riemers.net], The Hazy Mind [thehazymind.com], Coding4Fun [msdn.com], the ZBuffer [thezbuffer.com], and those are just the ones I remember off the top of my head from a year ago when I was dabbling with it. Each of those sites will take you from square one to
      • >> MicroSoft subsidizes training.
        Not for DirectX.

        >> DirectX is the native API to the OS on most peoples computers.
        There's nothing "native" about DirectX on Windows. I know, I worked on graphics drivers for one of the three big GPU companies (those three are Intel, NVIDIA, and ATI, in that order).

        I won't contest the book points.

        >> Microsoft managed to mastermind OpenGL standard development to halt to a freeze for several years, they no longer hold the same influence.
        To misquote Obi
    • Maybe this is a FAQ, but could someone point us why most game developers prefer DirectX, even if, by choosing OpenGL, they'd have the possibility to develop games for other operating systems as well? Yeah, I know, Windows has over 90% of the desktop market, but why don't develop for the whole market if something like OpenGL exist?

      There are a couple of reasons. First of all, Microsoft tailors the API to the latest graphics hardware much more quickly. This allows the developer to take better advantage o

      • There are a couple of reasons. First of all, Microsoft tailors the API to the latest graphics hardware much more quickly.

        Not really. Pretty much the first thing GPU companies do upon releasing fancy new hardware is to ship new drivers with OpenGL extensions letting developers get at the new functionality. D3D only exposes new functionality when Microsoft decide to rev the API.

        Second, partly as a consequence of that, you can usually do things faster under DirectX than under OpenGL, with a 2:1 speed ratio bei
        • Not really. Pretty much the first thing GPU companies do upon releasing fancy new hardware is to ship new drivers with OpenGL extensions letting developers get at the new functionality. D3D only exposes new functionality when Microsoft decide to rev the API.

          This is true to only a minimal degree. nVidia does quite a few extensions, and they do give some access to new "stuff". In a lot of cases, it's rather minimal access though, and in other cases, it's basically nonexistent. Just for an obvious exampl

          • This is true to only a minimal degree. nVidia does quite a few extensions, and they do give some access to new "stuff". In a lot of cases, it's rather minimal access though, and in other cases, it's basically nonexistent. Just for an obvious example right now, I don't know of any way to get at the geometry shader functionality via OpenGL. It simply doesn't fit well with the (current) OpenGL model.

            EXT_geometry_shader4 [opengl.org]
            What other stuff do you feel there's 'minimal' access to? nVidia has a history of doing real
    • I know you're trolling, but get out of your parents' basement. There's more to the 3d visualization world than video games.