[Interest] Qt3D Rendering offscreen

Andy asmaloney at gmail.com
Fri Aug 11 20:34:34 CEST 2017


Goal: With Qt3D (C++), render my scene offscreen, use render capture on it,
and save image to disk.

With my Qt3DWindow-based solution the scene looks fine and I can do the
render capture part (on macOS anyways - Windows doesn't work for me -
https://bugreports.qt.io/browse/QTBUG-61223 ).

Now I need to be able to do it offscreen (without the window open).

I thought this was going to be as simple as setting a QOffscreenSurface as
my forward renderer surface - something like:

   QOffscreenSurface *surface = new QOffscreenSurface;

   surface->create();

   Qt3DExtras::QForwardRenderer  *forwardRenderer = new
Qt3DExtras::QForwardRenderer;

   forwardRenderer->setSurface( surface );
   forwardRenderer->setExternalRenderTargetSize( QSize( 800, 600 ) );

   qDebug() << surface->format() << surface->size() << surface->isValid();

While this gives me a valid surface and the format is correct, its size is
always (1,1) and the render capture gives me images of that size.

How do I set the size of the QOffscreenSurface?

Or am I going about this the wrong way?

(It would be nice to have a class like the Qt3DWindow one specifically for
offscreen rendering.)

---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170811/db804625/attachment.html>


More information about the Interest mailing list