[osg-users] Viewer raw pixel data

OpenSceneGraph Users osg-users at lists.openscenegraph.org
Mon Nov 9 08:29:11 PST 2020


Hi Luigi,

The OSG can render to a framebuffer that is defined by a Window or a
PixelBuffer.  If you want a RGBA image from either of these you'll need to
use a Camera final draw callback to do a glReadPixel or
osg::Image::readPixels(..) call to copy the framebuffer data that resides
on the GPU back to the CPU so you can use it.  This round trip is
relatively slow though.

The most efficient way to render the vertex graphics together with 3D will
render the vector graphics with OpenGL/OSG so there is no need to copy any
data, you just render it all together.

Robert.

On Mon, 9 Nov 2020 at 16:00, OpenSceneGraph Users <
osg-users at lists.openscenegraph.org> wrote:

> We are in need of wrapping the OSG library inside a vector graphic
> environment.
> The vector graphic environment doesn't offer any OpenGL functionality in
> and of itself, however there is a function in its SDK to create and display
> a bitmap image given an array of bytes.
>
> /** Create an image surface from given pixel data.
> Data should point to start of top line of bitmap, stride tells how to get
> to next line.
> For upside down windows bitmaps, data = (pBits-(height-1)*stride) and
> stride is a negative number.
> @ingroup jsurface
> @param data The data.  For example, an RGBA image loaded in memory.
> @param format The format of the data.
> @param width The width of the new surface.
> @param height The height of the new surface.
> @param stride The number of bytes between the start of rows in the data
> buffer.
> @param freefun If not NULL, freefun will be called when the surface is
> destroyed
> @param freearg This will be passed to freefun if/when freefun is called.
> @return A pointer to the new surface.
> */
> t_jsurface* jgraphics_image_surface_create_for_data(unsigned char *data,
> t_jgraphics_format format, int width, int height, int stride, method
> freefun, void *freearg);
>
> The question is whether it is possible to extract the graphical output of
> the OSG Viewer as raw RGBA bytes. Then we could use the above function to
> basically create a pixel dump of the OSG viewer output and have the 2D
> vector graphic environment display it.
>
> Thanks for any help
> Regards
>
> - Luigi
>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSceneGraph Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osg-users+unsubscribe at googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/osg-users/1d655ece-f41b-4599-b9a8-30903c42f390n%40googlegroups.com
> <https://groups.google.com/d/msgid/osg-users/1d655ece-f41b-4599-b9a8-30903c42f390n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20201109/9c4fd792/attachment.html>


More information about the osg-users mailing list