7.5 => 7.8 broke text rendering in Qt application

[EDIT] The line width problem described here was because of OpenGL's core profile beiing set. It was a fix for the text not rendering properly, so now the problem is how to fix the text rendering in Qt (which is linked to the OCCT upgrade, probably because of the openGL dll) ?

Since upgrading to 7.8, all line widths in the 3D view are limited to the smallest possible size. I tried looking at the upgrading documentation but I didn't find anything.

The line width is set as follows :

Handle(AIS_InteractiveObject) interactive_object_from_shape(...)
  auto interactive_object = Handle(AIS_InteractiveObject) {};

  const auto& attributes = interactive_object->Attributes();


  const auto lines_aspect = opencascade::handle{ new Prs3d_LineAspect{ shape_color,
                                                                     line_width } }; // this does not work despite line_width beiing well set



  return interactive_object;

// And somewhere else:
renderer->getContext()->Display(interactive_object_from_shape(...), false);

This worked in the past, still correctly changes the line color, but the line width is stuck and I can't manage to change it in any way.

Any ideas ?

gkv311 n's picture

Which platform you are running on? Which GPU you have? How you configure OpenGl_GraphicDriver? Are there any warning or error messages in the OCCT log?

This could be result of using OpenGL Core Profile.

Rémi Chambionnat's picture

We have the bug on multiple computers with integrated intel GPUs and NVIDIA's 1650Ti alike, on Windows 10 and 11.

OpenGl_GraphicDriver is instantiated like this :

  // Create graphic driver.
  Handle(Aspect_DisplayConnection) displayConnection;
  Handle(OpenGl_GraphicDriver) graphicDriver =
    new OpenGl_GraphicDriver(displayConnection);

  // Set graphic driver options.
  auto& graphicDriverOptions = graphicDriver->ChangeOptions();
  graphicDriverOptions.buffersNoSwap = true;
  graphicDriverOptions.useSystemBuffer = false;

  // Create viewer.
  m_viewer = new V3d_Viewer(graphicDriver);

It does not seem like there is anything particular in the logs, is there a specific OCCT log file somewhere ?

Rémi Chambionnat's picture

Apparently, the problem is linked to using a more recent OpenGL version (4.1 instead of 2.0) as updating OCCT broke the text rendering in our Qt application. The fix was to set the surface renderer to OpenGL 4.1 (using QSurfaceFormat), but this prevents the use of line width in OCCT for some reason.
So now the question is how and why did the OCCT update to 7.8 broke Qt's surface rendering ?

EDIT The problem IS openGL core profile indeed, it is necessary to use it in Qt with openGl 3.2+

However, this does not fix anything as we now have to choose between disappearing text and no line width...

gkv311 n's picture

Apparently, your issue is connected not solely to OCCT 3D Viewer, but to it's integration with some 'Qt application' and 'Qt's surface rendering', without describing any details of such application (which version of Qt is used? how OpenGL setup is done on Qt side? how OCCT Viewer is embedded into Qt renderer? which problems with text do you have?).

In general, there is no good reason to use OpenGL Core Profile on Windows platform, save you have some blocking issues with Compatible Profile (but they could be also solid). There is no straight-forward alternatives to thick lines for Core Profile - possible implementations require some efforts and trade-off, and for the moment OCCT doesn't provide any. Hence, Compatible Profile is the best option, if you really need thick lines.

Interoperability of different OpenGL renderers within single application has an extra complexity and is known to struggle with issues due to OpenGL nature (global state) and bugs/features of both renderers, that could be worked around only after localizing the issue.

Rémi Chambionnat's picture

Thank you for this complete explanation. OpenGL version for surface rendering in Qt is set as such :

QSurfaceFormat format;
format.setVersion(4,1); // for Qt 4.1, defaults to 2.0
format.setProfile(QSurfaceForamt::CoreProfile); // for Qt > 3.2, defaults to QSurfaceFormat::CompatibilityProfile

This was the fix for the text disappearing. But of course, because this enables core profile, this broke the line width management. Before, nothing was specified manually, so QtSurfaceFormat defaulted to OpenGL 2.0 with compatibility. But the OCCT upgrade (and so probably the OpenGL dll upgrade) broke text rendering with these settings.