#include #include using namespace osgUtil; CubeMapGenerator::CubeMapGenerator(int texture_size) : osg::Referenced(), texture_size_(texture_size) { for (int i=0; i<6; ++i) { osg::ref_ptr image = osgNew osg::Image; unsigned char* data = (static_cast(malloc(texture_size*texture_size*4))); image->setImage(texture_size, texture_size, 1, 4, GL_RGBA, GL_UNSIGNED_BYTE, data); images_.push_back(image); } } CubeMapGenerator::CubeMapGenerator(const CubeMapGenerator ©, const osg::CopyOp ©op) : osg::Referenced(copy), texture_size_(copy.texture_size_) { Image_list::const_iterator i; for (i=copy.images_.begin(); i!=copy.images_.end(); ++i) { images_.push_back(static_cast(copyop(i->get()))); } } void CubeMapGenerator::generateMap(bool use_osg_system) { const float duv = 2.0f/(texture_size_-1); float v = 1; for (int i=0; i