Hi, Hector
 
This solution is quite general and you dont need to change other code to load from different resource's locations (and for about two pages of code you can load all kind of objects loadable with osgDB, usually you need to override only 3-4 functions like readObject (f.e. used for ttf fonts loading), readNode, readImage, readShader). I successfully use this approach for loading from cyphered archives and qt resources.
 
Cheers.
 
14.05.2012, 09:29, "Héctor Martínez" <[email protected]>:

Hi,

 

thank you for your reply. Sorry I didn’t see the answer the other day. While I was waiting for an answer, I solved it by loading the resource with Qt and converting the image to OSG.

Anyway, it is interesting the solution you provide, so I may try to implement it at some point.

 

Thank you!

 

Cheers!

 

From: [email protected] [mailto:[email protected]] On Behalf Of Sergey Polischuk
Sent: viernes, 11 de mayo de 2012 10:46
To: OpenSceneGraph Users
Subject: Re: [osg-users] Load images from resources file (rc)

 

As long as you know how to get raw data stream from wherever your resources are - you can write osgDB::ReadFileCallback where you override methods like

 

MyReadFileCallback::result_t
MyReadFileCallback::readObject(const std::string& filename, const osgDB::Options* options)
{

        //create stream which contain unpacked data of your file


        int ext_pos;
        if ((ext_pos = filename.find_last_of(".")) > 0)
        {
            std::string fileext = filename.substr(ext_pos + 1);
            osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForExtension(fileext);
            if (rw)
                return rw->readObject(stream, options);
        }

        return MyReadFileCallback::result_t();
}

 

You should register your read file callback in osgDB::Registry with osgDB::Registry::instance()->setReadFileCallback(...) prior to loading stuff.

Cheers,

Sergey

 

11.05.2012, 11:07, "Héctor Martínez" <[email protected]>:

Hi,

 

does anybody know if it is possible to load images from a ‘.rc’ file in osg using osgDB::readImageFile?

 

Thanks in advance

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to