-12- How do I overlay graphics on top of my Performer scene?

New Message Reply Date view Thread view Subject view Author view

Aaron M. Hightower (aaron++at++skips.dseg.ti.com)
06 Oct 93 00:00:01 EST


Typically this is done to implement a heads-up display (HUD).

In the draw function callback, the basic algorithm is:

    save state with pfPushState()
    disable textures, fog, & lighting with pfBasicState()
    save & clear projection matrix
    ortho2()
    save & clear modelling matrix
    draw()
    restore modelling matrix
    restore projection matrix
    restore state with pfPopState()

Or, you can draw your static info in the overlay planes and only redraw
it when the window receives a REDRAW event (moved, resized, etc.).
Changing between drawing to the overlays and drawing to regular
bitplanes takes a big hit.

For things that need to be updated real-time, draw() would consist of:

    zfunction(ZF_ALWAYS);
    zwritemask(0x0);
    draw HUD stuff
    zfunction(ZF_LEQUAL);
    zwritemask(0xffffffff);

-----------------------------------------------------------------------------
Example: (modification of PostDraw from Perfly)

void drawHUD(pfChannel *chan) /* example function */
{
  pfPushState();
  pfBasicState();
  pfPushIdentMatrix();
  zfunction(ZF_ALWAYS);
  zwritemask(0);

/* Example of how to put into pixel coordinates.
 * Not necessary depending on requirements of GL calls
 * IE: You may want to use different coordintes instead
 */
  pfGetChanSize(chan,&chanSizeX,&chanSizeY);
  ortho2(-.5f,chanSizeX-.5f,-.5f,chanSizeY-.5f);

  **** DRAW GL JUNK HERE ****

  zfunction(ZF_LEQUAL);
  zwritemask(0xffffffff);

  pfPopMatrix();
  pfPopState();
}

void
PostDraw(pfChannel *chan, void *data)
{
  drawHUD(chan); /*** Insert this line into PostDraw in perfly ***/
  if (ViewState->stats) pfDrawChanStats(chan);
  if(chan == ViewState->masterChan) pfuCollectInput();
}


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:11 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.