Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QOpenGLShaderProgram not working when I replace QGLShaderProgram...
Forum Updated to NodeBB v4.3 + New Features

QOpenGLShaderProgram not working when I replace QGLShaderProgram...

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    drhalftone
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      agocs
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • D Offline
        D Offline
        drhalftone
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved