Qt3D: How to render a mesh in wireframe mode using Qt C++?

The OP is interested on write a shader program, so its necessary to write OpenGL in Qt, right? Like in https://doc.qt.io/qt-5/qtgui-openglwindow-example.html and https://doc.qt.io/qt-5/qtopengl-hellogl2-example.htm.

There is a simple shader example on https://doc.qt.io/qt-5/qopenglshaderprogram.html

program.addShaderFromSourceCode(QOpenGLShader::Vertex,
    "attribute highp vec4 vertex;\n"
    "uniform highp mat4 matrix;\n"
    "void main(void)\n"
    "{\n"
    "   gl_Position = matrix * vertex;\n"
    "}");
program.addShaderFromSourceCode(QOpenGLShader::Fragment,
    "uniform mediump vec4 color;\n"
    "void main(void)\n"
    "{\n"
    "   gl_FragColor = color;\n"
    "}");

From https://learnopengl.com/Getting-started/Hello-Triangle

To draw your triangles in wireframe mode, you can configure how OpenGL
draws its primitives via glPolygonMode(GL_FRONT_AND_BACK, GL_LINE).
The first argument says we want to apply it to the front and back of
all triangles and the second line tells us to draw them as lines. Any
subsequent drawing calls will render the triangles in wireframe mode
until we set it back to its default using
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL).

And from https://learnopengl.com/Advanced-OpenGL/Advanced-GLSL

The gl_FrontFacing variable tells us if the current fragment is part
of a front-facing or a back-facing face. We could, for example, decide
to output different colors for all back faces.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)