Chapter 5. Pixel Rectangles


The earliest framebuffers were simply mapped into host memory. To render, applications addressed the framebuffer like any normal block of memory and stored final color values at pixel locations within the framebuffer (Sproul 1979). As graphics hardware evolved, providing efficient direct access to the framebuffer became increasingly difficult, and many graphics hardware manufacturers stopped providing memory-mapped framebuffer access altogether. To support hardware that can't be memory mapped, OpenGL allows reading, writing, and copying pixel rectangles in the framebuffer.

Chapter 6, "Texture Mapping," describes a much more powerful use for pixel data than simply copying it to the framebuffer. This chapter serves as an introduction to texture mapping, because OpenGL uses the same pixel pipeline to process textures as it does to process pixel rectangles.

What You'll Learn

This chapter covers the basics of drawing, reading, and copying pixel rectangles:

  • Drawing pixelsHow to send pixel rectangles to OpenGL for display in the framebuffer.

  • The raster positionHow to specify where pixels should be rendered.

  • Reading pixelsHow to read framebuffer contents from the framebuffer.

  • Copying pixelsHow to perform copy (or BLT) operations within the framebuffer.

  • Performance issuesWhy moving pixel rectangles can stunt performance. The chapter also suggests alternative approaches that provide better performance.

  • DebuggingHow to resolve some common pitfalls that can cause incorrect behavior in your application.

What You Won't Learn

OpenGL provides a powerful set of commands for processing pixel data. Applications use OpenGL to display and store pixel data in a wide variety of formats, as well as share pixel data between big- and little-endian machines. Most of these commands are outside the scope of this chapter, which focuses on the task of displaying, copying, and reading back pixel data as RGBA unsigned bytes.

The capabilities of OpenGL not covered in this chapter include

  • Pixel processingThe chapter does not discuss pixel transfer, pixel map, color table lookup, pixel zoom, the imaging subset, and several other aspects of pixel processing.

  • BitmapsThis chapter discusses bitmaps only in terms of how the glBitmap() command affects the current raster position.

For more information on pixel rectangles, bitmaps, and pixel operations, see Chapter 8, "Drawing Pixels, Bitmaps, Fonts, and Images," of OpenGL® Programming Guide and Section 4.3, "Drawing, Reading, and Copying Pixels," of The OpenGL Graphics System.




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