Added setDataVariance(DYNAMIC) to stats text labels that are dyanmically updated.
This commit is contained in:
parent
7868909f43
commit
96760970ed
@ -55,7 +55,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
#define INLINE_DRAWABLE_DRAW
|
||||
// #define INLINE_DRAWABLE_DRAW
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
namespace osgText {
|
||||
|
||||
//#define NEW_APPROACH
|
||||
#define NEW_APPROACH
|
||||
|
||||
class OSGTEXT_EXPORT TextBase : public osg::Drawable
|
||||
{
|
||||
|
@ -280,7 +280,27 @@ void Text::computeGlyphRepresentation()
|
||||
if (!_texcoords) { _texcoords = new osg::Vec2Array(osg::Array::BIND_PER_VERTEX); _texcoords->setBufferObject(_vbo.get()); }
|
||||
else _texcoords->clear();
|
||||
|
||||
#if 0
|
||||
_textureGlyphQuadMap.clear();
|
||||
#else
|
||||
for(TextureGlyphQuadMap::iterator itr = _textureGlyphQuadMap.begin();
|
||||
itr != _textureGlyphQuadMap.end();
|
||||
++itr)
|
||||
{
|
||||
GlyphQuads& glyphquads = itr->second;
|
||||
glyphquads._glyphs.clear();
|
||||
for(Primitives::iterator pitr = glyphquads._primitives.begin();
|
||||
pitr != glyphquads._primitives.end();
|
||||
++pitr)
|
||||
{
|
||||
(*pitr)->clear();
|
||||
(*pitr)->dirty();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
_lineCount = 0;
|
||||
|
||||
if (_text.empty())
|
||||
@ -1113,11 +1133,11 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
|
||||
state.Normal(_normal.x(), _normal.y(), _normal.z());
|
||||
|
||||
#ifdef NEW_APPROACH
|
||||
bool usingVertexArrayObjects = usingVertexBufferObjects && state.useVertexArrayObject(_useVertexArrayObject);
|
||||
|
||||
VertexArrayState* vas = state.getCurrentVertexArrayState();
|
||||
bool usingVertexArrayObjects = usingVertexBufferObjects && state.useVertexArrayObject(_useVertexArrayObject);
|
||||
bool requiresSetArrays = !usingVertexBufferObjects || !usingVertexArrayObjects || vas->getRequiresSetArrays();
|
||||
|
||||
bool requiresSetArrays = !usingVertexArrayObjects || vas->getRequiresSetArrays();
|
||||
if (requiresSetArrays)
|
||||
{
|
||||
vas->lazyDisablingOfVertexAttributes();
|
||||
@ -1233,11 +1253,11 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
|
||||
}
|
||||
|
||||
#ifdef NEW_APPROACH
|
||||
if (!usingVertexArrayObjects && !requiresSetArrays)
|
||||
if (!usingVertexArrayObjects)
|
||||
{
|
||||
// unbind the VBO's if any are used.
|
||||
state.unbindVertexBufferObject();
|
||||
state.unbindElementBufferObject();
|
||||
vas->unbindVertexBufferObject();
|
||||
vas->unbindElementBufferObject();
|
||||
}
|
||||
#else
|
||||
// unbind the VBO's if any are used.
|
||||
@ -1378,20 +1398,17 @@ void Text::drawForegroundText(osg::State& state, const GlyphQuads& glyphquad, co
|
||||
if (coords.valid() && !coords->empty())
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
bool usingVertexArrayObjects = usingVertexBufferObjects && state.useVertexArrayObject(_useVertexArrayObject);
|
||||
|
||||
VertexArrayState* vas = state.getCurrentVertexArrayState();
|
||||
bool usingVertexArrayObjects = usingVertexBufferObjects && state.useVertexArrayObject(_useVertexArrayObject);
|
||||
bool requiresSetArrays = !usingVertexBufferObjects || !usingVertexArrayObjects || vas->getRequiresSetArrays();
|
||||
|
||||
if(_colorGradientMode == SOLID)
|
||||
{
|
||||
OSG_NOTICE<<" Text::drawForegroundText() vas->disableColorArray(state);"<<std::endl;
|
||||
vas->disableColorArray(state);
|
||||
state.Color(colorMultiplier.r()*_color.r(),colorMultiplier.g()*_color.g(),colorMultiplier.b()*_color.b(),colorMultiplier.a()*_color.a());
|
||||
}
|
||||
else
|
||||
{
|
||||
bool requiresSetArrays = !usingVertexArrayObjects || vas->getRequiresSetArrays();
|
||||
OSG_NOTICE<<" Text::drawForegroundText() "<<requiresSetArrays<<"vas->setColorArray(state, colors.get())"<<std::endl;
|
||||
if (requiresSetArrays)
|
||||
{
|
||||
vas->setColorArray(state, colors.get());
|
||||
|
@ -128,7 +128,7 @@ osg::VertexArrayState* TextBase::createVertexArrayState(osg::RenderInfo& renderI
|
||||
}
|
||||
else
|
||||
{
|
||||
// OSG_NOTICE<<" Setup VertexArrayState to without using VAO "<<vas<<std::endl;
|
||||
OSG_NOTICE<<" Setup VertexArrayState to without using VAO "<<vas<<std::endl;
|
||||
}
|
||||
|
||||
return vas;
|
||||
|
@ -1184,6 +1184,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
|
||||
frameRateValue->setCharacterSize(_characterSize);
|
||||
frameRateValue->setPosition(pos);
|
||||
frameRateValue->setText("0.0");
|
||||
frameRateValue->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
frameRateValue->setDrawCallback(new AveragedValueTextDrawCallback(viewer->getViewerStats(),"Frame rate",-1, true, 1.0));
|
||||
|
||||
@ -1382,6 +1383,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
|
||||
averageValue->setCharacterSize(_characterSize);
|
||||
averageValue->setPosition(pos);
|
||||
averageValue->setText("1000");
|
||||
averageValue->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
pos.x() = averageValue->getBoundingBox().xMax() + 2.0f*_characterSize;
|
||||
|
||||
@ -1405,6 +1407,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
|
||||
minValue->setCharacterSize(_characterSize);
|
||||
minValue->setPosition(pos);
|
||||
minValue->setText("1000");
|
||||
minValue->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
pos.x() = minValue->getBoundingBox().xMax() + 2.0f*_characterSize;
|
||||
|
||||
@ -1427,6 +1430,8 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
|
||||
maxValue->setCharacterSize(_characterSize);
|
||||
maxValue->setPosition(pos);
|
||||
maxValue->setText("1000");
|
||||
maxValue->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
|
||||
pos.x() = maxValue->getBoundingBox().xMax();
|
||||
|
||||
@ -1449,6 +1454,8 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
|
||||
requestList->setCharacterSize(_characterSize);
|
||||
requestList->setPosition(pos);
|
||||
requestList->setText("0");
|
||||
requestList->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
|
||||
pos.x() = requestList->getBoundingBox().xMax() + 2.0f*_characterSize;;
|
||||
|
||||
@ -1471,6 +1478,8 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
|
||||
compileList->setCharacterSize(_characterSize);
|
||||
compileList->setPosition(pos);
|
||||
compileList->setText("0");
|
||||
compileList->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
|
||||
pos.x() = maxLabel->getBoundingBox().xMax();
|
||||
|
||||
@ -1555,6 +1564,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
|
||||
camStatsText->setCharacterSize(_characterSize);
|
||||
camStatsText->setPosition(pos);
|
||||
camStatsText->setText("");
|
||||
camStatsText->setDataVariance(osg::Object::DYNAMIC);
|
||||
camStatsText->setDrawCallback(new CameraSceneStatsTextDrawCallback(*citr, cameraCounter));
|
||||
|
||||
// Move camera block to the right
|
||||
@ -1628,6 +1638,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
|
||||
text->setFont(_font);
|
||||
text->setCharacterSize(_characterSize);
|
||||
text->setPosition(pos);
|
||||
text->setDataVariance(osg::Object::DYNAMIC);
|
||||
text->setDrawCallback(new ViewSceneStatsTextDrawCallback(*it, viewCounter));
|
||||
|
||||
pos.x() += 10 * _characterSize + 2 * backgroundMargin + backgroundSpacing;
|
||||
@ -1661,6 +1672,7 @@ void StatsHandler::createTimeStatsLine(const std::string& lineLabel,
|
||||
value->setCharacterSize(_characterSize);
|
||||
value->setPosition(pos);
|
||||
value->setText("0.0");
|
||||
value->setDataVariance(osg::Object::DYNAMIC);
|
||||
|
||||
if (!timeTakenName.empty())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user