Can't set Line width using V3d_View with QOpenGLWidget

Hello,
I have migrate my Qt/OCC integration from V3d_View/QWidget to V3d_View/QOpenGLWidget like done in the OcctQtViewer sample application https://github.com/gkv311/occt-samples-qopenglwidget but now the linewidth of wireframe shape is not working anymore (see difference in attached image, left is V3d_View/QOpenGLWidget and right is V3d_View/QWidget from my application before I migrate).
I am using OCC 7.6.0 for my application. I tested the following snippet:
{
// dummy shape for testing
TopoDS_Shape aBox = BRepPrimAPI_MakeBox (100.0, 50.0, 90.0).Shape();
Handle(AIS_Shape) aShape = new AIS_Shape (aBox);
aShape->Attributes()->SetupOwnFaceBoundaryAspect();
aShape->Attributes()->UnFreeBoundaryAspect()->SetWidth(5);
aShape->Attributes()->SetUnFreeBoundaryAspect(aShape->Attributes()->UnFreeBoundaryAspect());
myContext->Display (aShape, AIS_WireFrame, 0, false);
}

So line width is not working, but I tested point size (using a vertex instead of the box shape) and the point size is working.

Does anyone have any clues on why it is not working and how to fix this, is it a bug?
Best regards,
François.

Kirill Gavrilov's picture

What "About sample" shows you about OpenGL / prints into console?

Francois Lauzon's picture

I have attached a screenshot of the "About sample".
Here is a similar output from the application with V3d_View/QWidget integration:
2021-12-10 13:36:31.776 prt critical thread=42292: OpenGL informations...
2021-12-10 13:36:31.827 prt critical thread=42292: GLvendor: ATI Technologies Inc.
2021-12-10 13:36:31.828 prt critical thread=42292: GLdevice: Radeon RX Vega
2021-12-10 13:36:31.830 prt critical thread=42292: GLversion: 4.6.14761 Compatibility Profile Context 21.11.1 30.0.13033.1000
2021-12-10 13:36:31.831 prt critical thread=42292: GLSLversion: 4.60
2021-12-10 13:36:31.832 prt critical thread=42292: Max texture size: 16384
2021-12-10 13:36:31.834 prt critical thread=42292: Max FBO dump size: 16384x16384
2021-12-10 13:36:31.835 prt critical thread=42292: Max combined texture units: 160
2021-12-10 13:36:31.836 prt critical thread=42292: Max MSAA samples: 8
2021-12-10 13:36:31.837 prt critical thread=42292: Viewport: 779x513
2021-12-10 13:36:31.839 prt critical thread=42292: GPU memory: 8176 MiB
2021-12-10 13:36:31.840 prt critical thread=42292: ResolutionRatio: 1

Attachments: 
Kirill Gavrilov's picture

Qt has quite weird interface to select Core / Compatible profiles in OpenGL. Just comment the line "QSurfaceFormat::setVersion()" to get Compatible Profile which supports line width.

  //aGlFormat.setVersion (4, 5);
  aGlFormat.setProfile (myIsCoreProfile ? QSurfaceFormat::CoreProfile : QSurfaceFormat::CompatibilityProfile);
Francois Lauzon's picture

Thank you Kirill, now it is working properly!

François.

Liu Yang's picture

Is it possible to set line width in Core profile? In the following code, the line width is not working in core profile, but it works in compatible profile.

void AISElem::Compute(const Handle(PrsMgr_PresentationManager) & prsMgr, const Handle(Prs3d_Presentation) & prs, const Standard_Integer mode)
{
    prs->Clear();

    Handle(Graphic3d_Group) edgeGroup = prs->NewGroup();

    int lineWidth = 10;
    Handle(Graphic3d_AspectLine3d) lineAspect =
        new Graphic3d_AspectLine3d(Quantity_NOC_BLUE, Aspect_TOL_SOLID, lineWidth);
    edgeGroup->SetGroupPrimitivesAspect(lineAspect);

    Handle(Graphic3d_ArrayOfSegments) segArray =
        new Graphic3d_ArrayOfSegments(2);

    gp_Pnt pnt1(0, 0, 0);
    gp_Pnt pnt2(100, 100, 100);

    segArray->AddVertex(pnt1);
    segArray->AddVertex(pnt2);

    edgeGroup->AddPrimitiveArray(segArray);
}
gkv311 n's picture

Liu Yang wrote:

Is it possible to set line width in Core profile?

No it's impossible right now. Until OCCT will not implement emulated wide lines. Though you may draw thick mesh edges.