Ejemplo n.º 1
0
 Handle<Device::RTTexture> createRandomTexture(Device *device, size_t width, size_t height)
 {
   Handle<Device::RTTexture> texture = device->rtNewTexture("image");
   device->rtSetImage(texture, "image", createRandomImage(device, width, height));
   device->rtCommit(texture);
   return(texture);
 }
Ejemplo n.º 2
0
osg::Node* createQuads( unsigned int cols, unsigned int rows )
{
    osg::ref_ptr<osg::Geode> geode = new osg::Geode;
    for ( unsigned int y=0; y<rows; ++y )
    {
        for ( unsigned int x=0; x<cols; ++x )
        {
            osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
            texture->setImage( createRandomImage(512, 512) );
#ifdef COMPRESS_TEXTURE
            texture->setInternalFormatMode( osg::Texture2D::USE_S3TC_DXT1_COMPRESSION );
            texture->setUnRefImageDataAfterApply( true );
#endif

            osg::Vec3 center((float)x, 0.0f, (float)y);
            osg::ref_ptr<osg::Drawable> quad = osg::createTexturedQuadGeometry(
                                                   center, osg::Vec3(0.9f, 0.0f, 0.0f), osg::Vec3(0.0f, 0.0f, 0.9f) );
            quad->getOrCreateStateSet()->setTextureAttributeAndModes( 0, texture.get() );
            geode->addDrawable( quad.get() );
        }
    }
    return geode.release();
}