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


Set the currently active draw context


PhDrawContext_t *PhDCSetCurrent( 
                     void *draw_context );


This function makes the provided draw_context active. Calling this function with NULL makes the default draw context active. The default draw context emits draws to graphics drivers via Photon.

A draw context is anything that defines the flow of the draw stream. Print Contexts and Memory contexts are types of draw contexts - it may help to think of them as specialized subclasses of the draw context.

Contexts that may be set using this function:

Draw contexts
There's usually only one basic draw context per application. Draw contexts are used to deliver the draw stream to graphics drivers via Photon.
Print contexts
created via PpPrintCreatePC(). Print contexts are used to produce printed output from Photon applications.
Memory contexts
created via PmMemCreateMC(). Memory contexts are used to draw into memory to build images for manipulation or display.


The old draw context, or NULL if the new context can't be made current (active), in which case errno has specifics of the error.


In the following example, the print context pc is made active by calling PpPrintStart(). PpPrintStart() returns the context that the print context is replacing. The returned context is stored to enable us to restore the context that was active at the time we decided to start printing.

PhDrawContext_t *dc;
PpPrintContext_t *pc;
PmMemoryContext_t *mc;
if( ( dc = PpPrintStart( pc ) ) == -1 )
        perror( "unable to activate print context" );
        // do print stuff

        // Then restore context which was active before we
        // started printing.  This is equivalent to doing
        // a PpPrintStop() followed by a PmMemStart(), or
        // PpPrintStart(), depending on what type of draw
        // context was active previously.

        PhDCSetCurrent( dc );



Interrupt handler No
Signal handler No
Thread No

See also:

PhDCGetCurrent(), PmMemCreateMC(), PpPrintCreatePC(), PpPrintStart()

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