[Solved] QGLShader: Unable to open file "vert.vert"
-
Anyone has idea why my shader program can't read in the vertex shader file ?
I load the file residing in "Other Files" directory :
@
const QString vertexShaderPath="vert.vert";if(!m_shader.addShaderFromSourceFile(QGLShader::Vertex,vertexShaderPath )){ qDebug() << m_shader.log(); }
@
And getting this:QGLShader: Unable to open file "vert.vert"
-
Yes it resides in the "Other Files" but that is not a physical location.So in fact it resides in the same folder with the main.cpp .And somehow it is not loaded.
-
Lukas ,thanks for this tip! Now I see that it retrieves the file from the debug directory which is outside the project folder.I guess it is created when I run in debug mode.How can I change it so that it targets the vert.vert file from the project directory?
-
Please don't hack around, trying to get the build system to put stuff all over the place! Consider using a proper deployment configuration (aka. a "make install") instead. The build system is generating binaries and assumes that you do not care what it does. The installation is meant to make the application useful by copying files where they need to go. That will make reusing your application/sources way easier for others: You will have less assumptions about your system coded into the build system.
In Qt Creator you can add deployment steps for that...
-
[quote author="sasmaster" date="1318859574"]Lukas ,thanks for this tip! Now I see that it retrieves the file from the debug directory which is outside the project folder.I guess it is created when I run in debug mode.How can I change it so that it targets the vert.vert file from the project directory?[/quote]
You can change the working directory under Projects -> Run. addShaderFromSourceFile() takes either a relative or absolute path. So you can just use "debug/vert.vert" or "../vert.vert" or whatever.
But as said, the easiest way to deploy small files with your application is embedding them as a resource. No more fragile tinkering with relative paths. If you do not want to embed it take a look at Tobias post.