[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

PgSwapDisplay(), PgSwapDisplayCx()

Point the CRT of the video display at a given context

Synopsis:

int PgSwapDisplay( PdOffscreenContext_t *osc,
                   unsigned long flags );

int PgSwapDisplayCx( PhGC_t *gc,
                     PdOffscreenContext_t *osc,
                     unsigned long flags );

Library:

ph

Description:

These functions point the CRT of the video display at the context indicated by osc. These functions can be used for double and triple buffering. They're available only in direct mode.

The flags argument is a combination of the following bits:

Pg_SWAP_BLIT
Blit the contents of the new target to the old one.
Pg_SWAP_VSYNC
Wait for a Vsync to occur before continuing to parse the draw stream.

Note: To guarantee that you can point the CRT at this target, you should create it with the flag Pg_OSC_CRTC_SAFE.

PgSwapDisplay() works on the current graphics context, while you can specify the graphics context gc for PgSwapDisplayCx().

Returns:

0
Success.
-1
An error occurred.

Examples:

This example of double buffering assumes we're in direct mode already:

PdOffscreenContext_t *buf[2];
int cur_buf=1;

// Create an offscreen context from the current screen:
buf[0] = PdCreateOffscreenContext(0,0,0,Pg_OSC_MAIN_DISPLAY);

// Duplicate the buffer:
buf[1] = PdDupOffscreenContext(buf[0],Pg_OSC_CRTC_SAFE);

while (not_done)
{
    PhDCSetCurrent(buf[cur_buf]);
    RenderMyFrame();
    PgSwapDisplay(buf[cur_buf],0);
    PgFlush();
    cur_buf = cur_buf ? 0 : 1;
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PdCreateOffscreenContext(), PdDupOffscreenContext(), PdGetOffscreenContextPtr(), PdOffscreenContext_t, PgContextBlit*()

"Video memory offscreen" in the Raw Drawing and Animation chapter of the Photon Programmer's Guide


[Previous] [Contents] [Index] [Next]