Example on how to setup offscreen rendering for OCCT + Qt5 QML

Hi everyone,

I'm looking for a minimal example on how to use OCCT (7.4) for offscreen rendering onto Qt5 QML.

I plan to be able to render through the Qt/QML QOpenGLFramebufferObject, which seems to be the way to go to implement such feature.

The idea beeing to be able to put as many of these items inside one QML window.

So far, I've checked the QtAndroid sample and various posts from M.Gavrilov on the forum about methods that seems

to be related to such implementation ( OpenGl_FrameBuffer::InitWrapper(), OpenGl_Context::SetDefaultFrameBuffer() .. ).

But I couldn't figure out a way to make a minimal example working.

Here is how I try to setup the context and the view for OCCT :

m_oGlContext = new OpenGl_Context();
m_oGlFrameBuffer = new OpenGl_FrameBuffer();
Handle(OcctDummyWindow) aWindow = new OcctDummyWindow(100, 100);
m_oGlDriver = new OpenGl_GraphicDriver(nullptr, false);
m_oGlDriver->ChangeOptions().buffersNoSwap = Standard_False;
m_theV3dViewer = new V3d_Viewer(m_oGlDriver);
m_theCtx = new AIS_InteractiveContext(m_theV3dViewer);
m_theV3dView = m_theV3dViewer->CreateView();
// Handle(WNT_Window) aWindow = new WNT_Window((HWND) occView->window()->winId());
m_theV3dView->SetWindow(aWindow, (Aspect_RenderingContext) wglGetCurrentContext());
// m_theV3dView->View()->SetFBO(m_oGlFrameBuffer);
m_theV3dView->SetBackgroundColor(Quantity_TOC_RGB, 1.0, 1.0, 0.0);

But I still can't figure out how to setup a dummy window for offscreen rendering.

The code ( using the implementation of a WNT_Window found in the QtAndroid sample ) above results in an OpenGL error telling me that the pixel format is not valid.

Can someone share some example or insights on this matter ?

That would be great.



Hugues Delorme's picture

I tried some months ago to do the same thing but failed as well.
Maybe not related but did you try with using Aspect_NeutralWindow ?