[osg-users] Building a Texture2D from a PBO?

Sergey Polischuk pol-ss at yandex.ru
Fri Apr 22 06:27:30 PDT 2011


Hi, Trystan
You should do this in thread with active gl context, f.e. during cull traversal or rendering traversals.

Cheers,
Sergey.

22.04.2011, 05:54, "Trystan Larey-Williams" <trystan at trystan.org>:
> Hi all,
>
> I'm looking for a way to quickly read parts of images into parts of 2D textures. For instance, given a source rect for an image and a destination rect for the texture I want to get just the source rect into the dest rect with no scaling/resizing etc.
>
> I thought I may be able to do something like the snippet below. However, this code crashes on copyTexSubImage. Am I on the right track at all here?
>
> img = osgDB::readImageFile("image.png");
> pbo = new osg::PixelBufferObject(img.get());
> texture = new osg::Texture2D;
> texture->setTextureSize(img->s(), img->t());
> state = new osg::State;
> state->setContextID(viewer.getCamera()->getGraphicsContext()- >getState()->getContextID());
> state->bindPixelBufferObject(pbo.get());
> texture->copyTexSubImage2D(*state, 0, 0, 0, 0, img->s(), img->t());
>
> Thanks in advance,
> Trystan
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=38722#38722
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



More information about the osg-users mailing list