Code improvements from Norman Vine
This commit is contained in:
parent
ac5def8fd5
commit
4d6ac0ddf5
1 changed files with 110 additions and 133 deletions
|
@ -62,6 +62,26 @@ void FGATCDisplay::update(double dt) {
|
|||
static string msg1 = "";
|
||||
static string msg2 = "";
|
||||
|
||||
if( rep_msg || msgList.size() ) {
|
||||
//cout << "In FGATC::update()" << endl;
|
||||
SGPropertyNode *xsize_node = fgGetNode("/sim/startup/xsize");
|
||||
SGPropertyNode *ysize_node = fgGetNode("/sim/startup/ysize");
|
||||
int iwidth = xsize_node->getIntValue();
|
||||
int iheight = ysize_node->getIntValue();
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluOrtho2D( 0, iwidth, 0, iheight );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
glDisable( GL_LIGHTING );
|
||||
|
||||
glColor3f( 0.9, 0.4, 0.2 );
|
||||
|
||||
if(rep_msg) {
|
||||
//cout << "dsp_offset1 = " << dsp_offset1 << " dsp_offset2 = " << dsp_offset2 << endl;
|
||||
if(dsp_offset1 == 0) {
|
||||
|
@ -82,40 +102,15 @@ void FGATCDisplay::update(double dt) {
|
|||
|
||||
float fps = general.get_frame_rate();
|
||||
|
||||
//cout << "In FGATC::update()" << endl;
|
||||
SGPropertyNode *xsize_node = fgGetNode("/sim/startup/xsize");
|
||||
SGPropertyNode *ysize_node = fgGetNode("/sim/startup/ysize");
|
||||
int iwidth = xsize_node->getIntValue();
|
||||
int iheight = ysize_node->getIntValue();
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluOrtho2D( 0, iwidth, 0, iheight );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
glDisable( GL_LIGHTING );
|
||||
|
||||
glColor3f( 0.9, 0.4, 0.2 );
|
||||
|
||||
// guiFnt.drawString( rep_msg_str.c_str(),
|
||||
// int(iwidth - guiFnt.getStringWidth(buf) - 10 - (int)dsp_offset),
|
||||
// (iheight - 20) );
|
||||
// guiFnt.drawString( rep_msg_str.c_str(),
|
||||
// int(iwidth - guiFnt.getStringWidth(buf) - 10 - (int)dsp_offset),
|
||||
// (iheight - 20) );
|
||||
guiFnt.drawString( msg1.c_str(),
|
||||
int(iwidth - 10 - dsp_offset1),
|
||||
(iheight - 20) );
|
||||
guiFnt.drawString( msg2.c_str(),
|
||||
int(iwidth - 10 - dsp_offset2),
|
||||
(iheight - 20) );
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
glEnable( GL_LIGHTING );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPopMatrix();
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPopMatrix();
|
||||
|
||||
// Try to scroll at a frame rate independent speed
|
||||
// 40 pixels/second looks about right for now
|
||||
|
@ -145,35 +140,9 @@ void FGATCDisplay::update(double dt) {
|
|||
//cout << "Stopping single message\n";
|
||||
msgList_itr = msgList.erase(msgList_itr);
|
||||
} else if(m.counter > m.start_count) {
|
||||
//cout << "Displaying single message\n";
|
||||
// Display the message
|
||||
// FIXME - I'm sure all this opengl code should only be called once until all drawing is finished
|
||||
SGPropertyNode *xsize_node = fgGetNode("/sim/startup/xsize");
|
||||
SGPropertyNode *ysize_node = fgGetNode("/sim/startup/ysize");
|
||||
int iwidth = xsize_node->getIntValue();
|
||||
int iheight = ysize_node->getIntValue();
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
gluOrtho2D( 0, iwidth, 0, iheight );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable( GL_DEPTH_TEST );
|
||||
glDisable( GL_LIGHTING );
|
||||
|
||||
glColor3f( 0.9, 0.4, 0.2 );
|
||||
|
||||
guiFnt.drawString( m.msg.c_str(),
|
||||
100,
|
||||
(iheight - 40) ); // TODO - relate the distance in that the string is rendered to the string length.
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
glEnable( GL_LIGHTING );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPopMatrix();
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPopMatrix();
|
||||
++m.counter;
|
||||
msgList[i] = m;
|
||||
++msgList_itr;
|
||||
|
@ -186,6 +155,13 @@ void FGATCDisplay::update(double dt) {
|
|||
}
|
||||
}
|
||||
}
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
glEnable( GL_LIGHTING );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPopMatrix();
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
void FGATCDisplay::RegisterSingleMessage(string msg, int delay) {
|
||||
|
@ -221,3 +197,4 @@ void FGATCDisplay::CancelRepeatingMessage() {
|
|||
dsp_offset2 = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue