Ray-tracing requires OpenGL 3.1 and higher

I use OCCTOverview, when I clicked Ray-tracing button, I get this error:

TKOpenGl | Type: Error | ID: 0 | Severity: High | Message:

  Ray-tracing requires OpenGL 3.1 and higher

 my platform is MacOS wtih occt 7.5, Does anyone know how to set OpenGL version? or use QSurfaceFormat as version seter?

Thanks in advance.

Kirill Gavrilov's picture
MyWidget::MyWidget()
{
  connect (this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(onWindowChanged(QQuickWindow*)));
}
...
void MyWidget::onWindowChanged (QQuickWindow* theWin)
{
  QSurfaceFormat aGlFormat;
  aGlFormat.setOption  (QSurfaceFormat::DeprecatedFunctions, true);
  aGlFormat.setVersion (4, 5);
  aGlFormat.setProfile (QSurfaceFormat::CoreProfile);
  theWin->setFormat (aGlFormat);
}
mat geo's picture

thanks for your quick reply, 

OCCTOverview is write in c++,   I can't  add that qml code  to c++,

or have c++ version solution?

Thanks in advance.

Kirill Gavrilov's picture

This is a C++ code (could be applied to QtQuick sample samples/qt/AndroidQt, for example), but samples/qt/OCCTOverview doesn't use Qt for creation of OpenGL context - it relies on OCCT itself. In this case context parameters are defined by OpenGl_Caps structure.

Handle(V3d_Viewer) DocumentCommon::Viewer(
{
...
  aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
  aGraphicDriver->ChangeOptions().contextCompatible = false;
mat geo's picture

after add "aGraphicDriver->ChangeOptions().contextCompatible = false;" 

get error

Error: 2D texture 16384x256 IF: 33321 PF: 6403 DT: 5121 can not be created with error 1282.

Kirill Gavrilov's picture

Which graphics card do you use, on which platfrom / device?

You can use the following code snippet (from webgl sample) to dump OpenGL information to console:

static void dumpGlInfo (const Handle(V3d_View)& theView, bool theIsBasic)
{
  TColStd_IndexedDataMapOfStringString aGlCapsDict;
  theView->DiagnosticInformation (aGlCapsDict, theIsBasic ? Graphic3d_DiagnosticInfo_Basic : Graphic3d_DiagnosticInfo_Complete);
  if (theIsBasic)
  {
    TCollection_AsciiString aViewport;
    aGlCapsDict.FindFromKey ("Viewport", aViewport);
    aGlCapsDict.Clear();
    aGlCapsDict.Add ("Viewport", aViewport);
  }

  // beautify output
  {
    TCollection_AsciiString* aGlVer   = aGlCapsDict.ChangeSeek ("GLversion");
    TCollection_AsciiString* aGlslVer = aGlCapsDict.ChangeSeek ("GLSLversion");
    if (aGlVer   != NULL
     && aGlslVer != NULL)
    {
      *aGlVer = *aGlVer + " [GLSL: " + *aGlslVer + "]";
      aGlslVer->Clear();
    }
  }

  TCollection_AsciiString anInfo;
  for (TColStd_IndexedDataMapOfStringString::Iterator aValueIter (aGlCapsDict); aValueIter.More(); aValueIter.Next())
  {
    if (!aValueIter.Value().IsEmpty())
    {
      if (!anInfo.IsEmpty())
      {
        anInfo += "\n";
      }
      anInfo += aValueIter.Key() + ": " + aValueIter.Value();
    }
  }

  ::Message::SendInfo (anInfo);
}
mat geo's picture

graphics card are RX 5700 and  intel 530, two computer in MacOS 10.15.7, Qt 5.15.2

detail see in attachments

Kirill Gavrilov's picture

Could you check if CAD Assistant 1.5.0 works on your computers?
(you can enable verbose output in Settings and see logs in Message Window)
 

mat geo's picture

CAD Assistant can work well, and when set enable verbose output , where can get this log message?

btw, when start ./CADAssistant from terminal, I get some warning, 

Kirill Gavrilov's picture

These are warnings from Qt actually not indicating any issues.
Message Window can be shown using "3D" button on left panel -> then Message button on right panel.

CAD Assistant creates Core Profile by default (although via Qt) and Ray Tracing can be enabled in Settings.

mat geo's picture

CAD Assistant work well, right shadow window is that Message?

Kirill Gavrilov's picture

Yes, this is Message Window.

This is strange that you see errors in Qt Widgets sample (although nobody tested this sample on macOS before).
Maybe it is important also disabling OpenGl_Caps::ffpEnable flag while requesting Core Profile as it is done by Draw Harness command "vcaps -core":

aCaps->contextCompatible = false;
aCaps->ffpEnable = false;
mat geo's picture

  write like the last line, also get error:

TKOpenGl | Type: Error | ID: 0 | Severity: High | Message:
  Error: 2D texture 1262x966 IF: 35907 PF: 6408 DT: 5121 can not be created with error 1282.
    Handle(Aspect_DisplayConnection) aDisplayConnection;
    aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
    aGraphicDriver->ChangeOptions().contextCompatible=false;
    aGraphicDriver->ChangeOptions().ffpEnable=false;

attachments is run  bin ./DRAWEXE-7.6.0  System Info

mschollmeier01_166410's picture

I was having the same issue as well, on MacOS Big Sur on a 2017 iMac, using occt 7.5.0 and Qt 6.0. I can report that Kirill's suggestion to add 

aGraphicDriver->ChangeOptions().contextCompatible=false;

does solve the issue and I can successfully enable ray-tracing, shadows, reflections, etc. Thanks a lot!!