What is probably happening is the update to the texture is happening
just fine, but the previous frames draw traversal is still running so
sees the update to the image and downloads and uses it right away.
Setting the threading to SingleThreaded will prevent the osgViewer
from running the update in parallel to the previous draw traversal so
avoid this issue of texture being applied a frame early.
However, a better solution is to set the DataVariance on the StateSet
that the Texture is associated with to DYNAMIC stateset so that the
draw traversal knows to hold back the next frame till all the elements
that are changing have been dispatched first. The checked for
DataVariance is only done at Drawable and StateSet level so setting
this directly on the Texture won't help.
A a general note, make sure your a using an osg::ImageStream for
continuously updating data as this subclass from osg::Image adds the
use of PixelBufferObject automatically, this provides a much more
efficient means for downloading the data to OpenGL.
On Mon, Aug 29, 2011 at 10:32 PM, Fred Maulir <> wrote:
Hello to All,
I'm having a very specific issue using OpenSceneGraph. While using a texture shader I developped, I need to attach a texture to my object. But my texture need to be changed at each frame. However, I noticed that my texture is not updated in the next viewer.update() if my computer is very fast. If I slow down my computer it is correctly synchronized.
In other word, I'm looking for a way to way for a texture object to be propagated in the gpu buffer before rendering the frame.
As I'm using OpenSceneGraph for simulation purpose even 1 frame offset is not acceptable for me.
Basically the code can be summed up this way:
IMAGE->setImage(..., imageData, osg::Image::AllocationMode::NO_DELETE);
osg::StateSet *mystate = new osg::StateSet();
osg::Texture2D *texture = new osg::Texture2D();
IMAGE->setImage(..., ImageData[i], osg::Image::AllocationMode::NO_DELETE);
In this example when rendering the scene OSG sometimes uses the ImageData of index i-1 instead of index i
If anyone can help me I would be very happy.
Read this topic online here:
Post generated by Mail2Forum