Table of Contents Glide Programming Guide


Calculating a Pixel Address



Download 6.22 Mb.
Page82/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   78   79   80   81   82   83   84   85   ...   106
GLIDEPGM

3Calculating a Pixel Address


The address of a particular pixel is computed from the (x,y) coordinates and the length of a scanline, a value that is returned in the info structure when grLfbLock() is successful. info.strideInBytes represents the number of bytes in a row or scanline. Thus,
address(x,y) = y * info.strideInBytes + x
address of the word containing (x,y) = address(x,y)/2 = (y * info.strideInBytes + x)/2
The location of the y origin, set in the call to grSstWinOpen() (see Chapter Chapter 3. ), determines the mapping of y addresses into frame buffer memory. When writing to the LFB, the location of the y origin set in grSstWinOpen() can be overridden, as described in the discussion of grLfbLock() that follows.

4Reading from the LFB


To read data directly from the linear frame buffer, obtain a read-only LFB pointer by calling grLfbLock(), as described in the previous section. All data is read as two 16-bit pixels per 32-bit word. The default pixel ordering within the 32-bit read is 0xRRRRLLLL where the left pixel in the pair is in the lower 16-bits of the 32-bit word, as shown in Figure Accessing the Linear Frame Buffer.1.
Figure Accessing the Linear Frame Buffer.1 Reading from and writing to the LFB.
When a 32-bit word is read using the read pointer acquired with a call to grLfbLock(), the bytes are swapped: the left most pixel is returned in the low-order half word. When a 32-bit word containing two pixels is written to the LFB, the left most pixel is in the high-order half word. Remember that.

When a 32-bit word is read using the read pointer returned in info.lfbPtr, the target buffer determines how the data should be interpreted. If the locked buffer is a color buffer, the data should be interpreted as two RGB colors, each containing a 5-bit red value, a 6-bit green value, and a 5-bit blue value. If the locked buffer is a depth buffer, then the data contains two depth values, either 16-bit fixed point z values or 16-bit floating point w values, depending on grDepthBufferMode(). If the locked buffer is an alpha buffer, then the data contains two 8-bit alpha values, stored in the low order byte of each halfword. Table Accessing the Linear Frame Buffer.1 shows the possible data formats.


The 16-bit floating point format for w is shown in Table Accessing the Linear Frame Buffer.1. It has a 4-bit exponent and a 12-bit mantissa. Like IEEE floating point, a leading 1 value in the MSB of the mantissa is hidden. Note that the w floating point value is unsigned only. The w floating point format converts to a real number by using the equation:
1.mantissa * 2exponent
Using this format the minimum depth value is 1.0 (floating point encoding: 0x0000) and the maximum depth value is 65528.0 (floating point encoding: 0xFFFF).

  1. Table Accessing the Linear Frame Buffer.1 Interpreting data read from the LFB.

When a 32-bit word is read using the read pointer acquired with a call to grLfbLock(), the target buffer determines how the data should be interpreted. If the locked buffer is a color buffer, the data should be interpreted as two RGB colors, each containing a 5-bit red value, a 6-bit green value, and a 5-bit blue value. If the locked buffer is a depth buffer, then the data contains two depth values, either 16-bit fixed point z values or 16-bit floating point w values, depending on grDepthBufferMode(). If the locked buffer is an alpha buffer, then the data contains two 8-bit alpha values, stored in the low order byte of each halfword.

buffer

depth buffer mode

color format

physical layout of the data read

GR_BUFFER_FRONTBUFFER
GR_BUFFER_BACKBUFFER
GR_BUFFER_AUXBUFFER

ignored

GR_COLORFORMAT_ARGB or
GR_COLORFORMAT_RGBA









GR_COLORFORMAT_ABGR or
GR_COLORFORMAT_BGRA



GR_BUFFER_AUXBUFFER

GR_DEPTHBUFFER_ZBUFFER

ignored






GR_DEPTHBUFFER_WBUFFER

ignored



GR_BUFFER_AUXBUFFER

ignored

ignored





Download 6.22 Mb.

Share with your friends:
1   ...   78   79   80   81   82   83   84   85   ...   106




The database is protected by copyright ©ininet.org 2024
send message

    Main page