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

PdCreateDirectContext()

Create a direct-mode context

Synopsis:

PdDirectContext_t *PdCreateDirectContext( void );

Library:

ph

Description:

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.


Note: You must target this function at a specific card by calling PdSetTargetDevice().

Returns:

A pointer to a PdDirectContext_t structure if successful, or NULL on failure.

Examples:

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);

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PdDirectStart(), PdDirectStop(), PdReleaseDirectContext(), PdSetTargetDevice()

"Direct mode" in the Raw Drawing and Animation chapter of the Photon Programmer's Guide