From 9eaf03e16ed467b0ab0ffa103c4331e287a735e0 Mon Sep 17 00:00:00 2001 From: "Konstantin S. Matveyev" Date: Tue, 18 Apr 2017 15:53:48 +0100 Subject: [PATCH] Fixes glyphs's MODELVIEW matrices (positions, scales etc.) if state.getUseModelViewAndProjectionUniforms() is true --- src/osgText/Text3D.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/osgText/Text3D.cpp b/src/osgText/Text3D.cpp index 71f8f13c4..85a9aa1d2 100644 --- a/src/osgText/Text3D.cpp +++ b/src/osgText/Text3D.cpp @@ -493,6 +493,10 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const // ** apply this new modelview matrix state.applyModelViewMatrix(modelview); + // if we are using osg::Program which requires OSG's generated uniforms to track + // modelview and projection matrices then apply them now. + if (state.getUseModelViewAndProjectionUniforms()) state.applyModelViewAndProjectionUniformsIfRequired(); + osg::GLBeginEndAdapter& gl = (state.getGLBeginEndAdapter()); if (_drawMode & BOUNDINGBOX) @@ -583,6 +587,10 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const // restore the previous modelview matrix state.applyModelViewMatrix(previous); + + // if we are using osg::Program which requires OSG's generated uniforms to track + // modelview and projection matrices then apply them now. + if (state.getUseModelViewAndProjectionUniforms()) state.applyModelViewAndProjectionUniformsIfRequired(); } void Text3D::renderPerGlyph(osg::State & state) const @@ -613,6 +621,10 @@ void Text3D::renderPerGlyph(osg::State & state) const matrix.preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); state.applyModelViewMatrix(matrix); + // if we are using osg::Program which requires OSG's generated uniforms to track + // modelview and projection matrices then apply them now. + if (state.getUseModelViewAndProjectionUniforms()) state.applyModelViewAndProjectionUniformsIfRequired(); + state.lazyDisablingOfVertexAttributes(); // ** apply the vertex array @@ -688,6 +700,10 @@ void Text3D::renderPerFace(osg::State & state) const matrix.preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); state.applyModelViewMatrix(matrix); + // if we are using osg::Program which requires OSG's generated uniforms to track + // modelview and projection matrices then apply them now. + if (state.getUseModelViewAndProjectionUniforms()) state.applyModelViewAndProjectionUniformsIfRequired(); + state.setVertexPointer(it->_glyphGeometry->getVertexArray()); state.setNormalPointer(it->_glyphGeometry->getNormalArray()); @@ -713,6 +729,10 @@ void Text3D::renderPerFace(osg::State & state) const matrix.preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); state.applyModelViewMatrix(matrix); + // if we are using osg::Program which requires OSG's generated uniforms to track + // modelview and projection matrices then apply them now. + if (state.getUseModelViewAndProjectionUniforms()) state.applyModelViewAndProjectionUniformsIfRequired(); + state.setVertexPointer(it->_glyphGeometry->getVertexArray()); state.setNormalPointer(it->_glyphGeometry->getNormalArray()); @@ -746,6 +766,10 @@ void Text3D::renderPerFace(osg::State & state) const matrix.preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z())); state.applyModelViewMatrix(matrix); + // if we are using osg::Program which requires OSG's generated uniforms to track + // modelview and projection matrices then apply them now. + if (state.getUseModelViewAndProjectionUniforms()) state.applyModelViewAndProjectionUniformsIfRequired(); + state.setVertexPointer(it->_glyphGeometry->getVertexArray()); state.setNormalPointer(it->_glyphGeometry->getNormalArray());