OpenGL:Tutorials:Extensions Basics
From GPWiki
The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server. However, the GPWiki forums are still active! Come say hello. OpenGL Extensions
[edit] Terms
[edit] What's an OpenGL Extension?Extensions are features that were added to OpenGL after its initial release, many are supported by virtually every implementation available (multitexturing for example), some are so bleeding edge that only the newest implementations (i.e. graphics cards/drivers) support them (fragment shaders for example).
[edit] What do I need to use an Extension?The official extension registry maintained by Silicon Graphics, Inc. is available on the web at http://oss.sgi.com/projects/ogl-sample/registry/. Here you will find definitive specifications for all known OpenGL extensions, including what new constants they define, how they are intended to operate and possibly some suggested uses. Equally important you will find a header file called glext.h which defines all the new constants defined for all extensions, and platform specific files for Windows and X.
[edit] What's an ARB?ARB stands for Architecture Review Board. This is the group that decides what features will and won't be added to each official OpenGL version, and generally define in what direction OpenGL develops. This board is composed of industry heavyweights: 3dLabs, Apple, ATI, Dell, IBM, NVidia, SGI, and Sun Microsystems. Many of these companies also have vendor specific OpenGL extensions listed on the same page.
[edit] What can I do with an extension?An extraordinary number of things. GL_ARB_occlusion_query allows you to know how many pixels on screen were affected by drawing a particular object. It might not seem particularly useful, but suppose you have a 20,000 triangle model and you want to know if it needs to be drawn this frame. Using this extension you can draw a very simple box that would encase the model (AKA bounding box), if no pixels are effected, you know the model doesn't need to be drawn. GL_ARB_fragment_program defines the interface to Fragment Shaders, the most powerful extension yet. Using this extension you can actually define small programs to be run on the graphics hardware on every fragment your application draws. The language these programs are written in is call OpenGL Shader Language (GLSL or GLSlang for short) and is very similar to [[C++]]. You can affect every aspect of the fragment from its depth value to its fog and color.
[edit] How do I use an extension?
PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f = wglGetProcAddress("glMultiTexCoord2f");
Cross platform using SDL: typedef void (*GL_ActiveTextureARB_Func)(unsigned int);
GL_ActiveTextureARB_Func glActiveTextureARB = 0;
...
/* Get function pointer */
glActiveTextureARB = (GL_ActiveTextureARB_Func) SDL_GL_GetProcAddress("glActiveTextureARB");
You may want to make the pointer global so you can access it from anywhere within your program.
Doug Sheets (doug.sheets@gmail.com) August 21st, 2005 [edit] Related Links |


