OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Write Image From texture Generated by compute shader


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Wed May 08, 2019 11:42 am    Post subject:
Write Image From texture Generated by compute shader
Reply with quote

Hi,
I've seen osgcomputeShaders example,which compute shader generates procedural texture. But How can I write the texture to image file(jpg or png) in osg.
In OpenGL, It seem to use texture query function glGetTexImage.But in more complicate situation,like mipmap or compressed texture,how to handle with it.
Dose osg have the function like that?

Thank you!

Cheers,
Yu
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Wed May 08, 2019 5:55 pm    Post subject:
osg::image::readImageFromCurrentTexture
Reply with quote

Hi,
I use osg::image::readImageFromCurrentTexture in a cullvisitor,with texture apply before the method,but it doesn't work.

[code]class WriteTexureCallback : public osg::NodeCallback
{
public:
WriteTexureCallback()
:osg::NodeCallback()
{
mIsRuned = false;
}

virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
if (nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
{
osgUtil::CullVisitor* cv = nv->asCullVisitor();
if (nv->getFrameStamp()->getFrameNumber() > 20 && !mIsRuned)
{
osg::Texture* texture = dynamic_cast<osg::Texture*>(node->getOrCreateStateSet()->getTextureAttribute(0, osg::StateAttribute::TEXTURE));
if (texture)
{
texture->apply(*(cv->getState()));
osg::ref_ptr<osg::Image> image = new osg::Image;
image->readImageFromCurrentTexture(cv->getState()->getContextID(), true);

if (osgDB::writeImageFile(*image, "D:\\1.jpg"))
mIsRuned = true;
}
}
}
traverse(node, nv);
}
private:
bool mIsRuned;
};[/code]

Thank you!

Cheers,
Yu
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts problem about reconstructing world co... swaggydong General 0 Sun Jun 23, 2019 8:26 am View latest post
No new posts remove mipmap data from osg::Image Trajce Nikolov NICK General 0 Tue May 28, 2019 2:40 pm View latest post
No new posts Layered rendering with a geometry shader AnyOldName3 General 8 Tue May 14, 2019 11:25 pm View latest post
No new posts 回复: Is it possible to load text... GarfieldPig General 118 Fri May 10, 2019 4:32 pm View latest post
No new posts Is it possible to load texture withou... robertosfield General 9 Thu May 09, 2019 8:29 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP