From Wojciech Lewandowski, "Here are my changes:

- osg::Texture sets GL_MAX_TEXTURE_LEVEL if image uses fewer mipmaps than
number from computeNumberOfMipmaps (and it works!)
- DDS fix to read only available mipmaps
- DDS fixes to read / save 3D textures with mipmaps ( packing == 1 is
required)
- Few cosmetic DDS modifications and comments to make code cleaner (I hope)

Added _isTextureMaxLevelSupported variable to texture extensions. It
could be removed if OSG requires OpenGL version 1.2 by default.

Added simple ComputeImageSizeInBytes function in DDSReaderWrites. In
my opinion it would be better if similar static method was defined for
Image. Then it could be used not only in DDS but other modules as well (I
noticed that Texture/Texture2D do similar computations).

Also attached is an example test.osg model with DDS without last mipmaps to
demonstrate the problem. When loaded into Viewer with current code and moved
far away, so that cube occupies 4 pixels, cube becomes red due to the issue
I described in earlier post. When you patch DDS reader writer with attched
code but no osg::Texture yet, cube becomes blank (at least on my
Windows/NVidia)  When you also merge osg::Texture patch cube will look right
and mipmaps will be correct."
This commit is contained in:
Robert Osfield
2009-06-19 11:55:52 +00:00
parent 9d792c279b
commit 85bb6b327d
3 changed files with 126 additions and 159 deletions

View File

@@ -621,6 +621,9 @@ class OSG_EXPORT Texture : public osg::StateAttribute
void setShadowAmbientSupported(bool flag) { _isShadowAmbientSupported = flag; }
bool isShadowAmbientSupported() const { return _isShadowAmbientSupported; }
void setTextureMaxLevelSupported(bool flag) { _isTextureMaxLevelSupported = flag; }
bool isTextureMaxLevelSupported() const { return _isTextureMaxLevelSupported; }
void setMaxTextureSize(GLint maxsize) { _maxTextureSize=maxsize; }
GLint maxTextureSize() const { return _maxTextureSize; }
@@ -667,6 +670,7 @@ class OSG_EXPORT Texture : public osg::StateAttribute
bool _isNonPowerOfTwoTextureMipMappedSupported;
bool _isNonPowerOfTwoTextureNonMipMappedSupported;
bool _isTextureIntegerEXTSupported;
bool _isTextureMaxLevelSupported;
GLint _maxTextureSize;
GLint _numTextureUnits;