| 130 | //----------------------------------------------------------------------------- |
| 131 | |
| 132 | void GuiGraphCtrl::onRender(Point2I offset, const RectI &updateRect) |
| 133 | { |
| 134 | if (mBlendSB.isNull()) |
| 135 | { |
| 136 | GFXStateBlockDesc desc; |
| 137 | |
| 138 | desc.setBlend(true, GFXBlendSrcColor, GFXBlendInvSrcColor); |
| 139 | mBlendSB = GFX->createStateBlock(desc); |
| 140 | |
| 141 | desc.setBlend(false, GFXBlendOne, GFXBlendZero); |
| 142 | mSolidSB = GFX->createStateBlock(desc); |
| 143 | |
| 144 | } |
| 145 | |
| 146 | GFX->setStateBlock( mBlendSB ); |
| 147 | |
| 148 | GFX->getDrawUtil()->drawRectFill( updateRect, mProfile->mFillColor ); |
| 149 | |
| 150 | GFX->setStateBlock( mSolidSB ); |
| 151 | |
| 152 | const Point2I globalPos = getGlobalBounds().point; |
| 153 | const F32 midPointY = F32( globalPos.y ) + F32( getExtent().y ) * mCenterY; |
| 154 | |
| 155 | for( S32 k = 0; k < MaxPlots; ++ k ) |
| 156 | { |
| 157 | // Check if there is an autoplot and the proper amount of time has passed, if so add datum. |
| 158 | if( mAutoPlot[ k ] && mAutoPlotDelay[ k ] < (Sim::getCurrentTime() - mAutoPlotLastDisplay[ k ] ) ) |
| 159 | { |
| 160 | mAutoPlotLastDisplay[ k ] = Sim::getCurrentTime(); |
| 161 | addDatum( k, Con::getFloatVariable( mAutoPlot[ k ] ) ); |
| 162 | } |
| 163 | |
| 164 | // Nothing to graph |
| 165 | if( mGraphData[ k ].size() == 0 ) |
| 166 | continue; |
| 167 | |
| 168 | // Adjust scale to max value + 5% so we can see high values |
| 169 | F32 Scale = F32( getExtent().y ) / F32( mGraphMax[ k ] * 1.05 ); |
| 170 | |
| 171 | const S32 numSamples = mGraphData[ k ].size(); |
| 172 | F32 graphOffset; |
| 173 | switch( mGraphType[ k ] ) |
| 174 | { |
| 175 | case Bar: |
| 176 | { |
| 177 | F32 prevOffset = 0; |
| 178 | |
| 179 | for( S32 sample = 0; sample < numSamples; ++ sample ) |
| 180 | { |
| 181 | PrimBuild::begin( GFXTriangleStrip, 4 ); |
| 182 | PrimBuild::color( mGraphColor[ k ] ); |
| 183 | |
| 184 | graphOffset = F32( getExtent().x ) / F32( MaxDataPoints ) * F32( sample + 1 ); |
| 185 | |
| 186 | PrimBuild::vertex2f( globalPos.x + prevOffset, |
| 187 | midPointY - ( getDatum( k, sample ) * Scale ) ); |
| 188 | |
| 189 | PrimBuild::vertex2f( globalPos.x + graphOffset, |
nothing calls this directly
no test coverage detected