Add support for generating outline and signed distance field channels in a RGBA packed GlyphTexture Image.

This commit is contained in:
Robert Osfield
2017-09-08 16:59:43 +01:00
parent 77d4705182
commit de47eb3666
5 changed files with 292 additions and 64 deletions

View File

@@ -128,6 +128,10 @@ public:
int getGlyphInterval() const;
void setGyphTextureFeatures(GlyphTexture::Features features) { _glyphTextureFeatures = features; }
GlyphTexture::Features getGlyphTextureFeatures() const { return _glyphTextureFeatures; }
/** Set the size of texture to create to store the glyph images when rendering.
* Note, this doesn't affect already created Texture Glhph's.*/
void setTextureSizeHint(unsigned int width,unsigned int height);
@@ -145,6 +149,9 @@ public:
void setMagFilterHint(osg::Texture::FilterMode mode);
osg::Texture::FilterMode getMagFilterHint() const;
void setMaxAnisotropy(float anis) { _maxAnisotropy = anis; }
float getMaxAnisotropy() const { return _maxAnisotropy; }
unsigned int getFontDepth() const { return _depth; }
void setNumberCurveSamples(unsigned int numSamples) { _numCurveSamples = numSamples; }
@@ -203,11 +210,13 @@ protected:
unsigned int _margin;
float _marginRatio;
int _glyphInterval;
GlyphTexture::Features _glyphTextureFeatures;
unsigned int _textureWidthHint;
unsigned int _textureHeightHint;
osg::Texture::FilterMode _minFilterHint;
osg::Texture::FilterMode _magFilterHint;
float _maxAnisotropy;
unsigned int _depth;
unsigned int _numCurveSamples;
@@ -253,8 +262,6 @@ public:
virtual bool getVerticalSize(float & /*ascender*/, float & /*descender*/) const { return false; }
};
};
}

View File

@@ -58,6 +58,9 @@ public:
unsigned int getGlyphCode() const { return _glyphCode; }
void setFontResolution(const FontResolution& fontRes) { _fontResolution = fontRes; }
const FontResolution& getFontResolution() const { return _fontResolution; }
void setWidth(float width) { _width = width; }
float getWidth() const { return _width; }
@@ -90,8 +93,6 @@ public:
void setMaxTexCoord(const osg::Vec2& coord);
const osg::Vec2& getMaxTexCoord() const;
void subload() const;
protected:
virtual ~Glyph();
@@ -99,6 +100,8 @@ protected:
Font* _font;
unsigned int _glyphCode;
FontResolution _fontResolution;
float _width;
float _height;
@@ -263,6 +266,17 @@ public:
void setGlyphInterval(int interval) { _interval = interval; }
int getGlyphInterval() const { return _interval; }
enum Features
{
GREYSCALE,
OUTLINE_GREYSCALE,
SIGNED_DISTANCE_FIELD,
ALL_FEATURES
};
void setGlyphTextureFeatures(Features features) { _glyphTextureFeatures = features; }
Features getGlyphTextureFeatures() const { return _glyphTextureFeatures; }
bool getSpaceForGlyph(Glyph* glyph, int& posX, int& posY);
void addGlyph(Glyph* glyph,int posX, int posY);
@@ -280,16 +294,19 @@ protected:
virtual ~GlyphTexture();
void copyGlyphImage(Glyph* glyph);
// parameter used to compute the size and position of empty space
// in the texture which could accommodate new glyphs.
int _margin;
float _marginRatio;
int _interval;
int _margin;
float _marginRatio;
int _interval;
Features _glyphTextureFeatures;
int _usedY;
int _partUsedX;
int _partUsedY;
int _usedY;
int _partUsedX;
int _partUsedY;
typedef std::vector< osg::ref_ptr<Glyph> > GlyphRefList;
typedef std::vector< const Glyph* > GlyphPtrList;