Anders Follin (andersf++at++sgigbg.gothenburg.sgi.com)
Wed, 07 Apr 1999 15:39:08 +0200
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
This archive was generated by hypermail 2.0b2 on Wed Apr 07 1999 - 06:39:34 PDT