Hi Chris,

for read pixels there are  examples

http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/examples/osgscreencapture/osgscreencapture.cpp

https://code.google.com/p/osgworks/source/browse/trunk/src/osgwTools/ScreenCapture.cpp

Regards
Sergey




On Thu, Aug 21, 2014 at 12:27 PM, Chris Hidden <[email protected]> wrote:

> Yes! Ok, I read that forum and it gave me a better idea of how I might do
> this.   To account for transparency though I need to get the current
> pbuffer and put it into a local byte array.
>
> Something like
>
>
> Code:
>
> static BYTE pixels[width * height * 4] = {0};
>
> unsigned char* ptr = g_image->data();
>
> for (unsigned int i = 0; i < size; i += 2)
>         {
>                 pixels[i] = (ptr[i / 2] >> 4);
>                 pixels[i + 1] = (ptr[i / 2] & 0x0F);
>         }
>
>
>
>
> Now this doens't really work of course, I just get an empy BYTE array.
>
> Normally this could be done with :
>
>
> Code:
>
> glPixelStorei(GL_PACK_ALIGNMENT, 1);
>         glReadPixels(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, GL_BGRA_EXT,
> GL_UNSIGNED_BYTE, pixels);
>
>
>
>
>
> I know that OSG has a readPixels method.  But I don't really understand
> how to read the pixels into a byte array.  The optional packing parameter
> is an int in the osg::image::readpixels.  I just lack understanding of how
> to make this conversion.
>
> How would I got about doing this?  Is there maybe a better way in this
> case than readpixels?
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=60728#60728
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to