Removed the old code paths
This commit is contained in:
@@ -732,159 +732,15 @@ void Text::computePositions(unsigned int contextID) const
|
||||
case RIGHT_BOTTOM_BASE_LINE: _offset.set(_textBB.xMax(),-_characterHeight*(1.0 + _lineSpacing)*(_lineCount-1),0.0f); break;
|
||||
}
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
AutoTransformCache& atc = _autoTransformCache[contextID];
|
||||
osg::Matrix& matrix = atc._matrix;
|
||||
|
||||
if (_characterSizeMode!=OBJECT_COORDS || _autoRotateToScreen)
|
||||
{
|
||||
|
||||
matrix.makeTranslate(-_offset);
|
||||
|
||||
osg::Matrix rotate_matrix;
|
||||
if (_autoRotateToScreen)
|
||||
{
|
||||
osg::Vec3d trans(atc._modelview.getTrans());
|
||||
atc._modelview.setTrans(0.0f,0.0f,0.0f);
|
||||
|
||||
rotate_matrix.invert(atc._modelview);
|
||||
|
||||
atc._modelview.setTrans(trans);
|
||||
}
|
||||
|
||||
matrix.postMultRotate(_rotation);
|
||||
|
||||
if (_characterSizeMode!=OBJECT_COORDS)
|
||||
{
|
||||
|
||||
osg::Matrix M(rotate_matrix);
|
||||
M.postMultTranslate(_position);
|
||||
M.postMult(atc._modelview);
|
||||
osg::Matrix& P = atc._projection;
|
||||
|
||||
// compute the pixel size vector.
|
||||
|
||||
// pre adjust P00,P20,P23,P33 by multiplying them by the viewport window matrix.
|
||||
// here we do it in short hand with the knowledge of how the window matrix is formed
|
||||
// note P23,P33 are multiplied by an implicit 1 which would come from the window matrix.
|
||||
// Robert Osfield, June 2002.
|
||||
|
||||
// scaling for horizontal pixels
|
||||
float P00 = P(0,0)*atc._width*0.5f;
|
||||
float P20_00 = P(2,0)*atc._width*0.5f + P(2,3)*atc._width*0.5f;
|
||||
osg::Vec3 scale_00(M(0,0)*P00 + M(0,2)*P20_00,
|
||||
M(1,0)*P00 + M(1,2)*P20_00,
|
||||
M(2,0)*P00 + M(2,2)*P20_00);
|
||||
|
||||
// scaling for vertical pixels
|
||||
float P10 = P(1,1)*atc._height*0.5f;
|
||||
float P20_10 = P(2,1)*atc._height*0.5f + P(2,3)*atc._height*0.5f;
|
||||
osg::Vec3 scale_10(M(0,1)*P10 + M(0,2)*P20_10,
|
||||
M(1,1)*P10 + M(1,2)*P20_10,
|
||||
M(2,1)*P10 + M(2,2)*P20_10);
|
||||
|
||||
float P23 = P(2,3);
|
||||
float P33 = P(3,3);
|
||||
|
||||
float pixelSizeVector_w = M(3,2)*P23 + M(3,3)*P33;
|
||||
|
||||
float pixelSizeVert=(_characterHeight*sqrtf(scale_10.length2()))/(pixelSizeVector_w*0.701f);
|
||||
float pixelSizeHori=(_characterHeight/getCharacterAspectRatio()*sqrtf(scale_00.length2()))/(pixelSizeVector_w*0.701f);
|
||||
|
||||
// avoid nasty math by preventing a divide by zero
|
||||
if (pixelSizeVert == 0.0f)
|
||||
pixelSizeVert= 1.0f;
|
||||
if (pixelSizeHori == 0.0f)
|
||||
pixelSizeHori= 1.0f;
|
||||
|
||||
if (_characterSizeMode==SCREEN_COORDS)
|
||||
{
|
||||
float scale_font_vert=_characterHeight/pixelSizeVert;
|
||||
float scale_font_hori=_characterHeight/getCharacterAspectRatio()/pixelSizeHori;
|
||||
|
||||
if (P10<0)
|
||||
scale_font_vert=-scale_font_vert;
|
||||
matrix.postMultScale(osg::Vec3f(scale_font_hori, scale_font_vert,1.0f));
|
||||
}
|
||||
else if (pixelSizeVert>getFontHeight())
|
||||
{
|
||||
float scale_font = getFontHeight()/pixelSizeVert;
|
||||
matrix.postMultScale(osg::Vec3f(scale_font, scale_font,1.0f));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_autoRotateToScreen)
|
||||
{
|
||||
matrix.postMult(rotate_matrix);
|
||||
}
|
||||
|
||||
matrix.postMultTranslate(_position);
|
||||
}
|
||||
else if (!_rotation.zeroRotation())
|
||||
{
|
||||
matrix.makeRotate(_rotation);
|
||||
matrix.preMultTranslate(-_offset);
|
||||
matrix.postMultTranslate(_position);
|
||||
|
||||
// OSG_NOTICE<<"Old Need to rotate "<<matrix<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix.makeTranslate(_position-_offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
// now apply matrix to the glyphs.
|
||||
for(TextureGlyphQuadMap::iterator titr=_textureGlyphQuadMap.begin();
|
||||
titr!=_textureGlyphQuadMap.end();
|
||||
++titr)
|
||||
{
|
||||
GlyphQuads& glyphquad = titr->second;
|
||||
//OSG_NOTICE<<"Text::computePositions("<<contextID<<") glyphquad= "<<&glyphquad<<std::endl;
|
||||
GlyphQuads::Coords& coords = glyphquad._coords;
|
||||
|
||||
if (contextID>=glyphquad._transformedCoords.size())
|
||||
{
|
||||
// contextID exceeds one setup for glyphquad._transformedCoords, ignore this request.
|
||||
continue;
|
||||
}
|
||||
GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID];
|
||||
if (!transformedCoords) transformedCoords = new osg::Vec3Array;
|
||||
|
||||
unsigned int numCoords = coords->size();
|
||||
if (numCoords != transformedCoords->size())
|
||||
{
|
||||
transformedCoords->resize(numCoords);
|
||||
}
|
||||
|
||||
for(unsigned int i=0;i<numCoords;++i)
|
||||
{
|
||||
(*transformedCoords)[i] = osg::Vec3((*coords)[i].x(), (*coords)[i].y(), 0.0f)*matrix;
|
||||
}
|
||||
transformedCoords->dirty();
|
||||
}
|
||||
#endif
|
||||
|
||||
computeBackdropPositions(contextID);
|
||||
|
||||
#ifdef NEW_APPROACH
|
||||
_normal = osg::Vec3(0.0f,0.0f,1.0f);
|
||||
#else
|
||||
_normal = osg::Matrix::transform3x3(osg::Vec3(0.0f,0.0f,1.0f),matrix);
|
||||
_normal.normalize();
|
||||
#endif
|
||||
|
||||
const_cast<Text*>(this)->dirtyBound();
|
||||
}
|
||||
|
||||
// Presumes the atc matrix is already up-to-date
|
||||
#ifdef NEW_APPROACH
|
||||
void Text::computeBackdropPositions(unsigned int) const
|
||||
#else
|
||||
void Text::computeBackdropPositions(unsigned int contextID) const
|
||||
#endif
|
||||
{
|
||||
if(_backdropType == NONE)
|
||||
{
|
||||
@@ -896,11 +752,6 @@ void Text::computeBackdropPositions(unsigned int contextID) const
|
||||
unsigned int i;
|
||||
bool is_valid_size;
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
AutoTransformCache& atc = _autoTransformCache[contextID];
|
||||
osg::Matrix& matrix = atc._matrix;
|
||||
#endif
|
||||
|
||||
// FIXME: OPTIMIZE: This function produces the same value regardless of contextID.
|
||||
// Since we tend to loop over contextID, we should cache this value some how
|
||||
// instead of recomputing it each time.
|
||||
@@ -941,17 +792,7 @@ void Text::computeBackdropPositions(unsigned int contextID) const
|
||||
}
|
||||
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
GlyphQuads::Coords3& transformedCoords = glyphquad._transformedBackdropCoords[backdrop_index];
|
||||
#else
|
||||
if (contextID >= glyphquad._transformedBackdropCoords[backdrop_index].size())
|
||||
{
|
||||
// contextID exceeds one setup for glyphquad._transformedBackdropCoords, ignore this request.
|
||||
continue;
|
||||
}
|
||||
|
||||
GlyphQuads::Coords3& transformedCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
|
||||
#endif
|
||||
|
||||
if (!transformedCoords) transformedCoords = new osg::Vec3Array();
|
||||
|
||||
@@ -1021,11 +862,7 @@ void Text::computeBackdropPositions(unsigned int contextID) const
|
||||
vertical_shift_direction = -1.0f;
|
||||
}
|
||||
}
|
||||
#ifdef NEW_APPROACH
|
||||
(*transformedCoords)[i] = osg::Vec3(horizontal_shift_direction * _backdropHorizontalOffset * avg_width + (*coords)[i].x(), vertical_shift_direction * _backdropVerticalOffset * avg_height + (*coords)[i].y(), 0.0f);
|
||||
#else
|
||||
(*transformedCoords)[i] = osg::Vec3(horizontal_shift_direction * _backdropHorizontalOffset * avg_width + (*coords)[i].x(), vertical_shift_direction * _backdropVerticalOffset * avg_height + (*coords)[i].y(), 0.0f)*matrix;
|
||||
#endif
|
||||
transformedCoords->dirty();
|
||||
}
|
||||
}
|
||||
@@ -1387,79 +1224,18 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
if (_characterSizeMode!=OBJECT_COORDS || _autoRotateToScreen)
|
||||
{
|
||||
unsigned int frameNumber = state.getFrameStamp()?state.getFrameStamp()->getFrameNumber():0;
|
||||
AutoTransformCache& atc = _autoTransformCache[contextID];
|
||||
const osg::Matrix& modelview = state.getModelViewMatrix();
|
||||
const osg::Matrix& projection = state.getProjectionMatrix();
|
||||
|
||||
osg::Vec3 newTransformedPosition = _position*modelview;
|
||||
|
||||
int width = atc._width;
|
||||
int height = atc._height;
|
||||
|
||||
const osg::Viewport* viewport = state.getCurrentViewport();
|
||||
if (viewport)
|
||||
{
|
||||
width = static_cast<int>(viewport->width());
|
||||
height = static_cast<int>(viewport->height());
|
||||
}
|
||||
|
||||
bool doUpdate = atc._traversalNumber==-1;
|
||||
if (atc._traversalNumber>=0)
|
||||
{
|
||||
if (atc._modelview!=modelview)
|
||||
{
|
||||
doUpdate = true;
|
||||
}
|
||||
else if (width!=atc._width || height!=atc._height)
|
||||
{
|
||||
doUpdate = true;
|
||||
}
|
||||
else if (atc._projection!=projection)
|
||||
{
|
||||
doUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
atc._traversalNumber = frameNumber;
|
||||
atc._width = width;
|
||||
atc._height = height;
|
||||
|
||||
if (doUpdate)
|
||||
{
|
||||
atc._transformedPosition = newTransformedPosition;
|
||||
atc._projection = projection;
|
||||
atc._modelview = modelview;
|
||||
|
||||
computePositions(contextID);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// Ensure that the glyph coordinates have been transformed for
|
||||
// this context id.
|
||||
|
||||
if ( !_textureGlyphQuadMap.empty() )
|
||||
{
|
||||
const GlyphQuads& glyphquad = (_textureGlyphQuadMap.begin())->second;
|
||||
#ifdef NEW_APPROACH
|
||||
if (!glyphquad._coords.valid() || glyphquad._coords->empty() )
|
||||
{
|
||||
computePositions(contextID);
|
||||
}
|
||||
#else
|
||||
if (!glyphquad._transformedCoords[contextID].valid() || glyphquad._transformedCoords[contextID]->empty() )
|
||||
{
|
||||
computePositions(contextID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef NEW_APPROACH
|
||||
// save the previous modelview matrix
|
||||
osg::Matrix previous_modelview = state.getModelViewMatrix();
|
||||
|
||||
@@ -1482,30 +1258,12 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
|
||||
{
|
||||
// OSG_NOTICE<<"No need to apply matrix "<<std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
state.Normal(_normal.x(), _normal.y(), _normal.z());
|
||||
|
||||
if ((_drawMode&(~TEXT))!=0)
|
||||
{
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
// ** save the previous modelview matrix
|
||||
osg::Matrix previous(state.getModelViewMatrix());
|
||||
|
||||
// ** get the modelview for this context
|
||||
osg::Matrix modelview(_autoTransformCache[contextID]._matrix);
|
||||
|
||||
// ** mult previous by the modelview for this context
|
||||
modelview.postMult(previous);
|
||||
|
||||
// ** apply this new modelview matrix
|
||||
state.applyModelViewMatrix(modelview);
|
||||
|
||||
// OSG_NOTICE<<"Old state.applyModelViewMatrix() "<<modelview<<std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
state.disableNormalPointer();
|
||||
|
||||
state.Color(colorMultiplier.r()*_textBBColor.r(),colorMultiplier.g()*_textBBColor.g(),colorMultiplier.b()*_textBBColor.b(),colorMultiplier.a()*_textBBColor.a());
|
||||
@@ -1568,11 +1326,6 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
|
||||
glDrawArrays(GL_LINES, start_index, _decorationVertices->size());
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
// restore the previous modelview matrix
|
||||
state.applyModelViewMatrix(previous);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE)
|
||||
@@ -1620,58 +1373,42 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
|
||||
state.unbindElementBufferObject();
|
||||
}
|
||||
|
||||
#ifdef NEW_APPROACH
|
||||
if (needToApplyMatrix)
|
||||
{
|
||||
// apply this new modelview matrix
|
||||
state.applyModelViewMatrix(previous_modelview);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Text::accept(osg::Drawable::ConstAttributeFunctor& af) const
|
||||
{
|
||||
// TODO what to do about local transforms?
|
||||
for(TextureGlyphQuadMap::const_iterator titr=_textureGlyphQuadMap.begin();
|
||||
titr!=_textureGlyphQuadMap.end();
|
||||
++titr)
|
||||
{
|
||||
const GlyphQuads& glyphquad = titr->second;
|
||||
#ifdef NEW_APPROACH
|
||||
if (glyphquad._coords.valid() )
|
||||
{
|
||||
af.apply(osg::Drawable::VERTICES, glyphquad._coords->size(), &(glyphquad._coords->front()));
|
||||
af.apply(osg::Drawable::TEXTURE_COORDS_0, glyphquad._texcoords->size(), &(glyphquad._texcoords->front()));
|
||||
}
|
||||
#else
|
||||
if (!glyphquad._transformedCoords.empty() && glyphquad._transformedCoords[0].valid())
|
||||
{
|
||||
af.apply(osg::Drawable::VERTICES, glyphquad._transformedCoords[0]->size(), &(glyphquad._transformedCoords[0]->front()));
|
||||
af.apply(osg::Drawable::TEXTURE_COORDS_0, glyphquad._texcoords->size(), &(glyphquad._texcoords->front()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void Text::accept(osg::PrimitiveFunctor& pf) const
|
||||
{
|
||||
// TODO what to do about local transforms?
|
||||
for(TextureGlyphQuadMap::const_iterator titr=_textureGlyphQuadMap.begin();
|
||||
titr!=_textureGlyphQuadMap.end();
|
||||
++titr)
|
||||
{
|
||||
const GlyphQuads& glyphquad = titr->second;
|
||||
#ifdef NEW_APPROACH
|
||||
if (glyphquad._coords.valid())
|
||||
{
|
||||
pf.setVertexArray(glyphquad._coords->size(), &(glyphquad._coords->front()));
|
||||
pf.drawArrays(GL_QUADS, 0, glyphquad._coords->size());
|
||||
}
|
||||
#else
|
||||
if (!glyphquad._transformedCoords.empty() && glyphquad._transformedCoords[0].valid())
|
||||
{
|
||||
pf.setVertexArray(glyphquad._transformedCoords[0]->size(), &(glyphquad._transformedCoords[0]->front()));
|
||||
pf.drawArrays(GL_QUADS, 0, glyphquad._transformedCoords[0]->size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1780,13 +1517,8 @@ 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
|
||||
{
|
||||
|
||||
#ifdef NEW_APPROACH
|
||||
const GlyphQuads::Coords3& transformedCoords = glyphquad._coords;
|
||||
#else
|
||||
unsigned int contextID = state.getContextID();
|
||||
const GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID];
|
||||
#endif
|
||||
|
||||
if (transformedCoords.valid() && !transformedCoords->empty())
|
||||
{
|
||||
state.setVertexPointer(transformedCoords.get());
|
||||
@@ -1851,10 +1583,6 @@ void Text::renderWithDelayedDepthWrites(osg::State& state, const osg::Vec4& colo
|
||||
|
||||
void Text::drawTextWithBackdrop(osg::State& state, const osg::Vec4& colorMultiplier) const
|
||||
{
|
||||
#ifndef NEW_APPROACH
|
||||
unsigned int contextID = state.getContextID();
|
||||
#endif
|
||||
|
||||
for(TextureGlyphQuadMap::iterator titr=_textureGlyphQuadMap.begin();
|
||||
titr!=_textureGlyphQuadMap.end();
|
||||
++titr)
|
||||
@@ -1885,11 +1613,7 @@ void Text::drawTextWithBackdrop(osg::State& state, const osg::Vec4& colorMultipl
|
||||
|
||||
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index];
|
||||
#else
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
|
||||
#endif
|
||||
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
|
||||
{
|
||||
state.setVertexPointer(transformedBackdropCoords.get());
|
||||
@@ -1907,10 +1631,6 @@ void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMult
|
||||
{
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
unsigned int contextID = state.getContextID();
|
||||
#endif
|
||||
|
||||
if (!osg::PolygonOffset::areFactorAndUnitsMultipliersSet())
|
||||
{
|
||||
osg::PolygonOffset::setFactorAndUnitsMultipliersUsingBestGuessForDriver();
|
||||
@@ -1948,11 +1668,7 @@ void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMult
|
||||
|
||||
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index];
|
||||
#else
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
|
||||
#endif
|
||||
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
|
||||
{
|
||||
state.setVertexPointer( transformedBackdropCoords.get());
|
||||
@@ -1979,10 +1695,6 @@ void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMult
|
||||
{
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
unsigned int contextID = state.getContextID();
|
||||
#endif
|
||||
|
||||
glPushAttrib(GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
@@ -2014,11 +1726,7 @@ void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMult
|
||||
|
||||
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index];
|
||||
#else
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
|
||||
#endif
|
||||
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
|
||||
{
|
||||
state.setVertexPointer( transformedBackdropCoords.get());
|
||||
@@ -2040,10 +1748,6 @@ void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultipl
|
||||
{
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
|
||||
|
||||
#ifndef NEW_APPROACH
|
||||
unsigned int contextID = state.getContextID();
|
||||
#endif
|
||||
|
||||
// Hmmm, the man page says GL_VIEWPORT_BIT for Depth range (near and far)
|
||||
// but experimentally, GL_DEPTH_BUFFER_BIT for glDepthRange.
|
||||
// glPushAttrib(GL_VIEWPORT_BIT);
|
||||
@@ -2077,11 +1781,7 @@ void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultipl
|
||||
|
||||
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index];
|
||||
#else
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
|
||||
#endif
|
||||
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
|
||||
{
|
||||
state.setVertexPointer( transformedBackdropCoords.get());
|
||||
@@ -2119,9 +1819,6 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
|
||||
* 7c) If priority levels are different, then make sure the foreground
|
||||
* text has the higher priority.
|
||||
*/
|
||||
#ifndef NEW_APPROACH
|
||||
unsigned int contextID = state.getContextID();
|
||||
#endif
|
||||
TextureGlyphQuadMap::iterator titr; // Moved up here for VC6
|
||||
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_STENCIL_TEST);
|
||||
@@ -2181,11 +1878,7 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
|
||||
|
||||
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index];
|
||||
#else
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
|
||||
#endif
|
||||
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
|
||||
{
|
||||
state.setVertexPointer( transformedBackdropCoords.get());
|
||||
@@ -2194,11 +1887,7 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
|
||||
}
|
||||
|
||||
// Draw the foreground text
|
||||
#ifdef NEW_APPROACH
|
||||
const GlyphQuads::Coords3& transformedCoords = glyphquad._coords;
|
||||
#else
|
||||
const GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID];
|
||||
#endif
|
||||
if (transformedCoords.valid() && !transformedCoords->empty())
|
||||
{
|
||||
state.setVertexPointer( transformedCoords.get());
|
||||
@@ -2257,11 +1946,7 @@ void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMult
|
||||
|
||||
for( ; backdrop_index < max_backdrop_index; backdrop_index++)
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index];
|
||||
#else
|
||||
const GlyphQuads::Coords3& transformedBackdropCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];
|
||||
#endif
|
||||
if (transformedBackdropCoords.valid() && !transformedBackdropCoords->empty())
|
||||
{
|
||||
state.setVertexPointer( transformedBackdropCoords.get());
|
||||
@@ -2290,8 +1975,6 @@ Text::GlyphQuads::GlyphQuads(const GlyphQuads&)
|
||||
|
||||
void Text::GlyphQuads::initGlyphQuads()
|
||||
{
|
||||
|
||||
#ifdef NEW_APPROACH
|
||||
_coords = new osg::Vec3Array();
|
||||
_texcoords = new osg::Vec2Array();
|
||||
_colorCoords = new osg::Vec4Array();
|
||||
@@ -2300,24 +1983,6 @@ void Text::GlyphQuads::initGlyphQuads()
|
||||
{
|
||||
_transformedBackdropCoords[j] = new osg::Vec3Array();
|
||||
}
|
||||
#else
|
||||
_coords = new osg::Vec2Array();
|
||||
_texcoords = new osg::Vec2Array();
|
||||
_colorCoords = new osg::Vec4Array();
|
||||
|
||||
for (size_t i = 0; i < _transformedCoords.size(); i++)
|
||||
{
|
||||
_transformedCoords[i] = new osg::Vec3Array();
|
||||
}
|
||||
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
for (size_t i = 0; i < _transformedBackdropCoords[j].size(); i++)
|
||||
{
|
||||
_transformedBackdropCoords[j][i] = new osg::Vec3Array();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_quadIndices = new DrawElementsUShort(PrimitiveSet::TRIANGLES);
|
||||
}
|
||||
@@ -2351,7 +2016,7 @@ void Text::GlyphQuads::initGPUBufferObjects()
|
||||
_texcoords->setVertexBufferObject(vbo);
|
||||
_colorCoords->setBinding(osg::Array::BIND_PER_VERTEX);
|
||||
_colorCoords->setVertexBufferObject(vbo);
|
||||
#ifdef NEW_APPROACH
|
||||
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
if (_transformedBackdropCoords[j].valid())
|
||||
@@ -2360,27 +2025,6 @@ void Text::GlyphQuads::initGPUBufferObjects()
|
||||
_transformedBackdropCoords[j]->setVertexBufferObject(vbo);
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (size_t i = 0; i < _transformedCoords.size(); i++)
|
||||
{
|
||||
if (_transformedCoords[i].valid())
|
||||
{
|
||||
_transformedCoords[i]->setBinding(osg::Array::BIND_PER_VERTEX);
|
||||
_transformedCoords[i]->setVertexBufferObject(vbo);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
for (size_t i = 0; i < _transformedBackdropCoords[j].size(); i++)
|
||||
{
|
||||
if (_transformedBackdropCoords[j][i].valid())
|
||||
{
|
||||
_transformedBackdropCoords[j][i]->setBinding(osg::Array::BIND_PER_VERTEX);
|
||||
_transformedBackdropCoords[j][i]->setVertexBufferObject(vbo);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_quadIndices->setElementBufferObject(new osg::ElementBufferObject());
|
||||
}
|
||||
@@ -2388,7 +2032,6 @@ void Text::GlyphQuads::initGPUBufferObjects()
|
||||
|
||||
void Text::GlyphQuads::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
_coords->resizeGLObjectBuffers(maxSize);
|
||||
|
||||
for (int j = 0; j < 8; j++)
|
||||
@@ -2398,20 +2041,6 @@ void Text::GlyphQuads::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
_transformedBackdropCoords[j]->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
}
|
||||
#else
|
||||
_transformedCoords.resize(maxSize);
|
||||
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
for (size_t i = 0; i < _transformedBackdropCoords[j].size(); i++)
|
||||
{
|
||||
if (_transformedBackdropCoords[j][i].valid())
|
||||
{
|
||||
_transformedBackdropCoords[j][i]->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_quadIndices->resizeGLObjectBuffers(maxSize);
|
||||
|
||||
@@ -2420,7 +2049,6 @@ void Text::GlyphQuads::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
|
||||
void Text::GlyphQuads::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
#ifdef NEW_APPROACH
|
||||
_coords->releaseGLObjects(state);;
|
||||
|
||||
for (int j = 0; j < 8; j++)
|
||||
@@ -2430,17 +2058,6 @@ void Text::GlyphQuads::releaseGLObjects(osg::State* state) const
|
||||
_transformedBackdropCoords[j]->releaseGLObjects(state);
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
for (size_t i = 0; i < _transformedBackdropCoords[j].size(); i++)
|
||||
{
|
||||
if (_transformedBackdropCoords[j][i].valid())
|
||||
{
|
||||
_transformedBackdropCoords[j][i]->releaseGLObjects(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_quadIndices->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user