diff --git a/include/osgText/Font b/include/osgText/Font index 908cceaae..e3638afa0 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -22,7 +22,6 @@ #include #include #include -#include #include @@ -161,7 +160,6 @@ protected: osg::ref_ptr _stateset; SizeGlyphMap _sizeGlyphMap; GlyphTextureList _glyphTextureList; - StateSetList _stateSetList; // current active size of font unsigned int _width; @@ -173,8 +171,6 @@ protected: osg::Texture::FilterMode _minFilterHint; osg::Texture::FilterMode _magFilterHint; - osg::ref_ptr _texEnv; - osg::ref_ptr _implementation; @@ -222,10 +218,6 @@ public: /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ virtual int compare(const osg::StateAttribute& rhs) const; - void setStateSet(osg::StateSet* stateset) { _stateset = stateset; } - osg::StateSet* getStateSet() { return _stateset; } - const osg::StateSet* getStateSet() const { return _stateset; } - /** Set the margin around each glyph, to ensure that texture filtering doesn't bleed adjacent glyph's into each other.*/ void setGlyphImageMargin(unsigned int margin) { _margin = margin; } unsigned int getGlyphImageMargin() const { return _margin; } @@ -240,8 +232,6 @@ public: virtual ~GlyphTexture(); - osg::StateSet* _stateset; - // parameter used to compute the size and position of empty space // in the texture which could accomodate new glyphs. int _margin; @@ -283,9 +273,6 @@ public: GlyphTexture* getTexture(); const GlyphTexture* getTexture() const; - osg::StateSet* getStateSet(); - const osg::StateSet* getStateSet() const; - void setTexturePosition(int posX,int posY); int getTexturePositionX() const; int getTexturePositionY() const; diff --git a/include/osgText/Text b/include/osgText/Text index eda4a5726..b3cc40bd1 100644 --- a/include/osgText/Text +++ b/include/osgText/Text @@ -479,12 +479,12 @@ public: const LineNumbers& getLineNumbers() const { return _lineNumbers; } }; - typedef std::map,GlyphQuads> TextureGlyphQuadMap; + typedef std::map,GlyphQuads> TextureGlyphQuadMap; /** Direct Access to GlyphQuads */ - const GlyphQuads* getGlyphQuads(osg::StateSet* stateSet) const + const GlyphQuads* getGlyphQuads(Font::GlyphTexture* texture) const { - TextureGlyphQuadMap::iterator itGlyphQuad = _textureGlyphQuadMap.find(stateSet); + TextureGlyphQuadMap::iterator itGlyphQuad = _textureGlyphQuadMap.find(texture); if (itGlyphQuad == _textureGlyphQuadMap.end()) return NULL; return &itGlyphQuad->second; diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index 289dea7a1..ee292422f 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include @@ -138,9 +137,10 @@ Font::Font(FontImplementation* implementation): _magFilterHint(osg::Texture::LINEAR) { setImplementation(implementation); - _texEnv = new osg::TexEnv(osg::TexEnv::BLEND); _stateset = new osg::StateSet; + //_stateset->setMode(GL_BLEND,osg::StateAttribute::ON); + //_stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON); _stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); } @@ -301,15 +301,11 @@ void Font::addGlyph(unsigned int width, unsigned int height, unsigned int charco if (!glyphTexture) { - osg::StateSet* stateset = new osg::StateSet; - _stateSetList.push_back(stateset); - glyphTexture = new GlyphTexture; static int numberOfTexturesAllocated = 0; ++numberOfTexturesAllocated; - osg::notify(osg::INFO)<<" Creating new GlyphTexture "<setStateSet(stateset); - stateset->setMode(GL_BLEND,osg::StateAttribute::ON); - stateset->setTextureAttributeAndModes(0,glyphTexture,osg::StateAttribute::ON); - if (_texEnv.valid()) stateset->setTextureAttribute(0,_texEnv.get()); - stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); - if (!glyphTexture->getSpaceForGlyph(glyph,posX,posY)) { osg::notify(osg::WARN)<<"Warning: unable to allocate texture big enough for glyph"<getStateSet():0; } -const osg::StateSet* Font::Glyph::getStateSet() const { return _texture?_texture->getStateSet():0; } - void Font::Glyph::setTexturePosition(int posX,int posY) { _texturePosX = posX; _texturePosY = posY; } int Font::Glyph::getTexturePositionX() const { return _texturePosX; } int Font::Glyph::getTexturePositionY() const { return _texturePosY; } diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index 5b8bd909f..2176fa015 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -631,7 +631,7 @@ void Text::computeGlyphRepresentation() local.x() += bearing.x() * wr; local.y() += bearing.y() * hr; - GlyphQuads& glyphquad = _textureGlyphQuadMap[glyph->getTexture()->getStateSet()]; + GlyphQuads& glyphquad = _textureGlyphQuadMap[glyph->getTexture()]; glyphquad._glyphs.push_back(glyph); glyphquad._lineNumbers.push_back(lineNumber); @@ -1386,6 +1386,9 @@ void Text::drawImplementation(osg::State& state) const { unsigned int contextID = state.getContextID(); + state.applyMode(GL_BLEND,true); + state.applyTextureMode(0,GL_TEXTURE_2D,true); + if (_characterSizeMode!=OBJECT_COORDS || _autoRotateToScreen) { int frameNumber = state.getFrameStamp()?state.getFrameStamp()->getFrameNumber():0; @@ -1858,7 +1861,7 @@ void Text::renderOnlyForegroundText(osg::State& state) const ++titr) { // need to set the texture here... - state.apply(titr->first.get()); + state.applyTextureAttribute(0,titr->first.get()); const GlyphQuads& glyphquad = titr->second; @@ -1887,7 +1890,7 @@ void Text::renderWithPolygonOffset(osg::State& state) const ++titr) { // need to set the texture here... - state.apply(titr->first.get()); + state.applyTextureAttribute(0,titr->first.get()); const GlyphQuads& glyphquad = titr->second; @@ -1942,7 +1945,7 @@ void Text::renderWithNoDepthBuffer(osg::State& state) const ++titr) { // need to set the texture here... - state.apply(titr->first.get()); + state.applyTextureAttribute(0,titr->first.get()); const GlyphQuads& glyphquad = titr->second; @@ -1994,7 +1997,7 @@ void Text::renderWithDepthRange(osg::State& state) const ++titr) { // need to set the texture here... - state.apply(titr->first.get()); + state.applyTextureAttribute(0,titr->first.get()); const GlyphQuads& glyphquad = titr->second; @@ -2088,7 +2091,7 @@ void Text::renderWithStencilBuffer(osg::State& state) const ++titr) { // need to set the texture here... - state.apply(titr->first.get()); + state.applyTextureAttribute(0,titr->first.get()); const GlyphQuads& glyphquad = titr->second; @@ -2155,7 +2158,7 @@ void Text::renderWithStencilBuffer(osg::State& state) const ++titr) { // need to set the texture here... - state.apply(titr->first.get()); + state.applyTextureAttribute(0,titr->first.get()); const GlyphQuads& glyphquad = titr->second;