[Interest] Question about reading glsl shader source from a QResource using compression
Ola Røer Thorsen
ola at silentwings.no
Mon Jan 13 13:25:41 CET 2014
Hi all,
I've been looking at the Scene Graph - Graph example application included
with Qt5.2.0, to see how to create a custom shader material for Qt Quick.
In linenode.cpp, there is a LineShader class, where the shaders are read
like so:
const char *vertexShader() const {
QResource r(":/scenegraph/graph/shaders/line.vsh");
Q_ASSERT(r.isValid());
return (const char *) r.data();
}
const char *fragmentShader() const {
QResource r(":/scenegraph/graph/shaders/line.fsh");
Q_ASSERT(r.isValid());
return (const char *) r.data();
}
In the documentation for QResource, it says that the data returned by
r.data may be compressed. So is this way of reading the shader source code
safe at all times? Shouldn't it check with r.isCompressed and if so,
uncompress? Is there some assumption here that such small text files aren't
compressed?
Cheers,
Ola
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140113/567d853a/attachment.html>
More information about the Interest
mailing list