Section 8.1. Concepts


8.1. Concepts

Platform-specific OpenGL code, by definition, differs from platform to platform. The concepts and coding tasks involved are very similar, however. On every platform, applications typically perform the following tasks:

  • Specify the framebuffer configuration The interface typically is an array or C struct that the application fills in with constants and values to describe the desired framebuffer configuration.

  • Create a rendering context This generally is done after the application specifies the framebuffer configuration so that the context is initialized accordingly.

  • Create a window.

  • Associate the context with the window This is usually done on a per-thread basis.

  • After rendering each frame, swap buffers.

  • When the application exits, delete the rendering context.

In most of the example source code, GLUT performs these tasks. The example source code also includes a platform-specific example, however, to demonstrate how applications can perform these tasks using interfaces specific to Apple Mac OS X, Linux, and Microsoft Windows.

In addition to window (onscreen) rendering, all platforms provide offscreen rendering capabilities. Because rendering to a buffer in host RAM usually invokes a software rendering path, most OpenGL implementations support the concept of pbuffersoffscreen buffers in graphics-card RAM that support hardware-accelerated rendering. Pbuffers are allocated by the operating system, so each platform-specific interface supports a pbuffer extension.

More recently, implementations have moved to support the GL_EXT_framebuffer_object extension. Like pbuffers, this extension enables hardware-accelerated rendering to offscreen buffers. GL_EXT_framebuffer_object is an extension to OpenGL and not to the platform-specific interface, however. Therefore, applications access its features using (platform-independent) OpenGL extension commands rather than different commands for each platform. GL_EXT_framebuffer_object also provides additional capabilities, such as streamlined render-to-texture, that are not available in the pbuffer feature.

Finally, all platforms also provide a mechanism to share all OpenGL objects, including display lists, texture objects, and buffer objects.




OpenGL Distilled
OpenGL Distilled
ISBN: 0321336798
EAN: 2147483647
Year: 2007
Pages: 123
Authors: Paul Martz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net