next up previous contents
Next: 19.1.2 Extensions and OpenGL Up: 19.1 General Concerns Previous: 19.1 General Concerns

19.1.1 Handle Runtime Feature Availability Carefully

OpenGL implementations vary widely in their support of buffer sizes and the availability of some buffers, such as stencil and the alpha channel, especially among PC hardware. Be prepared to proceed with a limited number of bits per component, and be prepared to drop back on an alternative algorithm if you need but cannot get, for example, the accumulation buffer and the stencil buffer.

Implementations may choose to provide some extensions but not others. Check at runtime for the extensions available to you and then choose whether the implementation has the capability for a more interesting algorithm, such as 3D texturing for volume rendering (Section 16.2). You can check for an extension by checking the result of glGetStringGL_EXTENSIONS(GL_EXTENSIONS) for the substring corresponding to the extension. Section 20 discusses using extensions in more detail.

When writing programs which automatically configure to the available extensions the program may use the dynamic linking capabilities of the underlying operating system to acquire addresses of the functions implementing the new commands. On most UNIX systems the dlopen, dlsym, and dlclose commands may be used to manipulate dynamic libraries and query functions. On Windows systems the commands LoadLibrary, GetProcAddress, and FreeLibrary provide similar functionality. Portable programs should use dynamic binding rather than relying on linking explicitly with extension function symbols.

Other capabilities to check include:

Textures and other state elements that provide PROXY targets can test for the success of a state element binding without changing the actual values for that piece of state. You can identify the size available for one object by attempting to bind a very large object, then steadily reduce the size requested until the proxy parameters are accepted. A proxy binding that fails sets the state values for the proxy target to 0, while one that succeeds sets the proxy values to the parameters provided in the proxy call.

Note that the convolution extension does not provide a PROXY target but you can directly query the maximum width and height of the convolution kernel through glGetConvolutionParameter*EXT() using GL_MAX_CONVOLUTION_WIDTH_EXT and GL_MAX_CONVOLUTION_HEIGHT_EXT.


next up previous contents
Next: 19.1.2 Extensions and OpenGL Up: 19.1 General Concerns Previous: 19.1 General Concerns
David Blythe
1999-08-06