[osg-users] Update a texture's pixels contents, using apply or glTexSubImage2D
robert.osfield at gmail.com
Fri Sep 26 01:33:42 PDT 2008
The way to integrate a live video stream is to subclass from
osg::ImageStream (which is subclass from osg::Image), as is done in
the OSG's quicktime and xine-lib plugins. The ImageStream is then
attached to Texture be it a Texture1D, 2D, 3D or TextureRectangle.
This approach means that you don't ever subclass from the Texture
objects as the image data is encapsulated complete by
The way I'd tackle your task is to subclass from osg::ImageStream and
then allocate the image data then copy over this in your background
thread and then call dirty() on the ImageStream, this will tell the
Texture::apply() that the image data has changed and it'll then
automatically subload the data for you. ImageStream also by default
provides a PixelBufferObject which means upload performance will be
the best you can get.
On Fri, Sep 26, 2008 at 12:48 AM, Guillaume Langlois
<guillaume at spaceanddream.com> wrote:
> I have set up a DirectShow graph that grabs frames from a web cam. This
> graph executes asynchronously from Open Scene Graph, and the idea is to copy
> the output to the pixels of a TextureRectangle's image (so that each
> rendered frame shows the webcam feed on a 3d plane).
> I would have done this by calling glTexSubImage2D before binding the
> TextureRectangle, but being new to OSG, some of its functionality still
> eludes me, especially everything related to the apply() function, which I
> believe is what I have to do (?).
> In short, how could I update the texture's pixels with whatever the webcam
> graph has ready at each frame?
> Thank in advance,
> Guillaume Langlois
> osg-users mailing list
> osg-users at lists.openscenegraph.org
More information about the osg-users