[Solved] Error opening a shader file
-
wrote on 24 Oct 2011, 23:21 last edited by
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 ? -
wrote on 25 Oct 2011, 07:10 last edited by
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? -
wrote on 25 Oct 2011, 18:22 last edited by
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)) // 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
-
wrote on 25 Oct 2011, 20:11 last edited by
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".
-
wrote on 26 Oct 2011, 00:04 last edited by
Thank you. That was the problem, it's solved now :)
-
wrote on 9 Feb 2015, 21:19 last edited by
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!
-
wrote on 9 Feb 2015, 21:19 last edited by
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!