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. [Solved] Error opening a shader file
Forum Updated to NodeBB v4.3 + New Features

[Solved] Error opening a shader file

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 11.4k 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.
  • J Offline
    J Offline
    john_god
    wrote on last edited by
    #1

    I'm havin g the same problem has in this "thread":http://developer.qt.nokia.com/forums/viewthread/10751/ (since it 's solved I started a new one). Copying the shader files to the working directory works for me, but the resource solution fails. I add the shader files has resources (to a file.qrc) and then used

    @QGLShader *vertex_shader = new QGLShader(QGLShader::Vertex, this);
    if (!vertex_shader->compileSourceFile(":/vshader.vert"))
    {
    qDebug()<<"Error vertex";
    }

    QGLShader: Unable to open file ":/vshader.vert"
    Error vertex @
    Also if use shader files has resources will they not be embbed in the final executable file ? So how it would be possible then for compileSourceFile() to open them ?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Did you add the resource file to your .pro file?
      How does your resource file look like? Have you specified any prefixes?
      Can you open ":/vshader.vert" using QFile?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        john_god
        wrote on last edited by
        #3

        pro file:
        @RESOURCES +=
        DesktopOpenGLTeste.qrc@

        resource file:
        @<RCC>
        <qresource prefix="/new/prefix1">
        <file>graphGL/fshader.frag</file>
        <file>graphGL/vshader.vert</file>
        </qresource>
        </RCC>@

        can't open the file:
        @QFile file(":/graphGL/vshader.vert");

        if (file.open(QIODevice::ReadOnly&#41;&#41; // if file exists reads from file
        {
            qDebug()<<"Open file Ok";
        }
        else //if file does not exists
        {
            qDebug()<<"Open file fail";
        }@
        

        Also like this ":/vshader.vert" fails to. If I use "vshader.vert" it opens the file, since I copy the shader file to the working directory

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          As supposed you have to set resource prefix to "/new/prefix1", so the correct path is ":/new/prefix1/graphGL/vshader.vert". Set the prefix to "/" if you want to access the file as ":/graphGL/vshader.vert".

          1 Reply Last reply
          0
          • J Offline
            J Offline
            john_god
            wrote on last edited by
            #5

            Thank you. That was the problem, it's solved now :)

            1 Reply Last reply
            0
            • H Offline
              H Offline
              HelpINeedSomebody
              wrote on last edited by
              #6

              I'm having the same problem, but i dont understand a shit about that. Can anyone explain me step by step what i have to do? Thx fornhelping me if u do!

              1 Reply Last reply
              0
              • H Offline
                H Offline
                HelpINeedSomebody
                wrote on last edited by
                #7

                I'm having the same problem, but i dont understand a shit about that. Can anyone explain me step by step what i have to do? Thx fornhelping me if u do!

                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