OCCT + QOpenGLWidget (qt5.4.0)

How to embed OCCT in QOpenGLWidget?

QOpenGLWidget is different from QGLWidget because uses a FBO to render the final image.
I tried to embed OCCT in QOpenGLWidget but nothing shows. I think that's because QT and OCCT render in different buffers.

I tried also to derive my own widget from generic QWidget and created my own openGL context and binded a FBO.something shows but not with best results.

My question are:
- how to embed OCCT in QOpenGLWidget?
- How to make OCCT render in a OpenGL context made by Qt?(since OpenGL_graphicDriver initialize a context, is it possible to create viewer and view from another context?)

I apologise for my bad english

Ivan's picture

I saw the examples but the View class created uses WA_PaintOnScreen and this attribute don't let to have semi-transparent widgets overlapping the view.

sancelot's picture

In a same way, I would like being able to embed it in my OpenGL context, please can you point the samples you found ?

jelle's picture

Here is an example overpainting the OCC viewport in pythonocc. Perhaps this helps?


Ivan's picture

Hello Sancelot,

you can check this: http://qtocc.sourceforge.net/index.html

But as I said, using WA_PaintOnScreen doesn't let you to use semitransparent widgets on it....

Ivan's picture

if I try to bind a FBO and drawing offscreen in this way

Handle(OpenGl_FrameBuffer) fbo = new OpenGl_FrameBuffer();
fbo->Release(&(driver_->GetSharedContext().operator *()));

i get the following error:

TKOpenGl | Type: Performance | ID: 0 | Severity: Low | Message:
VBO creation for Primitive Array has failed for 169 vertices. Out of memory?

Do I have to allocate some buffer? How should I use FBO to render offscreen?

dt.cb3559_135993's picture

@Ivan : were you able to solve this error? I am getting the same messages

TKOpenGl | Type: Performance | ID: 0 | Severity: Low | Message:

  VBO creation for Primitive Array has failed for 72 vertices. Out of memory?

Kirill Gavrilov's picture

The problem is most likely due to inconsistent OpenGL state set by Qt and OCCT frameworks leading to unexpected and unhandled in proper place OpenGL errors.
E.g. VBO creation is NOT the actual place where error occurred, but rather the place where the error has been revealed - this is due to asynchronous nature of error reporting system in OpenGL.

Any OpenGL expert should be able solving your issue.
If you don't have such expert at hand - you may consider using Open CASCADE services for preparing a Qt widgets + OCCT sample basing on your needs.