2008-05-07 21:46:24 +08:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <sstream>
|
|
|
|
#include <osg/io_utils>
|
|
|
|
#include <osg/ArgumentParser>
|
|
|
|
#include <osg/Geode>
|
2017-08-29 20:48:06 +08:00
|
|
|
#include <osg/MatrixTransform>
|
2017-08-31 00:43:29 +08:00
|
|
|
#include <osgDB/ReadFile>
|
2017-08-30 00:19:26 +08:00
|
|
|
#include <osgDB/WriteFile>
|
2008-05-07 21:46:24 +08:00
|
|
|
#include <osgViewer/Viewer>
|
|
|
|
#include <osgViewer/ViewerEventHandlers>
|
2010-03-19 01:10:48 +08:00
|
|
|
#include <osgGA/StateSetManipulator>
|
2008-05-07 21:46:24 +08:00
|
|
|
|
|
|
|
void textInfo(osgText::Text* text)
|
|
|
|
{
|
2010-03-19 01:10:48 +08:00
|
|
|
osgText::String& s = text->getText();
|
|
|
|
|
2017-03-01 00:34:33 +08:00
|
|
|
for(unsigned int i = 0; i < s.size(); i++)
|
|
|
|
{
|
|
|
|
osg::Vec2 ul; text->getCoord(0 + (i * 4), ul); // upperLeft
|
|
|
|
osg::Vec2 ll; text->getCoord(1 + (i * 4), ll); // lowerLeft
|
|
|
|
osg::Vec2 lr; text->getCoord(2 + (i * 4), lr); // lowerRight
|
|
|
|
osg::Vec2 ur; text->getCoord(3 + (i * 4), ur); // upperRight
|
|
|
|
|
|
|
|
osg::notify(osg::NOTICE)
|
|
|
|
<< "'" << static_cast<char>(s[i]) << "':"
|
|
|
|
<< " width(" << lr.x() - ll.x() << ")"
|
|
|
|
<< " height(" << ul.y() - ll.y() << ")" << std::endl << "\t"
|
|
|
|
<< "ul(" << ul << "), "
|
|
|
|
<< "ll(" << ll << "), "
|
|
|
|
<< "lr(" << lr << "), "
|
|
|
|
<< "ur(" << ur << ")"
|
|
|
|
<< std::endl
|
|
|
|
;
|
|
|
|
}
|
2008-05-07 21:46:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
osg::Camera* createOrthoCamera(double width, double height)
|
|
|
|
{
|
2010-03-19 01:10:48 +08:00
|
|
|
osg::Camera* camera = new osg::Camera();
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
camera->getOrCreateStateSet()->setMode(
|
|
|
|
GL_LIGHTING,
|
|
|
|
osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF
|
|
|
|
);
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
osg::Matrix m = osg::Matrix::ortho2D(0.0f, width, 0.0f, height);
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
camera->setProjectionMatrix(m);
|
|
|
|
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
|
|
|
camera->setViewMatrix(osg::Matrix::identity());
|
|
|
|
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
|
|
|
|
camera->setRenderOrder(osg::Camera::POST_RENDER);
|
2009-02-08 23:56:35 +08:00
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
return camera;
|
2008-05-07 21:46:24 +08:00
|
|
|
}
|
|
|
|
|
2017-08-30 17:16:18 +08:00
|
|
|
typedef std::list<unsigned int> Sizes;
|
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
struct TextSettings
|
|
|
|
{
|
|
|
|
TextSettings():
|
|
|
|
fontFilename("fonts/arial.ttf"),
|
2017-09-06 17:40:05 +08:00
|
|
|
minFilter(osg::Texture::LINEAR_MIPMAP_LINEAR),
|
|
|
|
magFilter(osg::Texture::LINEAR),
|
2017-09-09 00:03:15 +08:00
|
|
|
maxAnisotropy(16.0f),
|
2017-10-21 00:03:25 +08:00
|
|
|
shaderTechnique(osgText::GREYSCALE),
|
2017-08-30 00:19:26 +08:00
|
|
|
textColor(1.0f, 1.0f, 1.0f, 1.0f),
|
|
|
|
backdropType(osgText::Text::NONE),
|
2017-09-26 22:32:41 +08:00
|
|
|
backdropOffset(0.07f, 0.07f),
|
2017-09-15 22:14:19 +08:00
|
|
|
backdropColor(0.0f, 0.0f, 0.0f, 1.0f),
|
|
|
|
scaleFontSizeToFontResolution(false)
|
2017-08-30 00:19:26 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-09-06 17:40:05 +08:00
|
|
|
|
|
|
|
void readFilterMode(const std::string& value, osg::Texture::FilterMode& filterMode)
|
|
|
|
{
|
|
|
|
if (value=="LINEAR") filterMode = osg::Texture::LINEAR;
|
2017-09-09 00:03:15 +08:00
|
|
|
else if (value=="NEAREST") filterMode = osg::Texture::NEAREST;
|
|
|
|
else if (value=="LINEAR_MIPMAP_LINEAR") filterMode = osg::Texture::LINEAR_MIPMAP_LINEAR;
|
2017-09-06 17:40:05 +08:00
|
|
|
}
|
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
void read(osg::ArgumentParser& arguments)
|
|
|
|
{
|
2017-08-30 17:16:18 +08:00
|
|
|
if (arguments.read("--test"))
|
|
|
|
{
|
|
|
|
backgroundColor = osg::Vec4(1.0, 1.0, 1.0, 1.0);
|
|
|
|
|
|
|
|
fontFilename = "fonts/arialbd.ttf";
|
|
|
|
backdropType = osgText::Text::OUTLINE;
|
|
|
|
|
|
|
|
sizes.clear();
|
|
|
|
sizes.push_back(8);
|
|
|
|
sizes.push_back(16);
|
|
|
|
sizes.push_back(32);
|
|
|
|
sizes.push_back(64);
|
|
|
|
sizes.push_back(128);
|
|
|
|
}
|
|
|
|
|
2017-10-21 00:03:25 +08:00
|
|
|
if (arguments.read("--GREYSCALE")) { shaderTechnique = osgText::GREYSCALE; }
|
|
|
|
if (arguments.read("--SIGNED_DISTANCE_FIELD")) { shaderTechnique = osgText::SIGNED_DISTANCE_FIELD; }
|
|
|
|
if (arguments.read("--ALL_FEATURES")) { shaderTechnique = osgText::ALL_FEATURES; }
|
2017-09-09 00:03:15 +08:00
|
|
|
|
2017-08-30 17:16:18 +08:00
|
|
|
if (arguments.read("--font",fontFilename)) {}
|
|
|
|
|
2017-09-06 17:40:05 +08:00
|
|
|
std::string value;
|
|
|
|
if (arguments.read("--min", value)) { readFilterMode(value, minFilter); }
|
|
|
|
if (arguments.read("--mag", value)) { readFilterMode(value, magFilter); }
|
|
|
|
|
2017-09-09 00:03:15 +08:00
|
|
|
if (arguments.read("--anisotropy",maxAnisotropy)) {}
|
2017-08-30 17:50:26 +08:00
|
|
|
|
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
if (arguments.read("--outline")) backdropType = osgText::Text::OUTLINE;
|
|
|
|
if (arguments.read("--shadow")) backdropType = osgText::Text::DROP_SHADOW_BOTTOM_RIGHT;
|
2017-09-13 18:08:51 +08:00
|
|
|
if (arguments.read("--shadow-br")) backdropType = osgText::Text::DROP_SHADOW_BOTTOM_RIGHT;
|
|
|
|
if (arguments.read("--shadow-cr")) backdropType = osgText::Text::DROP_SHADOW_CENTER_RIGHT;
|
|
|
|
if (arguments.read("--shadow-tr")) backdropType = osgText::Text::DROP_SHADOW_TOP_RIGHT;
|
|
|
|
if (arguments.read("--shadow-bc")) backdropType = osgText::Text::DROP_SHADOW_BOTTOM_CENTER;
|
|
|
|
if (arguments.read("--shadow-tc")) backdropType = osgText::Text::DROP_SHADOW_TOP_CENTER;
|
|
|
|
if (arguments.read("--shadow-bl")) backdropType = osgText::Text::DROP_SHADOW_BOTTOM_LEFT;
|
|
|
|
if (arguments.read("--shadow-cl")) backdropType = osgText::Text::DROP_SHADOW_CENTER_LEFT;
|
|
|
|
if (arguments.read("--shadow-tl")) backdropType = osgText::Text::DROP_SHADOW_TOP_LEFT;
|
|
|
|
|
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
|
|
|
|
float offset;
|
|
|
|
if (arguments.read("--offset", offset)) backdropOffset.set(offset, offset);
|
|
|
|
|
|
|
|
if (arguments.read("--text-color", textColor.r(), textColor.g(), textColor.b(), textColor.a())) {}
|
|
|
|
if (arguments.read("--bd-color", backdropColor.r(), backdropColor.g(), backdropColor.b(), backdropColor.a())) {}
|
2017-08-30 17:16:18 +08:00
|
|
|
if (arguments.read("--bg-color", backgroundColor.r(), backgroundColor.g(), backgroundColor.b(), backgroundColor.a())) {}
|
|
|
|
|
2017-09-15 22:14:19 +08:00
|
|
|
if (arguments.read("--constant-size")) scaleFontSizeToFontResolution = false;
|
|
|
|
if (arguments.read("--scale-size")) scaleFontSizeToFontResolution = true;
|
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void setText(osgText::Text& text)
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Settings::setText()"<<std::endl;
|
2017-09-09 00:03:15 +08:00
|
|
|
|
2017-09-29 17:20:59 +08:00
|
|
|
osg::ref_ptr<osgText::Font> font;
|
|
|
|
|
|
|
|
if (fontFilename!="default") font = osgText::readRefFontFile(fontFilename);
|
|
|
|
|
|
|
|
if (!font) font = osgText::Font::getDefaultFont();
|
2017-09-09 00:03:15 +08:00
|
|
|
|
|
|
|
font->setMinFilterHint(minFilter);
|
|
|
|
font->setMagFilterHint(magFilter);
|
|
|
|
font->setMaxAnisotropy(maxAnisotropy);
|
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
text.setColor(textColor);
|
|
|
|
text.setBackdropType(backdropType);
|
|
|
|
text.setBackdropOffset(backdropOffset.x(), backdropOffset.y());
|
|
|
|
text.setBackdropColor(backdropColor);
|
2017-10-23 21:50:35 +08:00
|
|
|
text.setShaderTechnique(shaderTechnique);
|
2017-09-13 02:13:01 +08:00
|
|
|
|
|
|
|
text.setFont(font.get());
|
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
}
|
|
|
|
|
2017-09-09 00:03:15 +08:00
|
|
|
std::string fontFilename;
|
|
|
|
osg::Texture::FilterMode minFilter;
|
|
|
|
osg::Texture::FilterMode magFilter;
|
|
|
|
float maxAnisotropy;
|
2017-10-21 00:03:25 +08:00
|
|
|
osgText::ShaderTechnique shaderTechnique;
|
2017-09-09 00:03:15 +08:00
|
|
|
|
|
|
|
osg::Vec4 textColor;
|
|
|
|
osgText::Text::BackdropType backdropType;
|
|
|
|
osg::Vec2 backdropOffset;
|
|
|
|
osg::Vec4 backdropColor;
|
|
|
|
osg::Vec4 backgroundColor;
|
|
|
|
Sizes sizes;
|
2017-09-15 22:14:19 +08:00
|
|
|
bool scaleFontSizeToFontResolution;
|
2017-08-30 00:19:26 +08:00
|
|
|
};
|
|
|
|
|
2017-09-26 22:32:41 +08:00
|
|
|
osgText::Text* createLabel(const std::string& l, TextSettings& settings, unsigned int size, osg::Vec3& pos)
|
2008-05-07 21:46:24 +08:00
|
|
|
{
|
2010-03-19 01:10:48 +08:00
|
|
|
osgText::Text* label = new osgText::Text();
|
2017-08-30 17:50:26 +08:00
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
settings.setText(*label);
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2017-09-15 22:14:19 +08:00
|
|
|
if (settings.scaleFontSizeToFontResolution)
|
|
|
|
{
|
|
|
|
label->setCharacterSize(size);
|
|
|
|
}
|
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
label->setFontResolution(size, size);
|
|
|
|
label->setPosition(pos);
|
|
|
|
label->setAlignment(osgText::Text::LEFT_BOTTOM);
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
// It seems to be important we do this last to get best results?
|
|
|
|
label->setText(l);
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2017-08-30 00:19:26 +08:00
|
|
|
// textInfo(label);
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2017-09-15 22:14:19 +08:00
|
|
|
pos.y() += label->getCharacterHeight()*2.0;
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
return label;
|
2008-05-07 21:46:24 +08:00
|
|
|
}
|
|
|
|
|
2017-09-06 23:53:54 +08:00
|
|
|
class KeyHandler : public osgGA::GUIEventHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
KeyHandler() {}
|
|
|
|
|
|
|
|
~KeyHandler() {}
|
|
|
|
|
|
|
|
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
|
|
|
|
{
|
|
|
|
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
|
|
|
|
if (!view) return false;
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
osg::StateSet* stateset = view->getSceneData()->getOrCreateStateSet();
|
|
|
|
#else
|
|
|
|
osg::StateSet* stateset = view->getCamera()->getOrCreateStateSet();
|
|
|
|
#endif
|
|
|
|
switch(ea.getEventType())
|
|
|
|
{
|
|
|
|
case(osgGA::GUIEventAdapter::KEYUP):
|
|
|
|
{
|
|
|
|
if (ea.getKey()=='d')
|
|
|
|
{
|
|
|
|
toggleDefine(stateset, "SIGNED_DISTANCE_FIELD");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (ea.getKey()=='o')
|
|
|
|
{
|
|
|
|
toggleDefine(stateset, "OUTLINE");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2017-08-30 00:19:26 +08:00
|
|
|
|
2017-09-06 23:53:54 +08:00
|
|
|
void toggleDefine(osg::StateSet* stateset, const std::string& define)
|
|
|
|
{
|
|
|
|
osg::StateSet::DefinePair* dp = stateset->getDefinePair(define);
|
|
|
|
if (dp)
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Disabling "<<define<<std::endl;
|
|
|
|
stateset->removeDefine(define);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Enabling "<<define<<std::endl;
|
|
|
|
stateset->setDefine(define);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-08-30 00:19:26 +08:00
|
|
|
|
2008-05-07 21:46:24 +08:00
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2010-03-19 01:10:48 +08:00
|
|
|
osg::ArgumentParser args(&argc, argv);
|
2017-08-29 19:21:14 +08:00
|
|
|
osgViewer::Viewer viewer(args);
|
2008-05-07 21:46:24 +08:00
|
|
|
|
|
|
|
|
2017-09-06 23:53:54 +08:00
|
|
|
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
|
2010-03-19 01:10:48 +08:00
|
|
|
viewer.addEventHandler(new osgViewer::StatsHandler());
|
|
|
|
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
|
2017-09-06 23:53:54 +08:00
|
|
|
viewer.addEventHandler(new KeyHandler());
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2017-08-30 17:16:18 +08:00
|
|
|
TextSettings settings;
|
|
|
|
settings.backgroundColor = viewer.getCamera()->getClearColor();
|
|
|
|
|
|
|
|
settings.read(args);
|
|
|
|
|
|
|
|
viewer.getCamera()->setClearColor(settings.backgroundColor);
|
2017-08-29 20:48:06 +08:00
|
|
|
|
|
|
|
osg::ref_ptr<osg::Group> root = new osg::Group;
|
|
|
|
|
2017-09-26 22:32:41 +08:00
|
|
|
bool split_screen = args.read("--split");
|
|
|
|
|
|
|
|
if (split_screen)
|
2017-08-29 20:48:06 +08:00
|
|
|
{
|
2017-09-26 22:32:41 +08:00
|
|
|
viewer.realize();
|
|
|
|
|
|
|
|
// quite an dirty divusion of the master Camera's window if one is assigned.
|
|
|
|
if (viewer.getCamera()->getGraphicsContext())
|
|
|
|
{
|
|
|
|
viewer.stopThreading();
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::GraphicsContext> gc = viewer.getCamera()->getGraphicsContext();
|
|
|
|
osg::ref_ptr<const osg::GraphicsContext::Traits> traits = gc->getTraits();
|
|
|
|
|
|
|
|
// left half
|
|
|
|
{
|
|
|
|
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
|
|
|
|
camera->setCullMask(0x1);
|
|
|
|
camera->setGraphicsContext(gc.get());
|
|
|
|
camera->setViewport(new osg::Viewport(0,0, traits->width/2, traits->height));
|
|
|
|
viewer.addSlave(camera.get(), osg::Matrixd::translate(1.0,0.0,0.0), osg::Matrixd::scale(2.0, 1.0, 1.0));
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
|
|
|
|
camera->setCullMask(0x2);
|
|
|
|
camera->setGraphicsContext(gc.get());
|
|
|
|
camera->setViewport(new osg::Viewport(traits->width/2+2,0, traits->width/2, traits->height));
|
|
|
|
viewer.addSlave(camera.get(), osg::Matrixd::translate(-1.0,0.0,0.0), osg::Matrixd::scale(2.0, 1.0, 1.0));
|
|
|
|
}
|
|
|
|
|
|
|
|
viewer.getCamera()->setGraphicsContext(0);
|
|
|
|
|
|
|
|
viewer.startThreading();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
split_screen = false;
|
|
|
|
}
|
2017-08-29 20:48:06 +08:00
|
|
|
}
|
|
|
|
|
2017-09-26 22:32:41 +08:00
|
|
|
osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform;
|
|
|
|
transform->setMatrix(osg::Matrixd::rotate(osg::DegreesToRadians(90.0), 1.0, 0.0, 0.0));
|
|
|
|
root->addChild(transform.get());
|
|
|
|
root = transform;
|
|
|
|
|
2017-08-31 00:43:29 +08:00
|
|
|
osg::ref_ptr<osg::Program> program = new osg::Program;
|
|
|
|
std::string shaderFilename;
|
|
|
|
while(args.read("--shader", shaderFilename))
|
|
|
|
{
|
|
|
|
osg::ref_ptr<osg::Shader> shader = osgDB::readRefShaderFile(shaderFilename);
|
|
|
|
if (shader.get())
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Loading shader "<<shaderFilename<<std::endl;
|
|
|
|
program->addShader(shader.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (program->getNumShaders()>0)
|
|
|
|
{
|
|
|
|
OSG_NOTICE<<"Using shaders"<<std::endl;
|
|
|
|
root->getOrCreateStateSet()->setAttribute(program.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
|
|
|
|
root->getOrCreateStateSet()->addUniform(new osg::Uniform("glyphTexture", 0));
|
2017-09-09 00:03:15 +08:00
|
|
|
|
2017-10-21 00:03:25 +08:00
|
|
|
settings.shaderTechnique = osgText::ALL_FEATURES;
|
2017-08-31 00:43:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string outputFilename;
|
|
|
|
if (args.read("-o", outputFilename)) {}
|
|
|
|
|
2017-08-30 17:16:18 +08:00
|
|
|
if (args.argc() > 1)
|
|
|
|
{
|
|
|
|
settings.fontFilename = argv[1];
|
2017-08-29 20:48:06 +08:00
|
|
|
|
2017-08-30 17:16:18 +08:00
|
|
|
// Create the list of desired sizes.
|
|
|
|
for(int i = 2; i < args.argc(); i++)
|
|
|
|
{
|
|
|
|
if(!args.isNumber(i)) continue;
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2017-08-30 17:16:18 +08:00
|
|
|
settings.sizes.push_back(std::atoi(args[i]));
|
|
|
|
}
|
|
|
|
}
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2017-08-30 17:16:18 +08:00
|
|
|
if (settings.sizes.empty())
|
2010-03-19 01:10:48 +08:00
|
|
|
{
|
2017-08-30 17:16:18 +08:00
|
|
|
settings.sizes.push_back(8);
|
|
|
|
settings.sizes.push_back(16);
|
|
|
|
settings.sizes.push_back(32);
|
|
|
|
settings.sizes.push_back(64);
|
2010-03-19 01:10:48 +08:00
|
|
|
}
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2017-09-26 22:32:41 +08:00
|
|
|
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
|
|
|
|
|
|
|
osg::Vec3 pos(0.0f, 0.0f, 0.0f);
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
// Add all of our osgText drawables.
|
2017-08-30 17:16:18 +08:00
|
|
|
for(Sizes::const_iterator i = settings.sizes.begin(); i != settings.sizes.end(); i++)
|
2010-03-19 01:10:48 +08:00
|
|
|
{
|
|
|
|
std::stringstream ss;
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2010-03-19 01:10:48 +08:00
|
|
|
ss << *i << " 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
2008-05-07 21:46:24 +08:00
|
|
|
|
2017-09-26 22:32:41 +08:00
|
|
|
geode->addDrawable(createLabel(ss.str(), settings, *i, pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
root->addChild(geode.get());
|
|
|
|
|
|
|
|
if (split_screen)
|
|
|
|
{
|
|
|
|
geode->setNodeMask(0x1);
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Geode> right_geode = new osg::Geode;
|
|
|
|
right_geode->setNodeMask(0x2);
|
|
|
|
|
2017-10-21 00:03:25 +08:00
|
|
|
settings.shaderTechnique = osgText::GREYSCALE;
|
2017-09-26 22:32:41 +08:00
|
|
|
|
|
|
|
pos.set(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
for(Sizes::const_iterator i = settings.sizes.begin(); i != settings.sizes.end(); i++)
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
|
|
|
|
ss << *i << " 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
|
|
|
|
right_geode->addDrawable(createLabel(ss.str(), settings, *i, pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
root->addChild(right_geode);
|
2010-03-19 01:10:48 +08:00
|
|
|
}
|
2008-05-07 21:46:24 +08:00
|
|
|
|
|
|
|
|
2017-08-31 00:43:29 +08:00
|
|
|
if (!outputFilename.empty())
|
2017-08-30 00:19:26 +08:00
|
|
|
{
|
2017-08-31 00:43:29 +08:00
|
|
|
osgDB::writeNodeFile(*root, outputFilename);
|
2017-08-30 00:19:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-29 20:48:06 +08:00
|
|
|
viewer.setSceneData(root.get());
|
2010-03-19 01:10:48 +08:00
|
|
|
|
|
|
|
return viewer.run();
|
2008-05-07 21:46:24 +08:00
|
|
|
}
|
2009-02-08 23:56:35 +08:00
|
|
|
|