Autopilot-CVS: sim/src/heli-3d heli-3d.cpp,2.0,2.1
Status: Alpha
Brought to you by:
tramm
|
From: Trammell H. <tr...@us...> - 2003-02-19 03:22:50
|
Update of /cvsroot/autopilot/sim/src/heli-3d
In directory sc8-pr-cvs1:/tmp/cvs-serv30757/src/heli-3d
Modified Files:
heli-3d.cpp
Log Message:
Draw the FPS and position on the HUD rather than on the ground
Index: heli-3d.cpp
===================================================================
RCS file: /cvsroot/autopilot/sim/src/heli-3d/heli-3d.cpp,v
retrieving revision 2.0
retrieving revision 2.1
diff -u -d -r2.0 -r2.1
--- heli-3d.cpp 22 Sep 2002 02:07:30 -0000 2.0
+++ heli-3d.cpp 19 Feb 2003 03:22:47 -0000 2.1
@@ -169,51 +169,66 @@
static void
draw_text(
- const char * buf
+ const char * buf,
+ float x,
+ float y
)
{
+ const float scale = 1.2;
+
+ glPushMatrix();
+ glLoadIdentity();
+
+ glTranslatef( x, y, -1 );
+
+ glScalef( 0.0001, 0.0001, 0.0001 );
+ glScalef( scale, scale, scale );
+
while( *buf )
glutStrokeCharacter(
GLUT_STROKE_MONO_ROMAN,
*buf++
);
+
+ glPopMatrix();
}
static void
draw_fps()
{
- char buf[8];
-
- sprintf( buf, "%3.2f", compute_fps() );
-
- glPushMatrix();
- glTranslatef( 0.95, 0.95, 0.0 );
- glScalef( 0.011, 0.011, 0.011 );
+ char buf[12];
- draw_text( buf );
+ snprintf(
+ buf,
+ sizeof(buf),
+ "FPS=%3.2f",
+ compute_fps()
+ );
- glPopMatrix();
+ draw_text( buf, -0.25, -0.230 );
}
static void
draw_pos(
double x,
- double y
+ double y,
+ double z
)
{
char buf[ 32 ];
- glPushMatrix();
- glTranslatef( x, 0.1, y );
- glRotatef( 90, 0, -1, 0 );
- glRotatef( 90, -1, 0, 0 );
- glScalef( 0.01, 0.01, 0.01 );
+ snprintf(
+ buf,
+ sizeof(buf),
+ "Pos=(% 3.2f,% 3.2f,% 3.2f)",
+ x,
+ y,
+ z
+ );
- sprintf( buf, "(%3.2f,%3.2f)", x, y );
- draw_text( buf );
+ draw_text( buf, -0.25, -0.25 );
- glPopMatrix();
}
static void
@@ -243,7 +258,7 @@
);
draw_fps();
- draw_pos( state.x, state.y );
+ draw_pos( state.x, state.y, -state.z );
glutPostRedisplay();
glutSwapBuffers();
|