Re: Showing bitmaps in the Performer window

New Message Reply Date view Thread view Subject view Author view

Mario Veraart (rioj7++at++fel.tno.nl)
Tue, 28 Oct 1997 15:23:43 +0100 (MET)


>
>
> I have been trying to look for a good way to show bitmaps as overlays on the
> performer window. Some options come to mind:
>
> - Creating 2 triangles and mapping them with a texture (how?)
This is to my opinion the most easy solution. You must draw the
geometry in the postDraw callback routine that sets up a view frustum
that is orthographic. You can take any range of coordinates for x and
y. Using this mapping construct a quad in a pfGeoset that si texture
with the bitmap you want. This can be done the first time you enter
the HUD fuction and keep the pfGeoset pointer. In the pfGeostate
attached set the right texture parameters. Then you call the
pfGeoset::draw() function to put it to screen.
See mail below from Fred Clyne for a HUD routine

> - Using OpenGL to write pixels directly each frame
Could be done is not portable to IRISGL platforms

> Jukka Väisänen vaizki++at++iscape.fi
> Iscape Software http://www.iscape.fi/

Mario

-----------------------------------------------
Subject: Re: HUD problems; how to use OpenGL?
From: "Fred Clyne" <fred++at++octave.cambridge.com>
Date: Sat, 3 Aug 1996 18:47:31 -0400

Funny you should ask, I just did this today.
I am working in C but you should be able to translate. Also, this works
for both IrisGL and OpenGL. In the draw callback, after you render the
scene, add your call to the HUD function:

void MyDraw(pfChannel *chan, void *data)
{
pfClearChan(chan);
pfDraw();
DrawHUD();
}

The HUD drawing routine needs to set its perspective matrix with an
ortho command and the viewing matrix with some matrix commands. I
had trouble with the different coordinate systems being used, so be
careful. The scene is in Performer coordinates (z-up, y-away, x-right).
So I created my HUD with z and x coords to be "consistent".
I put my data in gsets and created an ortho frustum that I remember in
the shared data structure along with DCS nodes to move things around on
the HUD. I also didn't wory about saving the perspective matrix since
the HUD is drawn last and the matrix will be set again by the channel.

at init time:
frust = pfNewFrust(arena);
pfFrustNearFar(frust,-1.0f,1.0f);
pfMakeOrthoFrust(frust,left,right,bottom,top);
sharedData->frust = frust;
..
sharedData->numGsets = nn;
sharedData->gsetList[0] = ...
sharedData->dcsList[0] = ...

APP updates the DCS nodes each frame:
pfDCSRot(sharedData->dcsList[0],...

void DrawHUD(void)
{
pfMatrix mat;
int ii;

/* work in my own graphics state */
pfPushState();
pfBasicState();

/* turn of the zbuffer so this always shows on top */
#ifdef IRISGL
zbuffer(FALSE);
#else
#ifdef OPENGL
glDisable(GL_DEPTH_TEST);
#else
...Please Define IRISGL/OPENGL...
#endif
#endif

/* create the ortho projection */
pfApplyFrust(sharedData->frust);

/* set the view matrix - push a GL ident matrix on stack */
pfPushIdentMatrix();
/* rotate back to Perf coords */
pfRotate(PF_X,-90.f);

/* draw the HUD */
for (ii=0; ii<sharedData->numGsets; ++ii)
        {
        pfPushMatrix();
        pfGetDCSMat(sharedData->dcsList[ii],mat)
        pfMultMatrix(mat);
        pfDrawGSet(sharedData->gsetList[ii]);
        pfPopMatrix();
        }

/* restore the view matrix */
pfPopMatrix();

/* restore zbuffer testing */
#ifdef IRISGL
zbuffer(TRUE);
#else
#ifdef OPENGL
glEnable(GL_DEPTH_TEST);
#else
...Please Define IRISGL/OPENGL...
#endif
#endif

/* restore the graphics state */
pfPopState();

}

Hope this helps.

--

Fred Clyne

Cambridge Research Associates office: 703-790-0505 x 7211 1430 Spring Hill Road, Suite 200 fax: 703-790-0370 McLean, VA 22102 email: fred++at++cambridge.com

======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++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:56:08 PDT

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