Moved all vertex array set up to start of Text/Text3D::drawImplementation().

This commit is contained in:
Robert Osfield 2017-03-04 17:20:54 +00:00
parent b88be0fbda
commit bb754b6f0a
2 changed files with 14 additions and 40 deletions

View File

@ -1091,20 +1091,21 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
state.Normal(_normal.x(), _normal.y(), _normal.z());
state.lazyDisablingOfVertexAttributes();
state.setVertexPointer(_coords.get());
state.setTexCoordPointer( 0, _texcoords.get());
state.applyDisablingOfVertexAttributes();
if ((_drawMode&(~TEXT))!=0)
{
if (!_decorationPrimitives.empty())
{
state.disableNormalPointer();
osg::State::ApplyModeProxy applyMode(state, GL_LIGHTING, false);
osg::State::ApplyTextureModeProxy applyTextureMode(state, 0, GL_TEXTURE_2D, false);
state.disableAllVertexArrays();
state.setVertexPointer(_coords.get());
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
switch(_backdropImplementation)
{
@ -1165,8 +1166,6 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
if (_drawMode & TEXT)
{
state.disableAllVertexArrays();
// Okay, since ATI's cards/drivers are not working correctly,
// we need alternative solutions to glPolygonOffset.
// So this is a pick your poison approach. Each alternative
@ -1322,16 +1321,12 @@ float Text::bilinearInterpolate(float x1, float x2, float y1, float y2, float x,
void Text::drawForegroundText(osg::State& state, const GlyphQuads& glyphquad, const osg::Vec4& colorMultiplier) const
{
const Coords& coords = _coords;
const TexCoords& texcoords = _texcoords;
const ColorCoords& colors = _colorCoords;
bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects);
if (coords.valid() && !coords->empty())
{
state.setVertexPointer(coords.get());
state.setTexCoordPointer(0, texcoords.get());
if(_colorGradientMode == SOLID)
{
state.disableColorPointer();
@ -1391,9 +1386,6 @@ void Text::renderWithDelayedDepthWrites(osg::State& state, const osg::Vec4& colo
void Text::drawTextWithBackdrop(osg::State& state, const osg::Vec4& colorMultiplier) const
{
state.setVertexPointer(_coords.get());
state.setTexCoordPointer( 0, _texcoords.get());
bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects);
for(TextureGlyphQuadMap::const_iterator titr=_textureGlyphQuadMap.begin();
@ -1447,9 +1439,6 @@ void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMult
osg::PolygonOffset::setFactorAndUnitsMultipliersUsingBestGuessForDriver();
}
state.setVertexPointer(_coords.get());
state.setTexCoordPointer( 0, _texcoords.get());
// Do I really need to do this for glPolygonOffset?
glPushAttrib(GL_POLYGON_OFFSET_FILL);
glEnable(GL_POLYGON_OFFSET_FILL);
@ -1509,9 +1498,6 @@ void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMult
glPushAttrib(GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
state.setVertexPointer(_coords.get());
state.setTexCoordPointer( 0, _texcoords.get());
for(TextureGlyphQuadMap::const_iterator titr=_textureGlyphQuadMap.begin();
titr!=_textureGlyphQuadMap.end();
++titr)
@ -1566,9 +1552,6 @@ void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultipl
// glPushAttrib(GL_VIEWPORT_BIT);
glPushAttrib(GL_DEPTH_BUFFER_BIT);
state.setVertexPointer(_coords.get());
state.setTexCoordPointer( 0, _texcoords.get());
for(TextureGlyphQuadMap::const_iterator titr=_textureGlyphQuadMap.begin();
titr!=_textureGlyphQuadMap.end();
++titr)
@ -1659,9 +1642,6 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
// Arrrgh! Why does the code only seem to work correctly if I call this?
glDepthMask(GL_FALSE);
state.setVertexPointer(_coords.get());
state.setTexCoordPointer( 0, _texcoords.get());
// Draw all the text to the stencil buffer to mark out the region
// that we can write too.
@ -1719,9 +1699,6 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
// Re-enable writing to the color buffer so we can see the results
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
state.setVertexPointer(_coords.get());
state.setTexCoordPointer( 0, _texcoords.get());
// Draw all the text again
for(TextureGlyphQuadMap::const_iterator titr=_textureGlyphQuadMap.begin();

View File

@ -499,7 +499,13 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
// OSG_NOTICE<<"No need to apply matrix "<<std::endl;
}
state.disableAllVertexArrays();
state.lazyDisablingOfVertexAttributes();
state.setVertexPointer(_coords.get());
state.setNormalPointer(_normals.get());
state.applyDisablingOfVertexAttributes();
if ((_drawMode&(~TEXT))!=0)
{
@ -509,8 +515,6 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
osg::State::ApplyModeProxy applyMode(state, GL_LIGHTING, false);
osg::State::ApplyTextureModeProxy applyTextureMode(state, 0, GL_TEXTURE_2D, false);
state.setVertexPointer(_coords.get());
for(Primitives::const_iterator itr = _decorationPrimitives.begin();
itr != _decorationPrimitives.end();
++itr)
@ -535,13 +539,6 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
if (wallStateSet==0) wallStateSet = frontStateSet;
if (backStateSet==0) backStateSet = frontStateSet;
state.lazyDisablingOfVertexAttributes();
state.setVertexPointer(_coords.get());
state.setNormalPointer(_normals.get());
state.applyDisablingOfVertexAttributes();
for(osg::Geometry::PrimitiveSetList::const_iterator itr=_frontPrimitiveSetList.begin(), end = _frontPrimitiveSetList.end(); itr!=end; ++itr)
{
(*itr)->draw(state, usingVertexBufferObjects);