Show
Ignore:
Timestamp:
10/01/09 22:19:42 (5 years ago)
Author:
robert
Message:

Introduced new BufferObject? design + implementation in preperation of implementing a pool system for buffer objects

Files:
1 modified

Legend:

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

    r10596 r10600  
    1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield  
     1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
    22 * 
    33 * This library is open source and may be redistributed and/or modified under   
     
    291291    } 
    292292 
    293     unsigned char* dataMinusOffset = 0; 
    294     unsigned char* dataPlusOffset = 0; 
    295  
    296     const PixelBufferObject* pbo = image->getPixelBufferObject(); 
    297     if (pbo && pbo->isPBOSupported(contextID)) 
     293    const unsigned char* dataPtr = image->data(); 
     294    GLBufferObject* pbo = image->getOrCreateGLBufferObject(contextID); 
     295    if (pbo) 
    298296    { 
    299297        state.bindPixelBufferObject(pbo); 
    300         dataMinusOffset = image->data(); 
    301         dataPlusOffset = reinterpret_cast<unsigned char*>(pbo->offset()); 
    302     } 
    303     else 
    304     { 
    305         pbo = 0; 
     298        dataPtr = reinterpret_cast<unsigned char*>(pbo->getOffset(image->getBufferIndex())); 
    306299    } 
    307300 
     
    311304          image->s(), image->t(), 0, 
    312305          image->getImageSizeInBytes(),  
    313           image->data() - dataMinusOffset + dataPlusOffset);                 
     306          dataPtr); 
    314307    } 
    315308    else 
     
    319312          (GLenum)image->getPixelFormat(), 
    320313          (GLenum)image->getDataType(), 
    321           image->data() - dataMinusOffset + dataPlusOffset ); 
     314          dataPtr ); 
    322315    } 
    323316     
     
    366359#ifdef DO_TIMING 
    367360    osg::Timer_t start_tick = osg::Timer::instance()->tick(); 
    368     osg::notify(osg::NOTICE)<<"glTexSubImage2D pixelFormat = "<<std::hex<<image->getPixelFormat()<<std::dec<<std::endl; 
     361    osg::notify(osg::NOTICE)<<"TextureRectangle::apply pixelFormat = "<<std::hex<<image->getPixelFormat()<<std::dec<<std::endl; 
    369362#endif 
    370     unsigned char* dataMinusOffset = 0; 
    371     unsigned char* dataPlusOffset = 0; 
    372  
    373     const PixelBufferObject* pbo = image->getPixelBufferObject(); 
    374     if (pbo && pbo->isPBOSupported(contextID)) 
     363    const unsigned char* dataPtr = image->data(); 
     364    GLBufferObject* pbo = image->getOrCreateGLBufferObject(contextID); 
     365    if (pbo) 
    375366    { 
    376367        state.bindPixelBufferObject(pbo); 
    377         dataMinusOffset = image->data(); 
    378         dataPlusOffset = reinterpret_cast<unsigned char*>(pbo->offset()); // -dataMinusOffset+dataPlusOffset 
    379  
     368        dataPtr = reinterpret_cast<unsigned char*>(pbo->getOffset(image->getBufferIndex())); 
    380369#ifdef DO_TIMING 
    381370        osg::notify(osg::NOTICE)<<"after PBO "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl; 
    382371#endif 
    383  
    384372    } 
    385373    else 
    386374    { 
    387         pbo = 0; 
     375        osg::notify(osg::NOTICE)<<"    no PixelBufferObject "<<image->getBufferObject()<<", "<<image->getPixelBufferObject()<<" pbo="<<pbo<<std::endl; 
    388376    } 
    389377     
     
    396384          (GLenum)image->getPixelFormat(), 
    397385          (GLenum)image->getDataType(), 
    398           image->data() - dataMinusOffset + dataPlusOffset);                 
     386          dataPtr); 
    399387    } 
    400388    else 
     
    405393          (GLenum)image->getPixelFormat(), 
    406394          (GLenum)image->getDataType(), 
    407           image->data() - dataMinusOffset + dataPlusOffset  ); 
     395          dataPtr); 
    408396    } 
    409397 
     
    416404    osg::notify(osg::NOTICE)<<"glTexSubImage2D "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl; 
    417405#endif 
    418      
    419406} 
    420407