Viewer raw pixel data

151 views
Skip to first unread message

Luigi Castelli

unread,
Nov 9, 2020, 10:44:03 AM11/9/20
to OpenSceneGraph Users
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

OpenSceneGraph Users

unread,
Nov 9, 2020, 11:30:29 AM11/9/20
to OpenSceneGraph Users
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.

--
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+...@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.
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Chris Hanson

unread,
Nov 9, 2020, 6:30:44 PM11/9/20
to OpenSceneGraph Users
Sure. What you're looking for is called Render To Texture, and there are a variety of OSG Render To Texture examples around that do a variety of things with that rendered texture, like save it to disk, etc.

--
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+...@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.


--
Chris 'Xenon' Hanson, omo sanza lettere. Xe...@AlphaPixel.com http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging  UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]
Reply all
Reply to author
Forward
0 new messages