Adapted GLBeginEndAdapter to use state.drawQuad(..) rather than use it's local GL_QUADS emulation.

Fixed to osg::Texture for GLES support.

Added automatic GLenum mode mappings in osg::PrimitiveSet to provide a fallback for non support glDrawArray/glDrawElement modes.

Added finer gained error checking during StateSet::compile().
This commit is contained in:
Robert Osfield
2009-11-12 14:35:44 +00:00
parent efb9908644
commit 8b141567b9
5 changed files with 94 additions and 48 deletions

View File

@@ -282,27 +282,7 @@ void GLBeginEndAdapter::End()
if (_primitiveMode==GL_QUADS)
{
unsigned int numQuads = _vertices->size()/4;
unsigned int numIndices = numQuads * 6;
if (numIndices > _indexArray.size())
{
// we need to expand the _indexArray to be big enough to cope with all the quads required.
unsigned int numExistingQuads = _indexArray.size()/6;
_indexArray.reserve(numIndices);
for(unsigned int i=numExistingQuads; i<numQuads; ++i)
{
unsigned int base = i*4;
_indexArray.push_back(base);
_indexArray.push_back(base+1);
_indexArray.push_back(base+3);
_indexArray.push_back(base+1);
_indexArray.push_back(base+2);
_indexArray.push_back(base+3);
}
}
glDrawElements(GL_TRIANGLES, numQuads*6, GL_UNSIGNED_SHORT, &(_indexArray.front()));
_state->drawQuads(0, _vertices->size());
}
else if (_primitiveMode==GL_QUAD_STRIP)
{