Re: Yet another HUD question

New Message Reply Date view Thread view Subject view Author view

Anders Follin (andersf++at++sgigbg.gothenburg.sgi.com)
Wed, 07 Apr 1999 14:36:09 +0200


Bob, Shankle wrote:
>
> Hi Performer users,
>
> I'm relatively new to Performer. I have modified the perfly C code to
> create a simple driving simulator. What I want to do now is create a Head's
> Up Display for this application.
>
> Reading through the archives I know this subject has been addressed many
> times but I can't find a working example to look at. I've been to
> www.dorbie.com and none of the examples apply.
>
> Does anyone have a working example I could have?
>
> thanks much,
> Bob Shankle
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com

Bob,

You need a DRAW callback to be able to call OpenGL from the draw process
(this *must* be done from the draw process). Below you'll find a code
framgent that draws a simple HUD.

rgds

Anders

void channelSetup(void)
{
.
.
.

        pfChanTravFunc(chan, PFTRAV_DRAW, drawHUD);
}

void drawHUD(pfChannel *chan, void *data)
{
        float sin, cos, hFOV, vFOV;
        int x, y, r, angle;

        pfClearChan(chan);
        pfDraw();

        /* Figure out the channel's viewport area. Draw a
           circle which has radius = 1/4 shortest dimension. */

        pfGetChanSize(chan, &x, &y);
        r = PF_MIN2(x, y) / 4.0f;

#ifdef OPENGL

        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        gluOrtho2D(-x/2, x/2, -y/2, y/2);

        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();

        glColor3f(1.0, 1.0, 0.0);
        glDisable(GL_DEPTH_TEST);

        /* Draw the circle */

        glBegin(GL_LINE_LOOP);
        for (angle = 0; angle <= 360; angle += 10) {
                pfSinCos( angle, &sin, &cos);
                glVertex2f(r * cos, r * sin);
        }
        glEnd();

        /* Draw hash marks for target */

        glBegin(GL_LINES);
                glVertex2f(-10, 0.0);
                glVertex2f( 10, 0.0);
                glVertex2f( 0.0, -10);
                glVertex2f( 0.0, 10);
        glEnd();

        glEnable(GL_DEPTH_TEST);
        glMatrixMode(GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();

#endif
}

-- 

Anders Follin M.Sc., Lic.Eng. Senior Systems Engineer

Silicon Graphics AB E-mail andersf++at++gothenburg.sgi.com Drakegatan 10 Switchboard (46) 31 83 78 00 S-412 50 Gothenburg Fax (46) 31 83 78 01 SWEDEN Direct (46) 31 83 78 04 Mobile (46)706 48 78 04 V-net 623-7804 (SGI internal) Mailstop ISE-3290 (SGI internal) www.sgi.se www.sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Wed Apr 07 1999 - 05:36:59 PDT

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