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 Updated to NodeBB v4.3 + New Features

QOpenGL RCC Errors

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 475 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 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
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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
      0
      • Christian EhrlicherC Christian Ehrlicher

        @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 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
        
        Christian EhrlicherC 1 Reply Last reply
        0
        • J jacubus

          @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
          
          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 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
          0
          • Christian EhrlicherC Christian Ehrlicher

            @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 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();
            
            Christian EhrlicherC 1 Reply Last reply
            0
            • J jacubus

              @Christian-Ehrlicher

                  // Compile vertex shader
                  if (!program.addShaderFromSourceFile(QOpenGLShader::Vertex, ":/vshader.glsl"))
                      close();
              
                  // Compile fragment shader
                  if (!program.addShaderFromSourceFile(QOpenGLShader::Fragment, ":/fshader.glsl"))
                      close();
              
              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 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

              • Login

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