From 20ee12e9866112f9d9dbf42132e665311683de03 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 6 Sep 2017 10:40:05 +0100 Subject: [PATCH] To control the GlyphTexture Min/MagFilter values Added --min and --mag filter with LINEAR, NEAREST and LINEAR_MIPMAP_LINER options for values --- examples/osgfont/osgfont.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/osgfont/osgfont.cpp b/examples/osgfont/osgfont.cpp index 823e7ae24..55f893f36 100644 --- a/examples/osgfont/osgfont.cpp +++ b/examples/osgfont/osgfont.cpp @@ -65,6 +65,8 @@ struct TextSettings { TextSettings(): fontFilename("fonts/arial.ttf"), + minFilter(osg::Texture::LINEAR_MIPMAP_LINEAR), + magFilter(osg::Texture::LINEAR), glyphImageMargin(1), glyphImageMarginRatio(0.02), glyphInterval(1), @@ -75,6 +77,14 @@ struct TextSettings { } + + void readFilterMode(const std::string& value, osg::Texture::FilterMode& filterMode) + { + if (value=="LINEAR") filterMode = osg::Texture::LINEAR; + if (value=="NEAREST") filterMode = osg::Texture::NEAREST; + if (value=="LINEAR_MIPMAP_LINEAR") filterMode = osg::Texture::LINEAR_MIPMAP_LINEAR; + } + void read(osg::ArgumentParser& arguments) { if (arguments.read("--test")) @@ -94,6 +104,10 @@ struct TextSettings if (arguments.read("--font",fontFilename)) {} + std::string value; + if (arguments.read("--min", value)) { readFilterMode(value, minFilter); } + if (arguments.read("--mag", value)) { readFilterMode(value, magFilter); } + if (arguments.read("--margin", glyphImageMargin)) {} if (arguments.read("--margin-ratio", glyphImageMarginRatio)) {} @@ -123,6 +137,8 @@ struct TextSettings } std::string fontFilename; + osg::Texture::FilterMode minFilter; + osg::Texture::FilterMode magFilter; unsigned int glyphImageMargin; float glyphImageMarginRatio; int glyphInterval; @@ -144,6 +160,8 @@ osgText::Text* createLabel(const std::string& l, TextSettings& settings, unsigne font->setGlyphImageMargin(settings.glyphImageMargin); font->setGlyphImageMarginRatio(settings.glyphImageMarginRatio); + font->setMinFilterHint(settings.minFilter); + font->setMagFilterHint(settings.magFilter); settings.setText(*label);