Download OpenGL Programming on Mac OS X

Transcript
userInfo: nil
repeats: YES ];
}
We’ve now seen how to determine which extensions to use; when they’re appropriate; when you should use the baseline OpenGL versus extensions; which
checks to perform for compile-, link-, and run-time correctness; and how to dynamically bind symbols. In essence, we’ve taken the complete tour of OpenGL
extension selection and usage and shown how a lot of plumbing fits together.
We’ll now look at a simpler way to do things—that is, letting someone else do
all the work for us in a cross-platform extension toolkit.
Extension Management Libraries
In prior sections we looked at native ways of dealing with extensions on the
Mac, from the compile-time to runtime means of checking and using them. During this exploration, we made clear some of the complexity that is extension
(and version) management in OpenGL, and we offered advice on some ways to
manage that complexity. All of the express ways of managing extensions—from
preprocessor token checks to dynamic symbol loading and executing—are perfectly fine for managing extensions. In fact, if you’re using only a few extensions,
manually checking for them may be the easiest way to get up and running, as
our example has shown. However, if you write a large application and use a variety of extensions, you’ll eventually end up writing a lot of code just to manage
extensions. At that point, you might start to wonder why you bothered in the
first place because you’re spending a lot of time writing infrastructure and not a
lot of time writing the next Killer App. Fortunately, a variety of people over the
years have encountered this same OpenGL extension management issue, and
decided to do something about it.
In this section, we’ll present two toolkits with capability for extension management: GLUT and an open-source project called the GL Extension Wrangler
(GLEW). GLEW and GLUT both wrap up the techniques we’ve discussed earlier, not just for the Mac but on a variety of platforms. Both are a great way to get
up and running with extensions to OpenGL without writing the infrastructure
yourself. Other choices are also available out there, in the wilds, as every few
years someone else decides to take a crack at writing the definitive extension
management toolkit. Apple even has its own version of something like GLEW,
though it’s just example code. Apple has written a little tool it calls glCheck.
If you’re interested in learning the details of ways of managing extensions, it’s
worth a look [6].
Because GLEW and GLUT are supported on multiple platforms, those tools
are preferable, in the authors’ estimation. However, all OpenGL extension and
Extension Management Libraries
269