occt-samples-qopenglwidget icon indicating copy to clipboard operation
occt-samples-qopenglwidget copied to clipboard

Crash: Two separate views, shared context

Open rainman110 opened this issue 1 year ago • 8 comments

I successfully used your example two create two separate views. it works out of the box.

Next, I tried to extract the V3d_Viewer and AIS_InteractiveContext out of the widget to create a shared state between both views (i.e. have the same context with different views).

In this case, the application crashes at the end of the second call to initializeGL, concretely at the line myView->SetWindow.

This worked well with the "normal" occt qt examples, but does not work anymore with your QOpenGlWidget-based example.

Do you have any suggestions, how I could use multiple views of the same context?

rainman110 avatar Apr 17 '23 19:04 rainman110

If you would share a sample project it would be simpler to understand what you are trying to do / reproduce the problem

gkv311 avatar Apr 18 '23 06:04 gkv311

Sure, I'll provide the very quick and dirty example - based on yours - in a fork.

rainman110 avatar Apr 18 '23 07:04 rainman110

@gkv311 Here's the example on my fork in the branch "dual_view" https://github.com/rainman110/occt-samples-qopenglwidget/tree/dual_view

I extracted the viewer and the context into a separate objects "scene", which should hold the shared state.

rainman110 avatar Apr 18 '23 14:04 rainman110

@gkv311 Did you have any chance to look at the example. I am a bit puzzled, what could be happening.

Conceptually, what is required to have to separate viewers from the same scene?

  • One common viewer and context ?
  • Two separate views

rainman110 avatar Apr 28 '23 13:04 rainman110

@gkv311 Did you have any chance to look at the example. I am a bit puzzled, what could be happening.

Sorry, need to find some time to setup Linux + OCCT + sample environment. It might be tricky from OCCT side wrapping two existing OpenGL views sharing common context, though conceptually it should work.

Meanwhile I've pushed another option for splitting views using Subview API introduced by OCCT 7.7. Tested on Windows platform for now.

image

gkv311 avatar Apr 30 '23 19:04 gkv311

Awesome! I'll gonna try this latest tomorrow.

Strangely, I always successfully used a multi view application based on the old qt example, that is part of the occt examples.

Thank you for looking into it!

rainman110 avatar May 01 '23 07:05 rainman110

Strangely, I always successfully used a multi view application based on the old qt example, that is part of the occt examples.

You've missed the point about wrapping alien OpenGL context created by Qt (QOpenGlWidget). Old OCCT Qt samples do all OpenGL management on their own, taking from Qt only created native window handles.

gkv311 avatar May 01 '23 07:05 gkv311

Oh yes. You're right. With the new approach, there are two separate OpenGL contexts created by each of the qopenglwidgets. I am looking forward to look into your changed code.

rainman110 avatar May 01 '23 08:05 rainman110