Changeset 950

Show
Ignore:
Timestamp:
10/20/08 10:43:41
Author:
robert
Message:

Added support for compression, and non power of two textures.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/vpb/BuildOptions

    r949 r950  
    6666        void setPowerOfTwoImages(bool powerOfTwoImages) { _powerOfTwoImages = powerOfTwoImages; } 
    6767        bool getPowerOfTwoImages() const { return _powerOfTwoImages; } 
    68          
     68 
    6969        /** Set the Archive name if one is to be used.*/ 
    7070        void setArchiveName(const std::string& filename) { _archiveName = filename; } 
  • trunk/src/vpb/Commandline.cpp

    r949 r950  
    455455    usage.addCommandLineOption("--RGBA-compressed","Use OpenGL compression on RGBA destination imagery");      
    456456    usage.addCommandLineOption("--RGB-16","Use 16bit RGB destination imagery");      
    457     usage.addCommandLineOption("--RGBA-24","Use 24bit RGB destination imagery");      
    458     usage.addCommandLineOption("--RGB-16","Use 16bit RGBA destination imagery");      
     457    usage.addCommandLineOption("--RGB-24","Use 24bit RGB destination imagery");      
     458    usage.addCommandLineOption("--RGBA-16","Use 16bit RGBA destination imagery");      
    459459    usage.addCommandLineOption("--RGBA","Use 32bit RGBA destination imagery");      
    460460    usage.addCommandLineOption("--vector","Interpret input as a vector data set"); 
  • trunk/src/vpb/Destination.cpp

    r949 r950  
    271271            } 
    272272             
    273             osg::notify(osg::NOTICE)<<"numColumnsAtFullRes = "<<numColumnsRequired<<"\tnumColumns = "<< numColumns<<std::endl
    274             osg::notify(osg::NOTICE)<<"numRowsAtFullRes = "<<numRowsRequired<<"\tnumRows = "<< numRows<<std::endl
     273            log(osg::NOTICE,"numColumnsAtFullRes = %itnumColumns = %i",numColumnsRequired,numColumns)
     274            log(osg::NOTICE,"numRowsAtFullRes = %i\tnumRows = ",numRowsRequired,numRows)
    275275        } 
    276276         
     
    11921192          case(DataSet::NO_MIP_MAPPING): 
    11931193            { 
     1194                log(osg::NOTICE,"DestinationTile::createStateSet() - DataSet::NO_MIP_MAPPING"); 
     1195             
    11941196                texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); 
    11951197                texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); 
     
    11981200          case(DataSet::MIP_MAPPING_HARDWARE): 
    11991201            { 
     1202                log(osg::NOTICE,"DestinationTile::createStateSet() - DataSet::MIP_MAPPING_HARDWARE"); 
    12001203                texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR); 
    12011204                texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); 
     
    12041207          case(DataSet::MIP_MAPPING_IMAGERY): 
    12051208            { 
     1209                log(osg::NOTICE,"DestinationTile::createStateSet() - DataSet::MIP_MAPPING_IMAGERY"); 
    12061210                texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR); 
    12071211                texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); 
     
    12141218 
    12151219        bool inlineImageFile = _dataSet->getDestinationTileExtension()==".ive"; 
    1216         bool compressedImageSupported = inlineImageFile || imageExtension==".dds"; 
     1220        bool compressedImageSupported = inlineImageFile || imageExtension=="dds"; 
    12171221        bool mipmapImageSupported = compressedImageSupported; // inlineImageFile; 
    12181222         
     
    12251229            (image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA)) 
    12261230        { 
     1231            log(osg::NOTICE,"Compressed image"); 
    12271232         
    12281233            if (image->s()>=minumDXT3CompressedTextureSize && image->t()>=minumDXT3CompressedTextureSize) 
     
    12331238            // force the mip mapping off temporay if we intend the graphics hardware to do the mipmapping. 
    12341239            if (_dataSet->getMipMappingMode()==DataSet::MIP_MAPPING_HARDWARE) 
     1240            { 
     1241                log(osg::INFO,"   switching off MIP_MAPPING for compile"); 
    12351242                texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); 
     1243            } 
    12361244 
    12371245            // make sure the OSG doesn't rescale images if it doesn't need to. 
     
    12581266        else 
    12591267        { 
     1268            log(osg::NOTICE,"Non compressed image mipmapImageSupported=%i imageExtension=%s",mipmapImageSupported,imageExtension.c_str()); 
     1269 
    12601270            if (_dataSet->getTextureType()==DataSet::RGB_16 && image->getPixelFormat()==GL_RGB) 
    12611271            { 
     
    12691279            if (mipmapImageSupported && _dataSet->getMipMappingMode()==DataSet::MIP_MAPPING_IMAGERY) 
    12701280            { 
    1271  
    1272                 osg::ref_ptr<osg::State> state = new osg::State; 
     1281                log(osg::NOTICE,"Doing mipmapping"); 
     1282 
     1283                // make sure the OSG doesn't rescale images if it doesn't need to. 
     1284                texture->setResizeNonPowerOfTwoHint(_dataSet->getPowerOfTwoImages()); 
    12731285 
    12741286                // get OpenGL driver to create texture from image. 
     
    13491361        } 
    13501362    } 
     1363 
     1364    _dataSet->getState()->checkGLErrors("DestinationTile::createStateSet()"); 
     1365 
    13511366    return _stateset.get(); 
    13521367} 
     
    13651380        _terrain->_heightField->allocate(8,8); 
    13661381        _terrain->_heightField->setOrigin(osg::Vec3(_extents.xMin(),_extents.yMin(),0.0f)); 
    1367         _terrain->_heightField->setXInterval(_extents.xMax()-_extents.xMin()); 
    1368         _terrain->_heightField->setYInterval(_extents.yMax()-_extents.yMin()); 
     1382        _terrain->_heightField->setXInterval(_extents.xMax()-_extents.xMin()/7.0); 
     1383        _terrain->_heightField->setYInterval(_extents.yMax()-_extents.yMin()/7.0); 
    13691384    } 
    13701385 
     
    15761591    } 
    15771592     
     1593    osg::Texture::FilterMode minFilter = _dataSet->getMipMappingMode()==BuildOptions::NO_MIP_MAPPING ?  
     1594                    osg::Texture::LINEAR : 
     1595                    osg::Texture::LINEAR_MIPMAP_LINEAR; 
     1596 
     1597    osg::Texture::FilterMode magFilter = osg::Texture::LINEAR; 
    15781598 
    15791599    // assign the imagery 
     
    15911611            osgTerrain::SwitchLayer* switchLayer = new osgTerrain::SwitchLayer; 
    15921612            switchLayer->setLocator(locator); 
     1613            switchLayer->setMinFilter(minFilter); 
     1614            switchLayer->setMagFilter(magFilter); 
    15931615            for(ImageSet::LayerSetImageDataMap::iterator litr = imageSet._layerSetImageDataMap.begin(); 
    15941616                litr != imageSet._layerSetImageDataMap.end(); 
     
    16011623 
    16021624                    osgTerrain::ImageLayer* imageLayer = new osgTerrain::ImageLayer; 
     1625                    imageLayer->setMinFilter(minFilter); 
     1626                    imageLayer->setMagFilter(magFilter); 
    16031627                    imageLayer->setImage(image); 
    16041628                    imageLayer->setSetName(litr->first); 
     
    16211645                imageLayer->setImage(image); 
    16221646                imageLayer->setLocator(locator); 
     1647                imageLayer->setMinFilter(minFilter); 
     1648                imageLayer->setMagFilter(magFilter); 
    16231649 
    16241650                terrainTile->setColorLayer(layerNum, imageLayer);