[Solved] Error opening a shader file



  • 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 ?



  • 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?



  • 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



  • 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".



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



  • 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!



  • 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!


Log in to reply
 

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