Can someone explain why the code below consistently produces text that
is half the height specified? If I render this text, take a screenshot
and measure the height of the text "ABC" in a paint program it will
measure up as approximately 64 pixels tall for a character size /
resolution of 128. I change the 128 to 256, the text will then
measures 128 and so on. Always measures half of what I specify. Should
this not render text that is approximately 128 pixels in height? I
understand that the characters won't be exactly the width/height I
specify, but half? Is this a bug or what?

{
    osg::Vec3d pos(osg::DegreesToRadians(someLat),
osg::DegreesToRadians(someLon), 0);
    ellipsoidModel->convertLatLongHeightToXYZ(pos[0], pos[1], pos[2],
pos[0], pos[1], pos[2]);
    osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform();
    mt->setMatrix(osg::Matrix::identity());
    mt->setMatrix(osg::Matrix::translate(pos));

    osg::ref_ptr<osgText::Text> text = new osgText::Text;
    text->setFont("Arial.ttf");
    osgText::Text::BackdropType type = osgText::Text::OUTLINE;
    text->setBackdropType(type);
    text->setColor(osg::Vec4(1,1,1,1));
    text->setBackdropColor(osg::Vec4(0,0,0,1));
    text->setAlignment(osgText::TextBase::CENTER_CENTER);
    text->setAutoRotateToScreen(true);
    text->setText("ABC");
    text->setCharacterSizeMode( osgText::TextBase::SCREEN_COORDS );
    text->setCharacterSize(128);
    text->setFontResolution(128, 128);


    osg::ref_ptr<osg::Geode> geode = new osg::Geode();
    geode->addDrawable(text.get());

    mt->addChild(geode.get());
    mt->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
    root->addChild(mt.get());
  }
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to