Important: Please read the Qt Code of Conduct -

OpenGL|Clip planes|Geometry shader

  • Hi everyone.
    What am I using: Qt 5.11.1, MinGW 5.3, Windows 10, C++11, last version of OpenGL and GlSL
    My task: I have non-solid (just surface) object, rendering by glDrawArrays, and i need to get cross-section of this object by plane. I have found ancient openGL function glClipPlane, but its not compability with VAOs and VBOs. Also Ive found out that its possible to rewrite glClipPlane via geometry shader.
    My questions/problems:

    1. Do you know other ways to realize this task?
    2. I really dont understand, how to add geometry shader in QtCreator, there is no "icon" of geometry shader, I tried to add vertex shader and rename it to .gsh or just .glsl, tried to use QOpenGLShaderProgram::addShaderFromSourceCode(QOpenGLShader::Geometry, QString &source) and write shader code in program, but every time I get "QOpenGLShader: could not create shader" on string with adding geometry shader.0_1531924420076_pic.png
      Geometry shader simpliest code:
    layout (triangles) in;
    layout (triangle_strip, max_vertices = 3) out;
    void main()
        int i;
        for (i = 0; i < gl_in.length(); i++)
            gl_Position = gl_in[i].gl_Position;

    Im newbier in Qt, so I really need your help. Thanks.

    There is few ways to solve this task. You don`t need geometry shader. Just read this post on stackoverflow

Log in to reply