Show
Ignore:
Timestamp:
01/24/12 15:34:02 (3 years ago)
Author:
robert
Message:

Added support for using GL_UNPACK_ROW_LENGTH in conjunction with texture's + osg::Image via new RowLength?
parameter in osg::Image. To support this Image::setData(..) now has a new optional rowLength parameter which
defaults to 0, which provides the original behaviour, Image::setRowLength(int) and int Image::getRowLength() are also provided.

With the introduction of RowLength? support in osg::Image it is now possible to create a sub image where
the t size of the image are smaller than the row length, useful for when you have a large image on the CPU
and which to use a small portion of it on the GPU. However, when these sub images are created the data
within the image is no longer contiguous so data access can no longer assume that all the data is in
one block. The new method Image::isDataContiguous() enables the user to check whether the data is contiguous,
and if not one can either access the data row by row using Image::data(column,row,image) accessor, or use the
new Image::DataIterator? for stepping through each block on memory assocatied with the image.

To support the possibility of non contiguous osg::Image usage of image objects has had to be updated to
check DataContiguous? and handle the case or use access via the DataIerator? or by row by row. To achieve
this a relatively large number of files has had to be modified, in particular the texture classes and
image plugins that doing writing.

Files:
1 modified

Legend:

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

    r12727 r12912  
    18431843 
    18441844    glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking()); 
     1845    unsigned int rowLength = image->getRowLength(); 
    18451846 
    18461847    bool useClientStorage = extensions->isClientStorageSupported() && getClientStorageHint(); 
     
    18921893        PixelStorageModes psm; 
    18931894        psm.pack_alignment = image->getPacking(); 
     1895        psm.pack_row_length = image->getRowLength(); 
    18941896        psm.unpack_alignment = image->getPacking(); 
    18951897 
     
    19001902                        dataPtr); 
    19011903 
     1904        rowLength = 0; 
    19021905    } 
    19031906 
     
    19111914        state.bindPixelBufferObject(pbo); 
    19121915        dataPtr = reinterpret_cast<unsigned char*>(pbo->getOffset(image->getBufferIndex())); 
     1916        rowLength = 0; 
    19131917#ifdef DO_TIMING 
    19141918        OSG_NOTICE<<"after PBO "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl; 
     
    19191923        pbo = 0; 
    19201924    } 
     1925 
     1926    glPixelStorei(GL_UNPACK_ROW_LENGTH,rowLength); 
    19211927 
    19221928    if( !mipmappingRequired || useHardwareMipMapGeneration) 
     
    21092115     
    21102116    glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking()); 
     2117    unsigned int rowLength = image->getRowLength(); 
    21112118     
    21122119    unsigned char* dataPtr = (unsigned char*)image->data(); 
     
    21482155                      inwidth,inheight,image->getDataType(), 
    21492156                      dataPtr); 
     2157 
     2158        rowLength = 0; 
    21502159    } 
    21512160 
     
    21602169        state.bindPixelBufferObject(pbo); 
    21612170        dataPtr = reinterpret_cast<unsigned char*>(pbo->getOffset(image->getBufferIndex())); 
     2171        rowLength = 0; 
    21622172#ifdef DO_TIMING 
    21632173        OSG_NOTICE<<"after PBO "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl; 
     
    21682178        pbo = 0; 
    21692179    } 
     2180 
     2181    glPixelStorei(GL_UNPACK_ROW_LENGTH,rowLength); 
    21702182 
    21712183    if( !mipmappingRequired || useHardwareMipMapGeneration)