Discussion:
Qt resouce and osgDB::readImageFile
Heiko Thiel
2014-09-11 14:51:54 UTC
Permalink
Hi,

I currently bind files wich our application need as resource. But is there a way, that osg automatically use the resource system (accept filepathes starting with qrc:/). Or how I can load a file from a qrc with something like readImageFile, where a filepathes is accepted, but I don't see an alternate with a stream?

Thank you!

Cheers,
Heiko

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=61020#61020
Andre Normann
2014-09-22 06:40:05 UTC
Permalink
Hi Heiko,

I solved the problem this way:

1. Create an own subclass of osgDB::ReadFileCallback and override the
readImage method.
2. Check inside the readImage() method, if the filename starts with ":/" or
"qrc:///"
3. If the filename is a Qt resource, then load the image into a QImage and
convert it to an osg::Image.
4. Call osgDB::Registry::instance()->setReadFileCallback() with a new
instance of your own osgDB::ReadFileCallback from step 1.

Now you should be able to load Qt resources by calling
osgDB::readImageFile(":/Test/Test.jpg") etc.


Best regards,
André
Post by Heiko Thiel
Hi,
I currently bind files wich our application need as resource. But is there
a way, that osg automatically use the resource system (accept filepathes
starting with qrc:/). Or how I can load a file from a qrc with something
like readImageFile, where a filepathes is accepted, but I don't see an
alternate with a stream?
Thank you!
Cheers,
Heiko
------------------
http://forum.openscenegraph.org/viewtopic.php?p=61020#61020
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Loading...