Show
Ignore:
Timestamp:
07/22/08 16:47:59 (6 years ago)
Author:
robert
Message:

Fixed handling of TextureCubeMap?'s with mipmapped/ImageSequence/PBO's.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgimagesequence/osgimagesequence.cpp

    r8647 r8657  
    2020#include <osg/Geometry> 
    2121#include <osg/Notify> 
     22#include <osg/Texture1D> 
    2223#include <osg/Texture2D> 
     24#include <osg/Texture3D> 
     25#include <osg/TextureRectangle> 
    2326#include <osg/ImageSequence> 
    2427#include <osg/Geode> 
     
    2629#include <osgDB/Registry> 
    2730#include <osgDB/ReadFile> 
     31#include <osgDB/WriteFile> 
    2832 
    2933#include <osgViewer/Viewer> 
     
    3741osg::StateSet* createState() 
    3842{ 
    39     // read 4 2d images 
    40     osg::ref_ptr<osg::Image> image_0 = osgDB::readImageFile("Images/lz.rgb"); 
    41     osg::ref_ptr<osg::Image> image_1 = osgDB::readImageFile("Images/reflect.rgb"); 
    42     osg::ref_ptr<osg::Image> image_2 = osgDB::readImageFile("Images/tank.rgb"); 
    43     osg::ref_ptr<osg::Image> image_3 = osgDB::readImageFile("Images/skymap.jpg"); 
     43    osg::ref_ptr<osg::ImageSequence> imageSequence = new osg::ImageSequence; 
    4444 
    45     osg::ref_ptr<osg::ImageSequence> imageSequence = new osg::ImageSequence; 
    46     imageSequence->addImage(image_0.get()); 
    47     imageSequence->addImage(image_1.get()); 
    48     imageSequence->addImage(image_2.get()); 
    49     imageSequence->addImage(image_3.get()); 
    50      
     45    imageSequence->setDuration(2.0); 
     46    imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posx.png")); 
     47    imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negx.png")); 
     48    imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posy.png")); 
     49    imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negy.png")); 
     50    imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posz.png")); 
     51    imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negz.png")); 
     52 
     53#if 1 
    5154    osg::Texture2D* texture = new osg::Texture2D; 
    52     texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); 
    53     texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); 
    54     texture->setWrap(osg::Texture2D::WRAP_R,osg::Texture2D::REPEAT); 
     55    texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); 
     56    texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); 
     57    texture->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT); 
    5558    texture->setResizeNonPowerOfTwoHint(false); 
    5659    texture->setImage(imageSequence.get()); 
    5760    //texture->setTextureSize(512,512); 
    5861     
    59     texture->setUpdateCallback(new osg::ImageSequence::UpdateCallback); 
     62    //texture->setUpdateCallback(new osg::ImageSequence::UpdateCallback); 
     63#else     
     64    osg::TextureRectangle* texture = new osg::TextureRectangle; 
     65    texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); 
     66    texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); 
     67    texture->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT); 
     68    // texture->setResizeNonPowerOfTwoHint(false); 
     69    texture->setImage(imageSequence.get()); 
     70    //texture->setTextureSize(512,512); 
     71     
     72    //texture->setUpdateCallback(new osg::ImageSequence::UpdateCallback); 
     73#endif 
    6074 
    6175    // create the StateSet to store the texture data 
     
    8195 
    8296 
    83 int main(int , char **) 
     97int main(int argc, char **argv) 
    8498{ 
     99    osg::ArgumentParser arguments(&argc,argv); 
     100 
    85101    // construct the viewer. 
    86     osgViewer::Viewer viewer; 
     102    osgViewer::Viewer viewer(arguments); 
    87103 
    88104    // create a model from the images and pass it to the viewer. 
    89105    viewer.setSceneData(createModel()); 
    90106 
     107    //osgDB::writeNodeFile(*viewer.getSceneData(),"test.osg"); 
     108 
    91109    return viewer.run(); 
    92110}