Changeset 12850

Show
Ignore:
Timestamp:
10/26/11 11:34:50 (3 years ago)
Author:
robert
Message:

Implement a simply attempt at detecting when the pixel format needs to be swapped.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/vnc/ReaderWriterVNC.cpp

    r12292 r12850  
    9090                        if(i) 
    9191                        { 
    92                             OSG_NOTICE<<"Handling "<<i<<" messages"<<std::endl; 
     92                            OSG_INFO<<"VNC Handling "<<i<<" messages"<<std::endl; 
    9393                         
    9494                            if(!HandleRFBServerMessage(_client)) 
     
    261261    osg::Image* image = (osg::Image*)(rfbClientGetClientData(client, 0)); 
    262262     
    263     int width=client->width; 
    264     int height=client->height; 
    265     int depth=client->format.bitsPerPixel; 
     263    int width = client->width; 
     264    int height = client->height; 
     265    int depth = client->format.bitsPerPixel; 
    266266 
    267267    OSG_NOTICE<<"resize "<<width<<", "<<height<<", "<<depth<<" image = "<<image<<std::endl; 
    268  
    269     image->allocateImage(width,height,1,GL_RGBA,GL_UNSIGNED_BYTE); 
     268    PrintPixelFormat(&(client->format)); 
     269 
     270    bool swap = client->format.redShift!=0; 
     271    GLenum gl_pixelFormat = swap ? GL_BGRA : GL_RGBA; 
     272 
     273    image->allocateImage(width, height, 1, gl_pixelFormat, GL_UNSIGNED_BYTE); 
     274    image->setInternalTextureFormat(GL_RGBA); 
     275 
     276 
    270277     
    271278    client->frameBuffer= (uint8_t*)(image->data());