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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org