Replaced osg::DrawElementeUInt usage for a more flexible DrawElements base class approach with the default set to DrawElementUShort to ensure compatibility with GLES2 implementes that don't support uint for glDrawElements.

This commit is contained in:
Robert Osfield 2017-05-25 10:41:12 +01:00
parent 10c1fedfca
commit 8b433f8364
2 changed files with 19 additions and 12 deletions

View File

@ -313,7 +313,7 @@ public:
osg::buffered_object<Coords3> _transformedBackdropCoords[8];
ColorCoords _colorCoords;
osg::ref_ptr<osg::DrawElementsUInt> _quadIndices;
osg::ref_ptr<osg::DrawElements> _quadIndices;
void updateQuadIndices();
GlyphQuads();

View File

@ -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);
}
}