Fixed cull callback usage to ensure that the lazy updating of the browser image functions automatically.

This commit is contained in:
Robert Osfield 2008-12-09 14:07:59 +00:00
parent c8190d9c54
commit 9a554f7eec
3 changed files with 13 additions and 4 deletions

View File

@ -240,11 +240,16 @@ struct UpdateOperation : public osg::Operation
if (!image) return false;
double deltaTime = image->getTimeOfLastRender() - image->getTimeOfLastUpdate();
// osg::notify(osg::NOTICE)<<"deltaTime = "<<deltaTime<<std::endl;
// osg::notify(osg::NOTICE)<<" image->getTimeOfLastRender() = "<<image->getTimeOfLastRender()<<std::endl;
// osg::notify(osg::NOTICE)<<" image->getTimeOfLastUpdate() = "<<image->getTimeOfLastUpdate()<<std::endl;
if (deltaTime<0.0)
{
return false;
}
int id = image->getBrowserWindowId();
if (id==0)
@ -283,6 +288,8 @@ struct UpdateOperation : public osg::Operation
GLint internalFormat = LLMozLib::getInstance()->getBrowserDepth( id ) == 3 ? GL_RGB : GL_RGBA;
GLenum pixelFormat = LLMozLib::getInstance()->getBrowserDepth( id ) == 3 ? GL_BGR_EXT : GL_BGRA_EXT;
// osg::notify(osg::NOTICE)<<" doing image update "<<std::endl;
image->setImage(width,height,1, internalFormat, pixelFormat, GL_UNSIGNED_BYTE,
(unsigned char*)LLMozLib::getInstance()->getBrowserWindowPixels( id ),
osg::Image::NO_DELETE);
@ -599,7 +606,6 @@ bool UBrowserImage::sendKeyEvent(int key, bool keyDown)
void UBrowserImage::setFrameLastRendered(const osg::FrameStamp*)
{
_timeOfLastRender = time();
_manager->active(this);
}

View File

@ -152,7 +152,7 @@ class UBrowserImage : public osgWidget::BrowserImage, public LLEmbeddedBrowserWi
// virtual
void onStatusTextChange( const EventType& eventIn )
{
osg::notify(osg::NOTICE) << "Event: status updated to " << eventIn.getStringValue() << std::endl;
osg::notify(osg::INFO) << "Event: status updated to " << eventIn.getStringValue() << std::endl;
};
////////////////////////////////////////////////////////////////////////////////

View File

@ -93,7 +93,10 @@ bool Browser::assign(BrowserImage* browserImage, const GeometryHints& hints)
texture,
osg::StateAttribute::ON);
pictureQuad->setEventCallback(new osgViewer::InteractiveImageHandler(_browserImage.get()));
osg::ref_ptr<osgViewer::InteractiveImageHandler> handler = new osgViewer::InteractiveImageHandler(_browserImage.get());
pictureQuad->setEventCallback(handler.get());
pictureQuad->setCullCallback(handler.get());
addDrawable(pictureQuad);