Changeset 10934

Show
Ignore:
Timestamp:
01/08/10 12:32:55 (3 years ago)
Author:
robert
Message:

From Rob Radtke, "I recently ran into some issues trying to save/load a scene graph as a .ive file. The problems came about because the scene graph contained depth textures in it. I have attached a patch (against the current revision: 10919) that fixes the issues that I encountered. Both attachments contain the same patch--one is a .zip file that contains the modified files and the other is a text patch file. Here is a summary of the changes I made:

1) Add getShadowComparison() accessor function to osg::Texture class
2) Modify ReaderWriterTiff::writeTifStream() and _readColor() (in Image.cpp) to handle pixelFormat==GL_DEPTH_COMPONENT as if it were GL_LUMINANCE
3) Modify the Texture classes of the ive and osg plug-ins so that they save/load the following Texture members: _use_shadow_comparison, _shadow_compare_func and _shadow_texture_mode
"

Location:
OpenSceneGraph/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/Texture

    r10833 r10934  
    538538          * See http://oss.sgi.com/projects/ogl-sample/registry/ARB/shadow.txt. */ 
    539539        void setShadowComparison(bool flag) { _use_shadow_comparison = flag; } 
    540  
     540        bool getShadowComparison() const { return _use_shadow_comparison; } 
     541         
    541542        enum ShadowCompareFunc { 
    542543            NEVER = GL_NEVER, 
  • OpenSceneGraph/trunk/src/osg/Image.cpp

    r10924 r10934  
    14171417    switch(pixelFormat) 
    14181418    { 
     1419        case(GL_DEPTH_COMPONENT):   //intentionally fall through and execute the code for GL_LUMINANCE 
    14191420        case(GL_LUMINANCE):         { float l = float(*data++)*scale; return Vec4(l, l, l, 1.0f); } 
    14201421        case(GL_ALPHA):             { float a = float(*data++)*scale; return Vec4(1.0f, 1.0f, 1.0f, a); } 
  • OpenSceneGraph/trunk/src/osgPlugins/ive/IveVersion.h

    r10513 r10934  
    5252#define VERSION_0041 41 
    5353#define VERSION_0042 42 
     54#define VERSION_0043 43 
    5455 
    55 #define VERSION VERSION_0042 
     56#define VERSION VERSION_0043 
    5657 
    5758/* The BYTE_SEX tag is used to check the endian 
  • OpenSceneGraph/trunk/src/osgPlugins/ive/Texture.cpp

    r10762 r10934  
    6363        out->writeInt(_sourceType); 
    6464    } 
     65 
     66    if( out->getVersion() >= VERSION_0043 ) 
     67    { 
     68      out->writeBool( _use_shadow_comparison ); 
     69      out->writeInt( _shadow_compare_func ); 
     70      out->writeInt( _shadow_texture_mode ); 
     71    } 
    6572} 
    6673 
     
    113120            _sourceType = in->readInt(); 
    114121        } 
     122 
     123        if( in->getVersion() >= VERSION_0043 ) 
     124        { 
     125          _use_shadow_comparison = in->readBool(); 
     126          _shadow_compare_func = (osg::Texture::ShadowCompareFunc)in->readInt(); 
     127          _shadow_texture_mode = (osg::Texture::ShadowTextureMode)in->readInt(); 
     128        } 
    115129    } 
    116130    else 
  • OpenSceneGraph/trunk/src/osgPlugins/osg/Texture.cpp

    r9475 r10934  
    2727bool Texture_matchSourceTypeStr(const char* str,int& value); 
    2828const char* Texture_getSourceTypeStr(int value); 
     29bool Texture_matchShadowCompareFuncStr(const char* str,Texture::ShadowCompareFunc& value); 
     30const char* Texture_getShadowCompareFuncStr(Texture::ShadowCompareFunc value); 
     31bool Texture_matchShadowTextureModeStr(const char* str,Texture::ShadowTextureMode& value); 
     32const char* Texture_getShadowTextureModeStr(Texture::ShadowTextureMode value); 
    2933 
    3034// register the read and write functions with the osgDB::Registry. 
     
    202206    } 
    203207 
     208    if (fr[0].matchWord("shadowComparison")) 
     209    { 
     210        if (fr[1].matchWord("TRUE"))  
     211        { 
     212            texture.setShadowComparison(true); 
     213            fr +=2 ; 
     214            iteratorAdvanced = true; 
     215        } 
     216        else if (fr[1].matchWord("FALSE"))  
     217        { 
     218            texture.setShadowComparison(false); 
     219            fr +=2 ; 
     220            iteratorAdvanced = true; 
     221        } 
     222    } 
     223 
     224    if (fr[0].matchWord("shadowCompareFunc")) 
     225    { 
     226        Texture::ShadowCompareFunc value; 
     227        if (Texture_matchShadowCompareFuncStr(fr[1].getStr(),value)) 
     228        { 
     229            texture.setShadowCompareFunc(value); 
     230            fr+=2; 
     231            iteratorAdvanced = true; 
     232        } 
     233    } 
     234 
     235    if (fr[0].matchWord("shadowTextureMode")) 
     236    { 
     237        Texture::ShadowTextureMode value; 
     238        if (Texture_matchShadowTextureModeStr(fr[1].getStr(),value)) 
     239        { 
     240            texture.setShadowTextureMode(value); 
     241            fr+=2; 
     242            iteratorAdvanced = true; 
     243        } 
     244    } 
     245 
    204246    return iteratorAdvanced; 
    205247} 
     
    254296 
    255297    fw.indent() << "resizeNonPowerOfTwo "<< (texture.getResizeNonPowerOfTwoHint()?"TRUE":"FALSE") << std::endl; 
     298 
     299    fw.indent() << "shadowComparison "<< (texture.getShadowComparison()?"TRUE":"FALSE") << std::endl; 
     300 
     301    fw.indent() << "shadowCompareFunc " << Texture_getShadowCompareFuncStr(texture.getShadowCompareFunc()) << std::endl; 
     302 
     303    fw.indent() << "shadowTextureMode " << Texture_getShadowTextureModeStr(texture.getShadowTextureMode()) << std::endl; 
    256304 
    257305    return true; 
     
    427475} 
    428476 
    429  
    430477const char* Texture_getSourceTypeStr(int value) 
    431478{ 
     
    442489    return NULL; 
    443490} 
     491 
     492bool Texture_matchShadowCompareFuncStr(const char* str, Texture::ShadowCompareFunc& value) 
     493{ 
     494    if (     strcmp(str,"GL_LEQUAL")==0) value = Texture::LEQUAL; 
     495    else if (strcmp(str,"GL_GEQUAL")==0) value = Texture::GEQUAL; 
     496    else return false; 
     497 
     498    return true; 
     499} 
     500 
     501const char* Texture_getShadowCompareFuncStr(Texture::ShadowCompareFunc value) 
     502{ 
     503    switch(value) 
     504    { 
     505    case( Texture::LEQUAL ): return "GL_LEQUAL"; 
     506    case( Texture::GEQUAL ): return "GL_GEQUAL"; 
     507    } 
     508    return NULL; 
     509} 
     510 
     511bool Texture_matchShadowTextureModeStr(const char* str,Texture::ShadowTextureMode& value) 
     512{ 
     513    if (     strcmp(str,"GL_LUMINANCE")==0) value = Texture::LUMINANCE; 
     514    else if (strcmp(str,"GL_INTENSITY")==0) value = Texture::INTENSITY; 
     515    else if (strcmp(str,"GL_ALPHA")==0) value = Texture::ALPHA; 
     516    else return false; 
     517 
     518    return true; 
     519} 
     520 
     521const char* Texture_getShadowTextureModeStr(Texture::ShadowTextureMode value) 
     522{ 
     523    switch(value) 
     524    { 
     525        case( Texture::LUMINANCE ): return "GL_LUMINANCE"; 
     526        case( Texture::INTENSITY ): return "GL_INTENSITY"; 
     527        case( Texture::ALPHA ): return "GL_ALPHA"; 
     528    } 
     529    return NULL; 
     530} 
  • OpenSceneGraph/trunk/src/osgPlugins/tiff/ReaderWriterTIFF.cpp

    r9556 r10934  
    784784 
    785785            switch(img.getPixelFormat()) { 
     786                case GL_DEPTH_COMPONENT: 
    786787                case GL_LUMINANCE: 
    787788                case GL_ALPHA: