Create a direct-mode context
PdDirectContext_t *PdCreateDirectContext( void );
ph
This function creates a direct-mode context. The context isn't activated at this point, and the graphics driver is still operating normally (i.e it's still Reply Blocked on Photon).
When an application enters direct mode, it's requesting that the graphics driver receive draw streams and service messages directly from the application, instead of from Photon. The driver blocks on the application, which is now responsible for telling the graphics driver what to do.
A pointer to a PdDirectContext_t structure if successful, or NULL on failure.
PdDirectContext_t *DirectMode=NULL; PhDrawContext_t *Olddc=NULL; PhRid_t rid_array[10]; DirectMode=PdCreateDirectContext(); if (DirectMode == NULL) { // error code } if( PdGetDevices(rid_array, 10) > 0) { PdSetTargetDevice( (PhDrawContext_t *) DirectMode, rid_array[0] ); Olddc=PdDirectStart(DirectMode); PgSetFillColor(Pg_PURPLE); PgDrawIRect(0,0,300,300,Pg_DRAW_FILL); PgFlush(); // Draw the purple rect PdDirectStop(DirectMode); // When the driver leaves direct mode, an expose event // is emitted, which will erase our rectangle, so we // sleep for a bit so we can see that the rectangle // was drawn. sleep(5); } PdReleaseDirectContext(DirectMode); PhDCSetCurrent(Olddc);
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PdDirectStart(), PdDirectStop(), PdReleaseDirectContext(), PdSetTargetDevice()
“Direct mode” in the Raw Drawing and Animation chapter of the Photon Programmer's Guide