osg 实现动态跟新纹理数据

时间:2021-11-03 16:08:18

主要是用这个函数来更新image的数据

    osg::Image* img0 = osgDB::readImageFile("C:/zq/workplace/osg/testAll/TestOsg/TestOsg/tmp/glassResource/cube.bmp");
osg::Image* img1 = osgDB::readImageFile("C:/zq/workplace/osg/testAll/TestOsg/TestOsg/tmp/glassResource/cube2.bmp");
//设置纹理数据
img0->setImage(1024, 768, 1,img1->getInternalTextureFormat(),img1->getPixelFormat(),img1->getDataType(), img1->data(), osg::Image::USE_MALLOC_FREE);
//刷新
img0->dirty();
std::cout << "dfas\n";
osg::Texture2D* tex = new osg::Texture2D;
//设置为动态数据
tex->setDataVariance(osg::Object::DYNAMIC);
tex->setImage(img0);
...