Reworked the state management within osgText::Text and osgText::Font so that it

only applies textures locally rather than whole StateSet.
This commit is contained in:
Robert Osfield
2006-08-02 21:05:56 +00:00
parent b81cea3963
commit 9e7b07fbcf
4 changed files with 15 additions and 39 deletions

View File

@@ -22,7 +22,6 @@
#include <osg/Texture2D>
#include <osg/StateSet>
#include <osg/buffered_value>
#include <osg/TexEnv>
#include <osgText/Export>
@@ -161,7 +160,6 @@ protected:
osg::ref_ptr<osg::StateSet> _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<osg::TexEnv > _texEnv;
osg::ref_ptr<FontImplementation> _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;

View File

@@ -479,12 +479,12 @@ public:
const LineNumbers& getLineNumbers() const { return _lineNumbers; }
};
typedef std::map<osg::ref_ptr<osg::StateSet>,GlyphQuads> TextureGlyphQuadMap;
typedef std::map<osg::ref_ptr<Font::GlyphTexture>,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;