diff --git a/include/osgText/Text b/include/osgText/Text index 67d861461..3c7b5a58a 100644 --- a/include/osgText/Text +++ b/include/osgText/Text @@ -313,7 +313,7 @@ public: osg::buffered_object _transformedBackdropCoords[8]; ColorCoords _colorCoords; - osg::ref_ptr _quadIndices; + osg::ref_ptr _quadIndices; void updateQuadIndices(); GlyphQuads(); diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index 5cedc7cb0..77bf8786b 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -2091,26 +2091,33 @@ void Text::GlyphQuads::initGlyphQuads() } } - _quadIndices = new DrawElementsUInt(PrimitiveSet::TRIANGLES); + _quadIndices = new DrawElementsUShort(PrimitiveSet::TRIANGLES); } void Text::GlyphQuads::updateQuadIndices() { - _quadIndices->clear(); - if (_coords->size() % 4 != 0) + unsigned int numCoords = _coords->size(); + unsigned int numQuads = numCoords/4; + unsigned int numVertices = numQuads*6; + + if (numCoords % 4 != 0) { OSG_WARN << "size of _coords is not divisible by 4."; } - for (unsigned int i = 0; i < (unsigned int)_coords->size(); i += 4) - { - _quadIndices->push_back(i); - _quadIndices->push_back(i + 1); - _quadIndices->push_back(i + 3); - _quadIndices->push_back(i + 1); - _quadIndices->push_back(i + 2); - _quadIndices->push_back(i + 3); + _quadIndices->resizeElements(numVertices); + + unsigned int vi=0; + for (unsigned int i = 0; i < numCoords; i += 4) + { + _quadIndices->setElement(vi++, i); + _quadIndices->setElement(vi++, i + 1); + _quadIndices->setElement(vi++, i + 3); + + _quadIndices->setElement(vi++, i + 1); + _quadIndices->setElement(vi++, i + 2); + _quadIndices->setElement(vi++, i + 3); } }