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 Wrapping Text around object as texture johansson_gbg General 0 Tue Oct 15, 2019 7:45 am View latest post
No new posts Image from shader lucasamparo General 14 Thu Oct 03, 2019 5:46 pm View latest post
No new posts How do I move a Texture in an model ... newlife958 General 10 Tue Sep 17, 2019 1:16 am View latest post
No new posts Render to Texture and osgQt (osgQOpenGL) wroos General 3 Mon Sep 16, 2019 5:47 pm View latest post
No new posts [OSG 3.6.3 Core Profile GL 3+] Weird ... johansson_gbg General 2 Thu Sep 12, 2019 1:17 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