Skip to content

Use osgDB::Registry::instance()->writeNode(...) in runtime #1204

Closed Answered by FuXiii
FuXiii asked this question in Q&A
Discussion options

You must be logged in to vote

I had fixed this problem by my net group friend.
After read model file into OSG, traverse all model's children node stateset an call:

osg::Texture2D* tex2D = dynamic_cast<osg::Texture2D>(stateset->getTextureAttribute(i, osg::StateAttribute::TEXTURE));
tex2D->setUnRefImageDataAfterApply(false);

And then call osgDB::Registry::instance()->writeNode(...) and then read the writed model file. It will draw correctly.
I don't know weather this the right method to fix this issue, if only look at the result, it maybe the right way.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by FuXiii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants