diff --git a/include/osg/State b/include/osg/State index 2e30a3b27..453905905 100644 --- a/include/osg/State +++ b/include/osg/State @@ -512,8 +512,11 @@ class OSG_EXPORT State : public Referenced, public Observer _currentPBO = 0; } - typedef std::vector Indices; - Indices _quadIndices[6]; + typedef std::vector IndicesGLushort; + IndicesGLushort _quadIndicesGLushort[4]; + + typedef std::vector IndicesGLuint; + IndicesGLuint _quadIndicesGLuint[4]; void drawQuads(GLint first, GLsizei count, GLsizei primCount=0); diff --git a/src/osg/State.cpp b/src/osg/State.cpp index e9a84b6d9..0b88d6383 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -1431,38 +1431,67 @@ void State::drawQuads(GLint first, GLsizei count, GLsizei primCount) unsigned int numQuads = (count/4); unsigned int numIndices = numQuads * 6; unsigned int endOfIndices = offsetFirst+numIndices; - Indices& indices = _quadIndices[array]; - if (endOfIndices>65536) - { - OSG_NOTICE<<"Warning: State::drawQuads("<= indices.size()) + if (endOfIndices<65536) { - // we need to expand the _indexArray to be big enough to cope with all the quads required. - unsigned int numExistingQuads = indices.size()/6; - unsigned int numRequiredQuads = endOfIndices/6; - indices.reserve(endOfIndices); - for(unsigned int i=numExistingQuads; i= indices.size()) { - unsigned int base = i*4 + array; - indices.push_back(base); - indices.push_back(base+1); - indices.push_back(base+3); - - indices.push_back(base+1); - indices.push_back(base+2); - indices.push_back(base+3); - - // OSG_NOTICE<<" adding quad indices ("<= indices.size()) + { + // we need to expand the _indexArray to be big enough to cope with all the quads required. + unsigned int numExistingQuads = indices.size()/6; + unsigned int numRequiredQuads = endOfIndices/6; + indices.reserve(endOfIndices); + for(unsigned int i=numExistingQuads; i