Point the CRT of the video display at a given context
int PgSwapDisplay( PdOffscreenContext_t *osc, unsigned long flags ); int PgSwapDisplayCx( PhGC_t *gc, PdOffscreenContext_t *osc, unsigned long flags );
ph
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:
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().
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; }
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PdCreateOffscreenContext(), PdDupOffscreenContext(), PdGetOffscreenContextPtr(), PdOffscreenContext_t, PgContextBlit*()
“Video memory offscreen” in the Raw Drawing and Animation chapter of the Photon Programmer's Guide