OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osgText::Text display issue (only white boxes rendered)


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
eskay187
Newbie


Joined: 28 Jul 2017
Posts: 4

PostPosted: Tue Dec 26, 2017 1:35 pm    Post subject:
osgText::Text display issue (only white boxes rendered)
Reply with quote

Hi,
for whatever reason I can not get correct correct 2D text display method working. My code is based on the osghud example, in the background I render a osgEarth map. The text is displayed, but always looks like only the "background" of each character is rendered, please see the attached screenshot.

I am using OSG 3.4.0 release on Ubuntu 17.10 with an NVIDIA GTX 1080 driver 384.90, also using osgEarth 2.8 and the osgEarthQt::Viewer to integrate into Qt5.

The following code should create the HUD:

[code]

void setup ()
{
...
font_ = osgText::readFontFile(HOME_DATA_DIRECTORY+"fonts/arial.ttf");

osgViewer::Viewer::Windows windows;
osg_viewer_->getWindows(windows);

assert (!windows.empty());

osg::Camera* hud_camera = createHUDCamera(0,windows[0]->getTraits()->width, 0, windows[0]->getTraits()->height);
hud_camera->setGraphicsContext(windows[0]);

osg::ref_ptr<osg::Geode> textGeode = new osg::Geode;
textGeode->addDrawable (createText(osg::Vec3(150.0f, 300.0f, 0.0f), "The Cessna monoplane", 10.0f));
textGeode->addDrawable (createText(osg::Vec3(150.0f, 400.0f, 0.0f), "Six-seat, low-wing and twin-engined", 15.0f));

hud_camera->addChild(textGeode);

root_node_->addChild(hud_camera);
...
}

osg::Camera* OSGViewDataWidget::createHUDCamera (double left, double right, double bottom, double top)
{
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
//camera->getOrCreateStateSet()->setGlobalDefaults();
camera->setReferenceFrame (osg::Transform::ABSOLUTE_RF);
camera->setClearMask (GL_DEPTH_BUFFER_BIT);
camera->setRenderOrder (osg::Camera::POST_RENDER);
camera->setAllowEventFocus (false);
camera->setProjectionMatrix (osg::Matrix::ortho2D (left, right, bottom, top));
camera->setViewMatrix(osg::Matrix::identity());
camera->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
return camera.release();
}

osgText::Text* OSGViewDataWidget::createText (const osg::Vec3& pos, const std::string& content, float size)
{
osg::ref_ptr<osgText::Text> text = new osgText::Text;
//text->setColor(osg::Vec4(0.0f, 1.0f, 1.0f, 1.0f));
text->setFontResolution (50,50);
text->setFont (font_.get());
text->setCharacterSize (size);
text->setAxisAlignment (osgText::TextBase::XY_PLANE);
text->setPosition (pos);
text->setText (content);
text->setDrawMode (osgText::TextBase::DrawModeMask::FILLEDBOUNDINGBOX | osgText::TextBase::DrawModeMask::TEXT);
text->setBoundingBoxColor (osg::Vec4(0.0f, 0.0f, 0.2f, 0.25f));
text->setBoundingBoxMargin (2.0f);
return text.release();
}
[/code]

I have tried several implementations but can for the life of me can not figure out what the issue is. If I change the font, the displayed white boxes change as well, so at least something happens ...

Can someone point me in the right direction? Any help would be appreciated.


Thank you!

Cheers,
Helmut
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 426
Location: France

PostPosted: Thu Dec 28, 2017 10:34 pm    Post subject:
Re: osgText::Text display issue (only white boxes rendered)
Reply with quote

Hi,
I think you should make a simple example to track where the bug is:
Personnaly I experienced a lot of conflicts between osg and qt renderer especially since I use qml for gui and embed osg rendering in a QQuickViewport (both qt and osg changed GL state leading to conflicts)

Try to reproduce the bug without Qt, if the problem persists, it's an osg bug. Only then, you'll can give us a simple cpp example (in attachment) to diagnose easily the issue.

Edit: Here's a copy paste from my frame() func osg rendering in a qt renderer..... don' know if it can help.. it's kind of empirical coding:
Code:
 glPushAttrib(GL_ALL_ATTRIB_BITS);
        // Qt bug!?
        QOpenGLContext::currentContext()->functions()->glUseProgram(0);
        glDisable(GL_BLEND);
        glEnable(GL_DEPTH_TEST);
        glDisable(GL_ALPHA_TEST);
        compositeViewer->frame();
        glDisable(GL_TEXTURE_3D);
  glPopAttrib();
      glDisable(GL_BLEND);
      glEnable(GL_DEPTH_TEST);            
       glDisable(GL_ALPHA_TEST);
             OpenGLContext::currentContext()->functions()->glActiveTexture(GL_TEXTURE0);


