|
如题,我想读取一张高程图并设为一张二维纹理。通过了以下的代码实现,但未能得到效果。表现的问题为贴图没有显示。想请教下代码,下面的代码是否有问题:
float *data1 = new float[256*64*3];
FILE *f1 = fopen("transmittance.raw", "rb");
fread(data1, 1, 256*64*3*sizeof(float), f1);
fclose(f1);
osg::ref_ptr<osg::Image> image2 = new osg::Image;
osg::Texture2D *transmittanceTex = new osg::Texture2D;
transmittanceTex->setFilter(osg::Texture::MIN_FILTER,osg::Texture:INEAR);
transmittanceTex->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
transmittanceTex->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE);
transmittanceTex->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE);
image2->setImage(256,64,0,GL_RGB,GL_RGB32F_ARB,GL_FLOAT,(unsigned char*)data,osg::Image::USE_NEW_DELETE);
transmittanceTex->setInternalFormat(GL_RGB);
transmittanceTex->setImage(image2.get());
ss->setTextureAttributeAndModes(2,transmittanceTex);
delete[] data1;
osg::Uniform* transmittanceTexUniform = new osg::Uniform("transmittanceSampler",2);
ss->addUniform(transmittanceTexUniform);
|
|