Re: [osg-users] Writing to an image file
Hi, I have the same problem than Amanda. I am creating a class SimpleBillboard which load a Model, create an ortho projection of it and a Quad and try to put the texture projeted onto that quad. I think that Amanda try to output the texture loaded into an image file. The problem is that after the allocation of the image, we write our image but there is no information in the buffer at this point. Because the loop has not started may be. So the question should be : How I can force OSG to render the texture into the buffer and then put it into the image. And not waiting for the loop. Is callback could be usefull here ? Thank you! Cheers, Benoît -- Benoît Bayol benoit.ba...@gmail.com -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=13988#13988 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Writing to an image file
Hi Amanda, On 26/5/09 5:39 PM, Amanda Henn wrote: I am very new to computer graphics and OSG/OpenGL. I need to figure out how to write a simple textured rectangle to a .tif file. I've found many examples of this but some are so complicated I can't understand them. What do you mean by 'write a texture rectangle'? Do you want to save the rendered frame to a file? If so then please take a look at the osgscreencapture example - in brief you need to add a capture callback to read the rendered frame and save it to a file. Here is the code I have so far, when I run it I can see a single rectangle with the road texture on it. I have some code that does create a result .tif file, but I can't view it. I'm sure I'm missing some things. I'd appreciate any help, I know this is probably a simple question... 'Can't view it' as in it's empty? Or not a tif file? Please give us a bit more detail to work with. //write image code I've been playing with osg::Image* resultImage = new osg::Image; resultImage->allocateImage(3000, 3000, 0, GL_RGB, GL_UNSIGNED_BYTE); osgDB::writeImageFile(*resultImage, "D:\\C++_Projects\\result.tif"); This will write an empty image (probably black). Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Writing to an image file
Hi, I am very new to computer graphics and OSG/OpenGL. I need to figure out how to write a simple textured rectangle to a .tif file. I've found many examples of this but some are so complicated I can't understand them. Here is the code I have so far, when I run it I can see a single rectangle with the road texture on it. I have some code that does create a result .tif file, but I can't view it. I'm sure I'm missing some things. I'd appreciate any help, I know this is probably a simple question... osgViewer::Viewer viewer; osg::Group* root = new osg::Group; osg::Geode* rectangleGeode = createRectangle(); root->addChild(rectangleGeode); osg::Texture2D* RoadTexture = new osg::Texture2D(); RoadTexture->setDataVariance(osg::Object::DYNAMIC); osg::Image* Road = osgDB::readImageFile("D:\\C++_Projects\\OSG_Test\\release\\road_texture.jpg"); if (!Road) { std::cout << " couldn't find texture, quitting." << std::endl; return -1; } RoadTexture->setImage(Road); osg::StateSet* stateOne = new osg::StateSet(); stateOne->setTextureAttributeAndModes(0, RoadTexture, osg::StateAttribute::ON); rectangleGeode->setStateSet(stateOne); viewer.setSceneData(root); //write image code I've been playing with osg::Image* resultImage = new osg::Image; resultImage->allocateImage(3000, 3000, 0, GL_RGB, GL_UNSIGNED_BYTE); osgDB::writeImageFile(*resultImage, "D:\\C++_Projects\\result.tif"); //End of write image code return viewer.run(); Thank you! Amanda -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12977#12977 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org