On Sat, Aug 12, 2017 at 8:40 AM, Sean Harmer <[email protected]> wrote:
> Hi, > > On Friday 11 August 2017 14:34:34 Andy wrote: > > 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? > > You don't :) An offscreen surface is only good for making a GL context > current. It is not suitable as a render target. If you want to do offscreen > I guess I find that class name confusing then... One draws on a surface, right? :-) rendering with QOffscreenSurface, you will need to provide your own render > target in the form of a framebuffer object. > > You will need to create an FBO by way of a QRenderTarget with a 2D texture > of > the desired size attached to the color0 attachment point, and a depth > format > texture of the same size attached to the depth attachment point. > So that's a QTexture2D for colo0 and... what for the "depth format texture"? Another QTexture2D? > > Select this with a QRenderTargetSelector in a custom framegraph to direct > rendering into the attached textures. You can then do a pixel read back > operation with the QRenderCapure and save the resulting image. > You make it sound so easy! > I suppose this could be wrapped in a convenience that allows the rest of > the > framegraph beyond the render target selector and render capture to be set. > +1. If I ever get anything working, I'd be happy to work with someone to get it into shape for Qt3DExtras. Thanks Sean! > Cheers, > > Sean > > > > > 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> > > -- > Dr Sean Harmer | [email protected] | Managing Director UK > Klarälvdalens Datakonsult AB, a KDAB Group company > Tel. UK +44 (0)1625 809908, Sweden (HQ) +46-563-540090 > KDAB - Qt Experts - Platform-independent software solutions > --- Andy Maloney // https://asmaloney.com twitter ~ @asmaloney <https://twitter.com/asmaloney>
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
