43 glColor3fv( colorWhite );
44 glDisable( GL_LIGHTING );
47 float percent = (m_current-currentDifference) / currentRange;
51 glVertex3f( m_slope + x + offset*width, y+height, 0);
53 glVertex3f( x + offset*width, y, 0);
54 glTexCoord2f( isNegative*percent, 0 );
55 glVertex3f( x+ offset*width +currentPercentage * width*percent, y, 0 );
56 glTexCoord2f( isNegative*percent, 1 );
57 glVertex3f( m_slope + x+ offset*width +currentPercentage * width*percent, y + height, 0 );
65 else if( current < m_min )
75 if( m_max < m_current )
83 if( m_min > m_current )
92 void HudLoadBar::update() {
94 float positivePercentage;
95 float negativePercentage;
97 positivePercentage = 1;
98 currentRange = m_max - m_min;
99 currentDifference = m_min;
100 }
else if( m_max <= 0 ) {
101 negativePercentage = 1;
102 currentRange = m_max - m_min;
103 currentDifference = m_max;
105 currentDifference = 0;
106 positivePercentage = m_max / (m_max - m_min);
107 currentRange = m_current < 0 ? -m_min : m_max;
109 negativePercentage = 1 - positivePercentage;
112 currentPercentage = negativePercentage;
114 currentPercentage = positivePercentage;
116 offset = negativePercentage;
117 isNegative = m_current < 0 ? -1.0 : 1.0;