OpenGL
implements extensions as a way for hardware vendors to introduce
new features into the GL without having to wait for the ARB to
decide on a spec. This is useful in two ways: it speeds up the
introduction of new features in the GL, and at the same time,
doesn't force the ARB to redo the spec every year or more (like
DirectX).
The most notable extension in the recent gaming industry is
ARB_multitexture. While it wasn't always an ARB extension
(GLQuake used SGIS_multitexture), it has been one of the best
examples of how the extension scheme works. The only problem is
making sure a hardware vendor introduces new extensions when they
add a new feature to their chipset. Luckily OpenGL is popular
enough and has strong industry support (John Carmack at id and lots of ex-SGI
engineers at NVIDIA), so
we're seeing many new cool extensions.
In this example, we're looking for the
extension for paletted textures
(GL_EXT_paletted_texture). Notice how it steps through
the entire string looking for that specific extension. The string
returned from glGetString() is a long list of the
extensions seperated by a space and null terminated. See how easy
this is? You can search for as many extensions as you like without
much extra work.
07/7/99 - Here's a simpler way to do
it (if you like that sort of thing) sent in by Michael Steinberg:
This is a
little troublesome because there are several ways in which
extensions are used. It can be simply a new constant value (S3TC),
or it can require new functions (multitexture) or both. The best
thing to do is look at the spec
to get any new constants and function declarations.
This example is taken from my GLConsole
for loading and using palettized images.
This is in a seperate file (tex.c) from the
main code. PFNGLCOLORTABLEEXTPROC is a pointer to an
OpenGL function. We will load this function from the OpenGL driver
next.
This is called after we've checked the
extension list. If it is supported, we try to get a pointer to the
function in the ICD with wglGetProcAddress, which needs
to be typecast to the GL function pointer.
Then we make the call to the function as
per it's definition. See the GLConsole
code for complete functions for loading 8-bit bmps.
Conclusion
Aren't
extensions great? Now if we can get vendors to post more
information about their driver's extensions (especially the vendor
specific ones). Kudos to ATI
for putting up their list of extensions. Let me know if other
vendors have done the same thing. I may have overlooked some.
last updated
These apply to all of my pages
linked from this one:
QUAKE(R) is a registered trademark of Id Software, Inc.
QUAKE(R), the stylized reproduction of the QUAKE(R) trademark,
including, without limitation, the Q in QUAKE(R), and the images
depicted in QUAKE(R) are the copyrighted property of Id Software,
Inc.
Microsoft VC++ and other phrases used to represent Microsoft
Visual C++ Developer Studio are registered trademarks of Microsoft
Corporation.
OpenGL is a registered trademark of Silicon Graphics, Inc.
(SGI)
If I'm using / abusing any other trademarks,
please inform me.