QOpenGLShaderProgram not working when I replace QGLShaderProgram...



  • I'm trying to update my code to replace the QGLxxxx deprecated classes with the new QOpenGLxxxx classes. So I'm running into a problem with a geometry shader that has the following code:

    @#version 110

    uniform float qt_delta; // USER DEFINED MAXIMUM DISTANCE THRESHOLD
    uniform int qt_mode;

    varying in float qt_magnitude[]; // VECTOR HOLDING THE MAGNITUDE VALUE FROM THE VERTEX SHADER
    varying float qt_albedo; // SCALAR HOLDING THE MAGNITUDE VALUE FOR THE FRAGMENT SHADER

    varying in vec3 qt_normal[]; // VECTOR HOLDING THE VERTEX NORMALS
    varying vec3 qt_normalVector; // VECTOR HOLDING THE UNIT LENGTH VERTEX NORMAL

    void main()
    {
    // CALCULATE DISTANCE BETWEEN EACH VERTEX, AND IF THEY ARE ALL
    // INSIDE THE MAXIMUM DISTANCE THRESHOLD, THEN EMIT THE VERTICES
    // TO THE FRAGMENT SHADER FOR DISPLAY. OTHERWISE, CULL THEM.
    vec4 delta = gl_PositionIn[1] - gl_PositionIn[0];
    if (length(delta) < qt_delta){
    delta = gl_PositionIn[2] - gl_PositionIn[0];
    if (length(delta) < qt_delta){
    delta = gl_PositionIn[2] - gl_PositionIn[1];
    if (length(delta) < qt_delta){

                // EMIT THE FIRST VERTEX ALONG WITH ITS ALBEDO (TEXTURE)
                if (qt_mode == 1){
                    qt_normalVector = qt_normal[0];
                }
                qt_albedo = qt_magnitude[0];
                gl_FrontColor = gl_FrontColorIn[0];
                gl_TexCoord[0] = gl_TexCoordIn[0][0];
                gl_Position = gl_PositionIn[0];
                EmitVertex();
    
                // EMIT THE SECOND VERTEX ALONG WITH ITS ALBEDO (TEXTURE)
                if (qt_mode == 1){
                    qt_normalVector = qt_normal[1];
                }
                qt_albedo = qt_magnitude[1];
                gl_FrontColor = gl_FrontColorIn[1];
                gl_TexCoord[0] = gl_TexCoordIn[1][0];
                gl_Position = gl_PositionIn[1];
                EmitVertex();
    
                // EMIT THE THIRD VERTEX ALONG WITH ITS ALBEDO (TEXTURE)
                if (qt_mode == 1){
                    qt_normalVector = qt_normal[2];
                }
                qt_albedo = qt_magnitude[2];
                gl_FrontColor = gl_FrontColorIn[2];
                gl_TexCoord[0] = gl_TexCoordIn[2][0];
                gl_Position = gl_PositionIn[2];
                EmitVertex();
            }
        }
    }
    EndPrimitive();
    

    }
    @

    This used to work just fine, but with the QOpenGLShaderProgram class, I now get the following shader compiling errors when I try to compile the shaders in the application:
    @QOpenGLShader::compile(Geometry): ERROR: 0:9: Invalid qualifiers 'in' in global variable context
    ERROR: 0:12: Invalid qualifiers 'in' in global variable context
    ERROR: 0:20: Use of undeclared identifier 'gl_PositionIn'
    @
    plus a very long list of additional errors. I noticed there was a bug report about QOpenGLShaderProgram not working correctly, but this looks like an error related to the compiling of the GLSL, not the code itself. So any help would be appreciated.



  • First, the minimum version for a geometry shader is 150.
    Second, "varying in" is invalid. Just use "in".



  • So here is the error message I'm getting from the GLSL compiler:

    @"LAUScanData::allocateBuffer() 0" 494 656
    QOpenGLShader::compile(Geometry): ERROR: 0:1: '' : version '150' is not supported

    *** Problematic Geometry shader source code ***
    #version 150
    #define lowp
    #define mediump
    #define highp

    uniform float qt_delta; // USER DEFINED MAXIMUM DISTANCE THRESHOLD
    uniform int qt_mode;
    @

    So I removed the version number altogether and get:

    @Starting /Users/dllau/Developer/build-AppleTest-Desktop_Qt_5_2_1_clang_64-Debug/AppleTest.app/Contents/MacOS/AppleTest...
    "LAUScanData::allocateBuffer() 0" 494 656
    QOpenGLShader::compile(Geometry): ERROR: 0:9: Invalid qualifiers 'in' in global variable context
    ERROR: 0:12: Invalid qualifiers 'in' in global variable context
    ERROR: 0:20: Use of undeclared identifier 'gl_PositionIn'
    ERROR: 0:20: Use of undeclared identifier 'gl_PositionIn'
    @

    Any suggestions?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.