Look back to Figure An Introduction to Glide.2 in Chapter Chapter 1. . The pixel pipeline is not bypassed when writing directly to the linear frame buffer, unless you disable it. In fact, writing to the linear frame buffer is functionally equivalent to sending individual pixels down the pixel pipeline. Effects such as depth buffering, fog, chroma-keying, and alpha blending are not automatically disabled during LFB writes. As a result, unexpected results can occur unless all special effects are disabled, or at least set to a known state.
1Disabling All Special Effects
If “pure” unmodified writes to the frame buffer are desired (a la VGA direct access), two mechanisms can be used to effect this. The first technique is to save the global state by calling grGlideGetState(), then disable all special effects via grDisableAllEffects(). Special effects can then be re-enabled individually; subsequent writes are performed on the linear frame buffer with only the desired effects enabled. When raw access to the frame buffer is complete, a call to grGlideSetState() resets the graphics hardware to its previous state.
void grGlideGetState( GrState *state )
void grDisableAllEffects( void )
void grGlideSetState( const GrState *state )
The other option for unmodified writes is enabling a hardware special effects pipeline bypass by setting the pixelPipeline parameter to grLfbLock() to FXFALSE. This is useful when rendering overlays or text directly to the screen and the application does not wish to disable all current effects (such as fog, depth buffering, etc.) individually.
Note that if the pixel pipeline is bypassed, then no effects are enabled with the exception of dithering. This includes clipping to the grClipWindow(), so an application must be careful not to write outside of the visible display. The values of grColorMask() and grDepthMask() are also ignored when the pixel pipeline is bypassed.
Example Accessing the Linear Frame Buffer.2 Enabling specific special effects.
The following code fragment illustrates how to save Glide’s state, set certain special effects, then restore Glide’s state.
GrState state;
GrLfbInfo_t info;
// Save the state
grGlideGetState( &state );
// Selectively enable some effects
grChromakeyMode( GR_CHROMAKEY_ENABLE );
grFogMode( GR_FOG_WITH_TABLE );
if ( grLfbLock( GR_WRITE_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_ANY, GR_ORIGIN_ANY, FXTRUE, &info)) {
// write some pixels using info.lfbPtr
// ...
grLfbUnlock(GR_WRITE_ONLY, GR_BUFFER_BACKBUFFER);
}
// Restore the state
grGlideSetState( &state );
Share with your friends: |