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. QOpenGL RCC Errors
Forum Update on Monday, May 27th 2025

QOpenGL RCC Errors

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 467 Views
  • 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.
  • J Offline
    J Offline
    jacubus
    wrote on 27 Dec 2022, 13:50 last edited by jacubus
    #1

    Hello, i'm trying to link shaders and .png texture file but i'm getting RCC errors.
    For shaders

    RCC Parse Error: 'C:/Users/Jacob/source/repos/SMGG_2_0/resources/fshader.glsl' Line: 1 Column: 1 [Start tag expected.]
    

    For .png

    RCC Parse Error: 'C:/Users/Jacob/source/repos/SMGG_2_0/resources/cube.png' Line: 1 Column: 1 [Encountered incorrectly encoded content.]
    

    CMake

    # Resources:
    set(shaders_resource_files
        "resources/fshader.glsl"
        "resources/vshader.glsl"
    )
    
    qt6_add_resources(SMGG_2_0 "shaders"
        PREFIX
            "Shaders"
        FILES
            ${shaders_resource_files}
    )
    set(textures_resource_files
        "resources/cube.png"
    )
    
    qt6_add_resources(SMGG_2_0 "textures"
        PREFIX
            "Textures"
        FILES
            ${textures_resource_files}
    )
    set(PROJECT_SOURCES
            ${shaders_resource_files}
            ${textures_resource_files}
    )
    

    Shader files

    #ifdef GL_ES
    // Set default precision to medium
    precision mediump int;
    precision mediump float;
    #endif
    
    uniform sampler2D texture;
    
    varying vec2 v_texcoord;
    
    //! [0]
    void main()
    {
        // Set fragment color from texture
        gl_FragColor = texture2D(texture, v_texcoord);
    }
    //! [0]
    
    
    #ifdef GL_ES
    // Set default precision to medium
    precision mediump int;
    precision mediump float;
    #endif
    
    uniform mat4 mvp_matrix;
    
    attribute vec4 a_position;
    attribute vec2 a_texcoord;
    
    varying vec2 v_texcoord;
    
    //! [0]
    void main()
    {
        // Calculate vertex position in screen space
        gl_Position = mvp_matrix * a_position;
    
        // Pass texture coordinate to fragment shader
        // Value will be automatically interpolated to fragments inside polygon faces
        v_texcoord = a_texcoord;
    }
    //! [0]
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 27 Dec 2022, 17:46 last edited by
      #2

      @jacubus said in QOpenGL RCC Errors:

      qt6_add_resources

      When you use the target variant you have to create the target (in your case SMGG_2_0 ) before the qt6_add_resources() call.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J 1 Reply Last reply 27 Dec 2022, 22:08
      0
      • C Christian Ehrlicher
        27 Dec 2022, 17:46

        @jacubus said in QOpenGL RCC Errors:

        qt6_add_resources

        When you use the target variant you have to create the target (in your case SMGG_2_0 ) before the qt6_add_resources() call.

        J Offline
        J Offline
        jacubus
        wrote on 27 Dec 2022, 22:08 last edited by
        #3

        @Christian-Ehrlicher
        When i moved it to be after .exe i'm getting that it can't be opened.

        QOpenGLShader: Unable to open file "vshader.glsl"
        QOpenGLShader: Unable to open file "fshader.glsl"
        QOpenGLShaderProgram::uniformLocation(mvp_matrix): shader program is not linked
        QOpenGLShaderProgram::uniformLocation(texture): shader program is not linked
        

        Project tree looks like:

                    | widget.h
                    | widget.cpp
        mainfolder -| resources -|
                                 | fshader.glsl
                                 | vshader.glsl
                                 | cube.png
        
        C 1 Reply Last reply 28 Dec 2022, 09:24
        0
        • J jacubus
          27 Dec 2022, 22:08

          @Christian-Ehrlicher
          When i moved it to be after .exe i'm getting that it can't be opened.

          QOpenGLShader: Unable to open file "vshader.glsl"
          QOpenGLShader: Unable to open file "fshader.glsl"
          QOpenGLShaderProgram::uniformLocation(mvp_matrix): shader program is not linked
          QOpenGLShaderProgram::uniformLocation(texture): shader program is not linked
          

          Project tree looks like:

                      | widget.h
                      | widget.cpp
          mainfolder -| resources -|
                                   | fshader.glsl
                                   | vshader.glsl
                                   | cube.png
          
          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 28 Dec 2022, 09:24 last edited by
          #4

          @jacubus said in QOpenGL RCC Errors:

          I'm getting that it can't be opened.

          but it compiles so it was correct.

          Now you should show us how you're loading them in your code.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          J 1 Reply Last reply 28 Dec 2022, 14:48
          0
          • C Christian Ehrlicher
            28 Dec 2022, 09:24

            @jacubus said in QOpenGL RCC Errors:

            I'm getting that it can't be opened.

            but it compiles so it was correct.

            Now you should show us how you're loading them in your code.

            J Offline
            J Offline
            jacubus
            wrote on 28 Dec 2022, 14:48 last edited by
            #5

            @Christian-Ehrlicher

                // Compile vertex shader
                if (!program.addShaderFromSourceFile(QOpenGLShader::Vertex, ":/vshader.glsl"))
                    close();
            
                // Compile fragment shader
                if (!program.addShaderFromSourceFile(QOpenGLShader::Fragment, ":/fshader.glsl"))
                    close();
            
            C 1 Reply Last reply 28 Dec 2022, 14:50
            0
            • J jacubus
              28 Dec 2022, 14:48

              @Christian-Ehrlicher

                  // Compile vertex shader
                  if (!program.addShaderFromSourceFile(QOpenGLShader::Vertex, ":/vshader.glsl"))
                      close();
              
                  // Compile fragment shader
                  if (!program.addShaderFromSourceFile(QOpenGLShader::Fragment, ":/fshader.glsl"))
                      close();
              
              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 28 Dec 2022, 14:50 last edited by
              #6

              @jacubus said in QOpenGL RCC Errors:

              ":/vshader.glsl"

              qt6_add_resources(SMGG_2_0 "shaders"
              PREFIX
              "Shaders"
              FILES
              ${shaders_resource_files}
              )

              I mean - how do you expect that the filename is :/vshader.glsl when you add "Shaders" as prefix. Reading the documentation to find out what the arguments are doing seems to be really hard these days...

              PREFIX specifies a path prefix under which all files of this resource are accessible from C++ code. This corresponds to the XML attribute prefix of the .qrc file format. If PREFIX is not given, the target property QT_RESOURCE_PREFIX is used.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0

              1/6

              27 Dec 2022, 13:50

              • Login

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