ImageControl question

classic Classic list List threaded Threaded
3 messages Options
jeladi jeladi
Reply | Threaded
Open this post in threaded view
|

ImageControl question

When porting from 2.8 to 3.0 I have noticed that an ImageControl I am using no longer works.  I just get a white square.  The initialization code looks like this:

m_compassImage = osgDB::readImageFile(std::string("../data/osgResources/Images/compass.png"));

    if(NULL != m_compassImage.get())
    {
        m_compassCtrl = new osgEarth::Util::Controls::ImageControl(m_compassImage.get());
        m_compassCtrl->setHorizAlign(osgEarth::Util::Controls::Control::ALIGN_RIGHT);
        m_compassCtrl->setFixSizeForRotation(true);
        m_rightBox->addControl(m_compassCtrl.get());
    }

Any thoughts?
jeladi jeladi
Reply | Threaded
Open this post in threaded view
|

Re: ImageControl question

BTW I also get the same behavior when I run the osgearth_controls.exe example.  I get a little white rectangle where the osgearth.gif is supposed to be.

I did some investigation of Controls.cpp and it looks like this line of code in Control::getGeomStateSet() is the culprit.

vp->setInheritShaders(false);

If I comment it out both my application and the osgearth_controls example display the image properly.  I thought of a solution where I could derive from ImageControl, call getGeomStateSet() somewhere inside that class, and set inherit shaders to true in the virtual program.  Unfortunately this didn't work and I think it is because the geometry state set gets created each time the function is called even if it already exists in the static member variable.

It looks like both getGeomStateSet() and getImageStateSet() create a state set each time they are called.  Am I interpreting the code correctly?  If so, should they be doing that?

jeladi jeladi
Reply | Threaded
Open this post in threaded view
|

Re: ImageControl question

Never mind I dug through your closed issues list and saw someone already reported this with #1526 back in June.  That fix works fine for me.