[osg-users] compressed textures (DDS) and texture rectangles

sherman wilcox wilcox.sherman at gmail.com
Sun Sep 2 09:59:49 PDT 2007


OSG doesn't support compressed textures when using texture rectangles, does it?
Earlier today I tried to load some DDS files using the
osg::TextureRectangle....didn't work. Thought it was something I was
doing wrong so I started digging and ran across this comment in
texturerectangle.cpp:

// UH: ignoring compressed for now.

Yep, that was the first clue! Anyway, I hacked in a quick change, just
not sure how robust it is. Here tis:

*********old code************

     // UH: ignoring compressed for now.
     glTexImage2D(target, 0, _internalFormat,
       image->s(), image->t(), 0,
       (GLenum)image->getPixelFormat(),
       (GLenum)image->getDataType(),
       image->data() - dataMinusOffset + dataPlusOffset );


*********new code************
   if(isCompressedInternalFormat(_internalFormat) &&
extensions->isCompressedTexImage2DSupported())
   {
     extensions->glCompressedTexImage2D(target, 0, _internalFormat,
       image->s(), image->t(), 0,
       image->getImageSizeInBytes(),
       image->data() - dataMinusOffset + dataPlusOffset);
   }
   else
   {
     // UH: ignoring compressed for now.
     glTexImage2D(target, 0, _internalFormat,
       image->s(), image->t(), 0,
       (GLenum)image->getPixelFormat(),
       (GLenum)image->getDataType(),
       image->data() - dataMinusOffset + dataPlusOffset );
   }

In my limited testing with DXT5 DDS files, this quick change appears
to work. Admittedly, I didn't spend too much time on this, it's late
and I'm tired. So, if anyone sees a problem or would simply like to
offer suggestions...



More information about the osg-users mailing list