Changeset 8195

Show
Ignore:
Timestamp:
04/23/08 16:10:41
Author:
robert
Message:

Added mutex to object creation to avoid a race condition when using threaded multiple graphics context

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph/trunk/src/osg/TextureRectangle.cpp

    r7648 r8195  
    147147    const unsigned int contextID = state.getContextID(); 
    148148 
     149 
     150    static OpenThreads::Mutex s_mutex; 
     151 
    149152    // get the texture object for the current contextID. 
    150153    TextureObject* textureObject = getTextureObject(contextID); 
    151  
     154     
     155     
    152156    if (textureObject != 0) 
    153157    { 
     
    190194    else if (_image.valid() && _image->data()) 
    191195    { 
     196 
     197        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex); 
     198 
    192199        // we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object.         
    193200        _textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_RECTANGLE); 
    194  
     201         
    195202        textureObject->bind(); 
    196203 
     
    206213            non_const_this->_image = 0; 
    207214        } 
     215 
     216 
    208217    } 
    209218    else if ( (_textureWidth!=0) && (_textureHeight!=0) && (_internalFormat!=0) )