Table of Contents Glide Programming Guide


What Happens When a Special Effect is Enabled During an LFB Write?



Download 6.22 Mb.
Page87/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   83   84   85   86   87   88   89   90   ...   106
GLIDEPGM

2What Happens When a Special Effect is Enabled During an LFB Write?


If depth buffering is enabled during linear frame buffer writes, incoming pixel depths are either retrieved from the incoming pixel or from the constant depth register, depending on the write mode. Note that this can lead to some very odd effects: rarely will an application wish to depth buffer values being written to the depth buffer. If depth buffering is not desired, then the application should disable it by calling grDepthBufferMode() with the parameter GR_DEPTHBUFFER_DISABLE. Note that depth biasing is disabled during linear frame buffer writes because of a resource conflict between depth biasing and linear frame buffer writes.
If alpha testing is enabled during linear frame buffer writes, incoming pixel alpha values are either retrieved from the incoming pixel or from the constant alpha register, depending on the write mode. If alpha testing is not desired, then the application should set the alpha test function to GR_CMP_ALWAYS.
If alpha blending is enabled during linear frame buffer writes, incoming pixel alpha values are either retrieved from the incoming pixel or from the constant alpha register, depending on the write mode. If alpha blending is not desired, then the application should call grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO)
All other effects, such as chroma-keying and fog, act the same in linear frame buffer write modes as in normal rendering operations and are disabled as described in Chapter Chapter 8. .
It is possible to directly read from and write to the alpha/depth buffer for various special effects. To write directly to the alpha/depth buffer call grLfbLock() with a buffer parameter of GR_BUFFER_AUXBUFFER, and then use the newly acquired pointer. When writing to the depth buffer, incoming values must be in the correct format (16-bit floating point for w buffering or 16-bit integer for linear z buffering). The 16-bit floating point format used for w buffering is described in Table Accessing the Linear Frame Buffer.1. Remember that if depth buffering is enabled and the application is writing directly to the depth buffer, unexpected results may occur since, in essence, the application is depth buffering writes to the depth buffer.
Example Accessing the Linear Frame Buffer.3 Writing one 565 RGB pixel to the back buffer (RGB ordering).

FxU16 pixel = 0xFFFF; // White pixel


GrLfbInfo_t info;
FxU16 *ptr;

if ( grLfbLock( GR_WRITE_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_565, GR_ORIGIN_ANY, FXTRUE, &info)) {


ptr = info.lfbPtr;
ptr[x + y*info.strideInBytes] = pixel;
grLfbUnlock(GR_WRITE_ONLY, GR_BUFFER_BACKBUFFER);
}

Example Accessing the Linear Frame Buffer.4 Writing two 565 RGB pixels to the back buffer (RGB color ordering).


The significant difference between this example and the last one is the type of the pointer ptr that is used to access frame buffer memory.

GrLfbInfo_t info;


FxU32 *ptr;
Fx16 whitePixel, blackPixel;
FxU32 pixel;

whitePixel = 0xFFFF;


blackPixel = 0x0000;

// This will make the black pixel the leftmost of the pair.


pixel = ( ( ( FxU32 ) blackPixel ) << 16 ) | whitePixel;

if ( grLfbLock( GR_WRITE_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_565, GR_ORIGIN_ANY, FXTRUE, &info)) {


ptr = info.lfbPtr;
ptr[x + y*info.strideInBytes] = pixel;
grLfbUnlock(GR_WRITE_ONLY, GR_BUFFER_BACKBUFFER);
}
Example Accessing the Linear Frame Buffer.5 Writing one 888 RGB pixel to the back buffer (ARGB color ordering).

GrLfbInfo_t info;


FxU32 pixel = 0x00FF0000; // Red pixel

if ( grLfbLock( GR_WRITE_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_888, GR_ORIGIN_ANY, FXTRUE, &info)) {


info.lfbPtr[x + y* info.strideInBytes] = pixel;
grLfbUnlock(GR_WRITE_ONLY, GR_BUFFER_BACKBUFFER);
}

Download 6.22 Mb.

Share with your friends:
1   ...   83   84   85   86   87   88   89   90   ...   106




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

    Main page