Hi Robert,

I've been testing the RC5 and I have a problem with text.  I saw PR # 523 and 
thought it might be the same problem.  It looks quite similar to the issue I'm 
seeing.  I updated to RC6 (includes PR 523) and things look a lot better, but 
not completely fixed.

I have finally been able to reproduce this in native OSG without any extra 
libraries.  Attached is a .cpp modification of the osgtext example that 
demonstrates the problem.  This is tested on RC6.


The text "Left" is on the left side, and (correctly) shifts position each frame 
(up and down).  This is important, because the position changes every frame.  
But the bounding box on the Left text (incorrectly) keeps getting bigger and 
bigger.

The text "Right" is on the right side, and its position is set to the right 
side of "Left" text, based on Left's bounding box.  You'll see it float to the 
right as the frames redraw.  I would expect "Right" to stay in the same place 
horizontally, but it does not.


The problem seems to be related to:
1) Changing the position of the text to a new position
2) Having a drop shadow


Unfortunately I do not know how to fix this.  I can work on it if you 
want/need, but perhaps you see the problem right away?  Please let me know if 
the attachment osgtext.cpp doesn't come through for some reason.

 - Dan


-----Original Message-----
From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Friday, April 06, 2018 10:02 AM
To: OpenSceneGraph Users
Subject: [osg-users] OpenSceneGraph-3.6.0 release candidate 6

Hi All,

I have just tagged release candidate 6:

    
https://github.com/openscenegraph/OpenSceneGraph/tree/OpenSceneGraph-3.6.0-rc6

I'm really hoping this is now and we are good to go.  If things are
building and running OK I'll tag 3.6.0 tomorrow.   So yet another big
PLEASE test :-)

Let us know about success or failures so we know where we are at for the 
release.

Thankyou!
Robert.

--Changes since rc5

Fri, 6 Apr 2018 14:47:54 +0100
Author : Robert Osfield
Updated for rc6

Fri, 6 Apr 2018 14:17:35 +0100
Author : Robert Osfield
Fixed warning

Fri, 6 Apr 2018 14:07:58 +0100
Author : Robert Osfield
Changed TextBase::setAlignment() to use computeGlyphRepresentation(); rather 
than computePositions(); to address issues seen with calling
Text::setAlignment() after calls to Text::setText()

Fri, 6 Apr 2018 14:06:50 +0100
Author : Robert Osfield
Added osgtext --alignment test to look the effect of calling
Text::setAlignent() before and after the Text::setText().

Thu, 5 Apr 2018 18:00:30 +0100
Author : OpenSceneGraph git repository
Merge pull request #525 from emminizer/fix-windows-exportosgDB: Added missing 
extern OSGDB_EXPORT.

Thu, 5 Apr 2018 10:51:24 -0400
Author : Daniel Emminizer
osgDB: Added missing extern OSGDB_EXPORT.

Thu, 5 Apr 2018 14:14:49 +0100
Author : Robert Osfield
Quietened down debug message output for osgText shader setup and 
Drawable::createVertexArrayStateImplementation

Thu, 5 Apr 2018 12:35:36 +0100
Author : Robert Osfield
Changed DisplaySettings::setShaderHint(..) messages to INFO

Thu, 5 Apr 2018 12:19:56 +0100
Author : Robert Osfield
Updated ChangeLOG and news

Thu, 5 Apr 2018 11:21:55 +0200
Author : Philippe Renon
mingw: fix compile error in GraphicsWindowWin32.cppcompilation error was 
introduced by msvc specific change see 
https://github.com/openscenegraph/OpenSceneGraph/commit/bb169979a1054e2fa63a7ea82c9c8bec87e90494
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
/* OpenSceneGraph example, osgtext.
*
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the "Software"), to deal
*  in the Software without restriction, including without limitation the rights
*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*  copies of the Software, and to permit persons to whom the Software is
*  furnished to do so, subject to the following conditions:
*
*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*  THE SOFTWARE.
*/

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>

#include <osgGA/StateSetManipulator>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>

#include <osg/Camera>

#include <osgText/Font>
#include <osgText/Text>

class UpdateText : public osgGA::GUIEventHandler
{
public:
  UpdateText(osgText::Text* left, osgText::Text* right)
    : left_(left), right_(right), flipText_(false)
  {
  }

  virtual bool handle(const osgGA::GUIEventAdapter& ea, 
osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*)
  {
    if (ea.getEventType() == ea.FRAME)
    {
      static const int INIT_X = 10;
      static const int INIT_Y = 100;

      osg::BoundingBox bb1 = left_->getBoundingBox();

      // Alternate the Y to get new positions every frame
      int newY = INIT_Y;
      if (flipText_)
        newY += 10.f;
      flipText_ = !flipText_;

      left_->setPosition(osg::Vec3f(INIT_X, newY, 0.f));
      int newX = (bb1.xMax() - bb1.xMin()) + 50 + INIT_X;
      right_->setPosition(osg::Vec3f(newX, newY, 0.f));
    }
    return false;
  }
private:
  osg::ref_ptr<osgText::Text> left_;
  osg::ref_ptr<osgText::Text> right_;
  bool flipText_;
};


int main(int argc, char** argv)
{
    osg::ArgumentParser arguments(&argc, argv);

    // construct the viewer.
    osgViewer::Viewer viewer(arguments);

    // create the hud.
    osg::Camera* camera = new osg::Camera;
    camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    camera->setProjectionMatrixAsOrtho2D(0, 1280, 0, 1024);
    camera->setViewMatrix(osg::Matrix::identity());
    camera->setClearMask(GL_DEPTH_BUFFER_BIT);
    camera->getOrCreateStateSet()->setMode(GL_LIGHTING, 
osg::StateAttribute::OFF);

    viewer.setSceneData(camera);

    osgText::Text* left = new osgText::Text;
    left->setFont("fonts/arialbd.ttf");
    left->setText("Left");
    left->setDataVariance(osg::Object::DYNAMIC);
    left->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT);
    camera->addChild(left);

    osgText::Text* right = new osgText::Text;
    right->setFont("fonts/arialbd.ttf");
    right->setText("Right");
    right->setDataVariance(osg::Object::DYNAMIC);
    right->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT);
    camera->addChild(right);

    viewer.addEventHandler(new UpdateText(left, right));
    viewer.addEventHandler(new 
osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
    viewer.addEventHandler(new osgViewer::StatsHandler());

    viewer.run();

    return 0;
}

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to