Cheers

eskay187 wrote:
Hi,
for whatever reason I can not get correct correct 2D text display method working. My code is based on the osghud example, in the background I render a osgEarth map. The text is displayed, but always looks like only the "background" of each character is rendered, please see the attached screenshot.

I am using OSG 3.4.0 release on Ubuntu 17.10 with an NVIDIA GTX 1080 driver 384.90, also using osgEarth 2.8 and the osgEarthQt::Viewer to integrate into Qt5.

The following code should create the HUD:

Code:


void setup ()
{
...
    font_ = osgText::readFontFile(HOME_DATA_DIRECTORY+"fonts/arial.ttf");

    osgViewer::Viewer::Windows windows;
    osg_viewer_->getWindows(windows);

    assert (!windows.empty());

    osg::Camera* hud_camera = createHUDCamera(0,windows[0]->getTraits()->width, 0, windows[0]->getTraits()->height);
    hud_camera->setGraphicsContext(windows[0]);

    osg::ref_ptr<osg::Geode> textGeode = new osg::Geode;
    textGeode->addDrawable (createText(osg::Vec3(150.0f, 300.0f, 0.0f),  "The Cessna monoplane", 10.0f));
    textGeode->addDrawable (createText(osg::Vec3(150.0f, 400.0f, 0.0f),  "Six-seat, low-wing and twin-engined", 15.0f));

    hud_camera->addChild(textGeode);

    root_node_->addChild(hud_camera);
...
}

osg::Camera* OSGViewDataWidget::createHUDCamera (double left, double right, double bottom, double top)
{
    osg::ref_ptr<osg::Camera> camera = new osg::Camera;
    //camera->getOrCreateStateSet()->setGlobalDefaults();
    camera->setReferenceFrame (osg::Transform::ABSOLUTE_RF);
    camera->setClearMask (GL_DEPTH_BUFFER_BIT);
    camera->setRenderOrder (osg::Camera::POST_RENDER);
    camera->setAllowEventFocus (false);
    camera->setProjectionMatrix (osg::Matrix::ortho2D (left, right, bottom, top));
    camera->setViewMatrix(osg::Matrix::identity());
    camera->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
    return camera.release();
}

osgText::Text* OSGViewDataWidget::createText (const osg::Vec3& pos, const std::string& content, float size)
{
    osg::ref_ptr<osgText::Text> text = new osgText::Text;
    //text->setColor(osg::Vec4(0.0f, 1.0f, 1.0f, 1.0f));
    text->setFontResolution (50,50);
    text->setFont (font_.get());
    text->setCharacterSize (size);
    text->setAxisAlignment (osgText::TextBase::XY_PLANE);
    text->setPosition (pos);
    text->setText (content);
    text->setDrawMode (osgText::TextBase::DrawModeMask::FILLEDBOUNDINGBOX | osgText::TextBase::DrawModeMask::TEXT);
    text->setBoundingBoxColor (osg::Vec4(0.0f, 0.0f, 0.2f, 0.25f));
    text->setBoundingBoxMargin (2.0f);
    return text.release();
}


I have tried several implementations but can for the life of me can not figure out what the issue is. If I change the font, the displayed white boxes change as well, so at least something happens ...

Can someone point me in the right direction? Any help would be appreciated.


Thank you!

Cheers,
Helmut
Back to top
View user's profile Send private message Visit poster's website
eskay187
Newbie


Joined: 28 Jul 2017
Posts: 4

PostPosted: Sun Dec 31, 2017 9:24 am    Post subject:
Code Example
Reply with quote

Hi,
thank you for your reply, and sorry for my late response (holidays).

I have made a "simple" example of the bug in form of a standalone program, which is based on the osgpointsprites, osghud examples and the osgEarthQt Viewer.

You'll also see the the point sprite textures are not rendered correctly (near Africa), as the whole texture is rendered as a simple white rectangle. I assumed this to be related to the same error, so I added it.

What I should have mentioned previously is that of course the examples themselves (on their own) work fine, but if they are combined in the way as I have done something weird is going on, and since I am not a graphics specialist I am somewhat out of my depth.

If it should turn out that the osgEarthQt usage/lib is the issue, then I guess I'll have to apologize for reporting in the wrong forum. I just started posting here since the rendering error showed when using code based on osg examples.

To build the example, just run "cmake .." in the build folder and run it in the "build/bin" folder (some data files are stored there that are used). You'll also need to have osgEarth (2.8) installed and an active internet connection to load the map data.

The attached files are to code/data files and a screenshot of how it looks in my setup.

Again, thank you for your support. If I can give further information please let me know.

Cheers,
Helmut
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 426
Location: France

