On 17 Sep 2013, at 19:47, Rick Armstrong <[email protected]>
wrote:
> Indeed, PNG would be ideal!
> > - if you have any interested in
> > doing this, I can point you at examples since the screenshot code was
> > converted to do the same thing recently -it's probably a couple of hours
> > hacking at most)
>
> I'd be happy to take a crack at it. This would be my first foray into the
> FlightGear source tree, so a pointer to some sample code would be great.
>
Okay, various pieces:
gui_funcs.cxx has the screenshot dumping code, especially the logic to
run things safely via an OSG GraphicsContextOperation. Its run() virtual
contains a call to: sg_glDumpWindow
which is defined in SimGear and does the actual reading of the frame-buffer and
writing via:
// dump the screen buffer to a png file, returns true on success
bool sg_glDumpWindow(const char *filename, int win_width, int
win_height)
{
osg::ref_ptr<osg::Image> img(new osg::Image);
img->readPixels(0,0, win_width, win_height, GL_RGB,
GL_UNSIGNED_BYTE);
return osgDB::writeImageFile(*img, filename);
}
The trick will be to interface this with the jpg-httpd infrastructure. There's
a problem I can see here - the osgDB API is very file orientated, but I assume
you need the image data in memory to send down the HTTP socket. We might need
to ask on the OSG mailing list if this can be done, otherwise you'd have to
read the file back after writing it. This is little ugly but the file should be
in the cache so probably no actual disk access happens.
Most of jpgfactory.cxx is irrelevant, I'd ignore it completely since it only
deals with the tile-rendering (not needed these days since we can render big GL
viewports natively) and the mechanics of running the image compressor. If you
can plug the stuff you need into line 227 of jpg-httpd, I think you're good.
That's a very rough sketch based on ten minutes reading of course.
Note if you want actual good performance from this system, there's much smarter
things that could be done, such as grabbing the frame buffer each normal
rendering frame, instead of re-rendering the scene each time an HTTP get is
received. That would need much more drastic changes to the system however.
As ever, any further questions, just ask.
Regards,
James
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel