Changeset 172


Ignore:
Timestamp:
Dec 7, 2010, 10:55:17 AM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/TerrainTest
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • experimental/TerrainTest/myTerrainTechnique.cpp

    r171 r172  
    3434         ImageLayer* il = dynamic_cast<ImageLayer*>( getTerrainTile()->getColorLayer(0) );
    3535         osg::Image* img = il->getImage();
    36          img->setInternalTextureFormat( GL_RGBA );
     36         //img->setInternalTextureFormat( GL_RGBA );
    3737
    38          osg::ref_ptr<osg::Image> img2 = new osg::Image();
    39          img2->setInternalTextureFormat( GL_RGBA );
    40          img2->alloc
     38         if( img->getPixelFormat() == GL_RGBA )
     39                 OSG_ALWAYS << "Format ist RGBA" << std::endl;
     40         if( img->getPixelFormat() == GL_RGB )
     41                 OSG_ALWAYS << "Format ist RGB" << std::endl;
     42          if( img->getPixelFormat() == GL_COMPRESSED_RGB_S3TC_DXT1_EXT )
     43                 OSG_ALWAYS << "Format ist GL_COMPRESSED_RGB_S3TC_DXT1_EXT" << std::endl;
     44
     45         
     46
     47         //osg::ref_ptr<osg::Image> img2 = new osg::Image();
     48         //img2->setInternalTextureFormat( GL_RGBA );
     49         //OSG_ALWAYS << "test: " << std::hex << img->getPixelFormat() << std::endl;
    4150
    4251    GeometryTechnique::init(dirtyMask, assumeMultiThreaded);
    4352}
     53
     54void myTerrainTechnique::ConvertImage(osg::ref_ptr<osg::Image> a_toImage, osg::ref_ptr<osg::Image> a_fromImage, GLenum a_pixelFormat, GLenum a_dataType)
     55{
     56        GLenum dataType = a_fromImage -> getDataType();
     57
     58        //setInternalTextureFormat( 0); // tmp
     59        a_toImage -> allocateImage(
     60                a_fromImage -> s(),
     61                a_fromImage -> t(),
     62                a_fromImage -> r(),
     63                a_pixelFormat, a_dataType, a_fromImage -> getPacking());
     64
     65        //// Wenn Quelle und Ziel RGBA sind
     66        //if( a_toImage -> getPixelFormat() == GL_RGBA && a_fromImage -> getPixelFormat() == GL_RGBA)
     67        //{
     68        //      unsigned nr = a_fromImage->t();
     69        //      unsigned nc = a_fromImage->s();
     70        //      for (unsigned r = 0; r < nr; ++r)
     71        //      {
     72        //              for (unsigned c = 0; c < nc; ++c)
     73        //              {
     74        //                      unsigned char * fromPixelData = a_fromImage -> data(c, nr-r-1);
     75        //                      unsigned char *   toPixelData =   a_toImage -> data(c, nr-r-1);
     76
     77        //                      // Copy r, g, b, a.
     78        //                      for( int component = 0; component < 4; ++ component)
     79        //                      {
     80        //                              My_OSG_Library::OSG_PixelComponent pixelComponent( a_fromImage -> getDataType(), fromPixelData, component /* r, g, b, a */);
     81        //                              pixelComponent.Store( a_toImage -> getDataType(), toPixelData, component);
     82        //                      }
     83        //              }
     84        //      }
     85        //}
     86        //else
     87        // Wenn Quelle RGB ist und Ziel RGBA
     88        //if( a_toImage -> getPixelFormat() == GL_RGBA && a_fromImage -> getPixelFormat() == GL_RGB)
     89        //{
     90        //      unsigned nr = a_fromImage -> t();
     91        //      unsigned nc = a_fromImage -> s();
     92        //      for (unsigned r = 0; r < nr; ++r)
     93        //      {
     94        //              for (unsigned c = 0; c < nc; ++c)
     95        //              {
     96        //                      unsigned char * fromPixelData = a_fromImage -> data(c, nr-r-1);
     97        //                      unsigned char *   toPixelData =   a_toImage -> data(c, nr-r-1);
     98
     99        //                      // Copy r, g, b.
     100        //                      for( int component = 0; component < 3; ++ component)
     101        //                      {
     102        //                              My_OSG_Library::OSG_PixelComponent pixelComponent( a_fromImage -> getDataType(), fromPixelData, component /* r, g, b */);
     103        //                              pixelComponent.Store( a_toImage -> getDataType(), toPixelData, component);
     104        //                      }
     105
     106        //                      // Initialize alpha to opaque.
     107        //                      My_OSG_Library::OSG_PixelComponent::One().Store( a_toImage -> getDataType(), toPixelData, 3);
     108        //              }
     109        //      }
     110        //}
     111}
  • experimental/TerrainTest/myTerrainTechnique.h

    r171 r172  
    33#include <osgTerrain/GeometryTechnique>
    44#include <osg/Image>
     5
    56
    67namespace osgTerrain {
     
    1920
    2021        virtual void init(int dirtyMask, bool assumeMultiThreaded);
     22
     23        void ConvertImage(osg::ref_ptr<osg::Image> a_toImage, osg::ref_ptr<osg::Image> a_fromImage, GLenum a_pixelFormat, GLenum a_dataType);
    2124};
    2225
Note: See TracChangeset for help on using the changeset viewer.