Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- osg::Texture*
- GroundCover::createTexture() const
- {
- osg::Texture2DArray* tex = new osg::Texture2DArray();
- int arrayIndex = 0;
- float s = -1.0f, t = -1.0f;
- for(int b=0; b<getBiomes().size(); ++b)
- {
- const GroundCoverBiome* biome = getBiomes()[b].get();
- for(int i=0; i<biome->getBillboards().size(); ++i, ++arrayIndex)
- {
- const GroundCoverBillboard& bb = biome->getBillboards()[i];
- osg::ref_ptr<osg::Image> im;
- // make sure the texture array is POT - required now for mipmapping to work
- if ( s < 0 )
- {
- s = nextPowerOf2(bb._image->s());
- t = nextPowerOf2(bb._image->t());
- tex->setTextureSize(s, t, getTotalNumBillboards());
- }
- if ( bb._image->s() != s || bb._image->t() != t )
- {
- ImageUtils::resizeImage( bb._image.get(), s, t, im );
- }
- else
- {
- im = bb._image.get();
- }
- tex->setImage( arrayIndex, im.get() );
- }
- }
- tex->setFilter(tex->MIN_FILTER, tex->NEAREST_MIPMAP_LINEAR);
- tex->setFilter(tex->MAG_FILTER, tex->LINEAR);
- tex->setWrap (tex->WRAP_S, tex->CLAMP_TO_EDGE);
- tex->setWrap (tex->WRAP_T, tex->CLAMP_TO_EDGE);
- tex->setUnRefImageDataAfterApply( true );
- tex->setMaxAnisotropy( 4.0 );
- //tex->setResizeNonPowerOfTwoHint( false ); // no longer legal for tex2darray!
- return tex;
- }
Add Comment
Please, Sign In to add comment