PostPosted: Sun Dec 31, 2017 3:53 pm    Post subject:
Re: Code Example
Reply with quote

Hi
Thank for the effort but it seams your example is still based on a QT graphic context.
In order to determine if the bug come from osg or from qt, you should use a classic osgUtil::CompositeViewer (OSGViewDataWidget is a QtWidget coming from osgEarth, so removing it is mandatory in order to determine if there's a bug in core osg)
cheers

eskay187 wrote:
Hi,
thank you for your reply, and sorry for my late response (holidays).

I have made a "simple" example of the bug in form of a standalone program, which is based on the osgpointsprites, osghud examples and the osgEarthQt Viewer.

You'll also see the the point sprite textures are not rendered correctly (near Africa), as the whole texture is rendered as a simple white rectangle. I assumed this to be related to the same error, so I added it.

What I should have mentioned previously is that of course the examples themselves (on their own) work fine, but if they are combined in the way as I have done something weird is going on, and since I am not a graphics specialist I am somewhat out of my depth.

If it should turn out that the osgEarthQt usage/lib is the issue, then I guess I'll have to apologize for reporting in the wrong forum. I just started posting here since the rendering error showed when using code based on osg examples.

To build the example, just run "cmake .." in the build folder and run it in the "build/bin" folder (some data files are stored there that are used). You'll also need to have osgEarth (2.Cool installed and an active internet connection to load the map data.

The attached files are to code/data files and a screenshot of how it looks in my setup.

Again, thank you for your support. If I can give further information please let me know.

Cheers,
Helmut
Back to top
View user's profile Send private message Visit poster's website
eskay187
Newbie


Joined: 28 Jul 2017
Posts: 4

PostPosted: Mon Jan 01, 2018 11:36 am    Post subject:
Re: Code Example
Reply with quote

Hi again,
I found the issue. While I compiled the example you requested, I disabled the LogarithmicDepthBuffer I used, and voila, both issues were resolved.

I used the following code in the scene set up:

Code:
osg::Camera* camera = osg_viewer_->getCamera();
LogarithmicDepthBuffer logdepth;
logdepth.install(camera);


This somehow messed up the display, for reasons unknown to me. So it seems that everything works with the Viewer and also in the Qt5 setup, if this devious LogarithmicDepthBuffer is not used.

So, thanks for your support!

mp3butcher wrote:
Hi
Thank for the effort but it seams your example is still based on a QT graphic context.
In order to determine if the bug come from osg or from qt, you should use a classic osgUtil::CompositeViewer (OSGViewDataWidget is a QtWidget coming from osgEarth, so removing it is mandatory in order to determine if there's a bug in core osg)
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11910

PostPosted: Mon Jan 01, 2018 12:33 pm    Post subject:
osgText::Text display issue (only white boxes rendered)
Reply with quote

Hi Helmut,

Good to hear you've found a form of resolution for the text issue. My
guess is that the logarithmic depth buffer is implemented with a
custom fragment shader and this shader doesn't support text, or
osgText itself is providing shaders that aren't compatible so the
depths are all wrong.

Robert.

On 1 January 2018 at 11:36, Helmut Puhr <> wrote:
Quote:
Hi again,
I found the issue. While I compiled the example you requested, I disabled the LogarithmicDepthBuffer I used, and voila, both issues were resolved.

I used the following code in the scene set up:


Code:
osg::Camera* camera = osg_viewer_->getCamera();
LogarithmicDepthBuffer logdepth;
logdepth.install(camera);



This somehow messed up the display, for reasons unknown to me. So it seems that everything works with the Viewer and also in the Qt5 setup, if this devious LogarithmicDepthBuffer is not used.

So, thanks for your support!


mp3butcher wrote:
Quote:
Hi
Thank for the effort but it seams your example is still based on a QT graphic context.
In order to determine if the bug come from osg or from qt, you should use a classic osgUtil::CompositeViewer (OSGViewDataWidget is a QtWidget coming from osgEarth, so removing it is mandatory in order to determine if there's a bug in core osg)


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72658#72658




Attachments:
http://forum.openscenegraph.org//files/example_working_223.png





------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts OSG + Qt performance issue Ale General 1 Wed May 30, 2018 3:13 pm View latest post
No new posts DXF file with text crashes on Intersect brianh General 4 Tue May 29, 2018 3:15 pm View latest post
No new posts Which character encoding is used by o... wernerM General 1 Tue May 29, 2018 2:53 pm View latest post
No new posts osgText: problem with SCREEN_COORDS mode gwaldron General 9 Thu May 17, 2018 3:56 pm View latest post
No new posts Text Bounding Box Calculation Daniel Emminizer, Code... General 2 Mon May 14, 2018 3:03 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP