Re: Overlay graphics on performer

New Message Reply Date view Thread view Subject view Author view

Rob Jenkins (robj++at++barney.reading.sgi.com)
Wed, 16 Aug 1995 19:55:40 +0100


On Aug 16, 1:15pm, SSPSU91++at++aol.com wrote:
> Subject: Overlay graphics on performer
> The following question is related to page 365 of the IRIS Performer
> Programming Guide, the frequently asked question "How do I overlay graphics
> on top of my IRIS Performer scene?" .
> For steps 3 (save and clear the projection matrix) and 5 (save and clear the
> modelling matrix) of the answer what are the specific Performer calls to do
> this? Also for steps 7 and 9 (restoring the modelling and projection
> matrices).
> Is there an example of this anywhere in the Performer library?
>
> Stephanie Sroczyk, JJM Systems Inc.
>-- End of excerpt from SSPSU91++at++aol.com

Stephanie

This is covered pretty well in the info-performer archives:

ftp sgigate.sgi.com as anonymous, cd /pub/Performer/selected-topics if you ls
ther are *lots* of this in there - the code below is taken out of the file
'hud':

>From the FAQ: (Sharon Fischler)
------------
Subject: -12- How do I overlay graphics on top of my Performer scene?
Date: 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();
}

so the pfPush../pfPop... calls are the ones you are after.

Hope this helps

Cheers
Rob

-- 
________________________________________________________________
Rob Jenkins, Software Support Group, Silicon Graphics UK Ltd.       
1530 Arlington Business Park, Theale, Reading, UK, RG7 4SB. 
tel 01734 257736, fax 01734 257553, email robj++at++reading.sgi.com,

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:51:48 PDT

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