Re: [Interest] Question about reading glsl shader source from a QResource using compression
I think the example is just doing it wrong, it should instead load the resource file contents using QFile into two QByteArrays into the ctor and then return the QByteArrays' contents there. Right. Thanks for the feedback! I'll use QFile to be sure, in case compression is enabled. Cheers! ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
[Interest] Question about reading glsl shader source from a QResource using compression
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 ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Question about reading glsl shader source from a QResource using compression
Presence and level of resource compression depends on command line parameters passed to the resource compiler. IIRC compression is disabled by default so all resources are stored as is unless you explicitly tell the resource compiler to compress them and correct way of retrieving resource data depends on your project settings. On Jan 13, 2014 4:26 PM, Ola Røer Thorsen o...@silentwings.no wrote: 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 ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Question about reading glsl shader source from a QResource using compression
On 13 January 2014 13:25, Ola Røer Thorsen o...@silentwings.no wrote: 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? I think the example is just doing it wrong, it should instead load the resource file contents using QFile into two QByteArrays into the ctor and then return the QByteArrays' contents there. -- Giuseppe D'Angelo ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest