Fixes to BlendFunc - adding missing ZERO handling.

Improved handling of alpha values in DXT1 compression.
This commit is contained in:
Robert Osfield 2003-04-18 19:46:46 +00:00
parent bc8bd29646
commit 1cf0be9963
3 changed files with 38 additions and 5 deletions

View File

@ -247,6 +247,7 @@ void State::apply(const StateSet* dstate)
apply();
}
if (_reportGLErrors) checkGLErrors("end of State::apply(StateSet*)");
}
void State::apply()
@ -271,6 +272,8 @@ void State::apply()
if (unit<_textureAttributeMapList.size()) applyAttributeMap(_textureAttributeMapList[unit]);
}
}
if (_reportGLErrors) checkGLErrors("end of State::apply()");
}
void State::haveAppliedMode(StateAttribute::GLMode mode,StateAttribute::GLModeValue value)

View File

@ -133,6 +133,8 @@ osg::Image* ReadDDSFile(const char *filename)
{
osg::Image* osgImage = new osg::Image();
osgImage->setFileName(filename);
DDSURFACEDESC2 ddsd;
char filecode[4];
@ -192,11 +194,20 @@ osg::Image* ReadDDSFile(const char *filename)
// Compressed formats.
else if(ddsd.ddpfPixelFormat.dwFlags & DDPF_FOURCC)
{
bool usingAlpha = ddsd.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS;
switch(ddsd.ddpfPixelFormat.dwFourCC)
{
case FOURCC_DXT1:
if (usingAlpha)
{
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
pixelFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
}
else
{
internalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
pixelFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
}
break;
case FOURCC_DXT3:
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
@ -230,8 +241,26 @@ osg::Image* ReadDDSFile(const char *filename)
{
// Now set mipmap data (offsets into image raw data).
osg::Image::MipmapDataType mipmaps;
// Number of offsets in osg is one less than num_mipmaps
// because it's assumed that first offset is 0.
//This is to complete mipmap sequence until level Nx1
//debugging messages
float power2_s = logf((float)s)/logf((float)2);
float power2_t = logf((float)t)/logf((float)2);
osg::notify(osg::INFO) << "ReadDDSFile info : ddsd.dwMipMapCount = "<<ddsd.dwMipMapCount<<std::endl;
osg::notify(osg::INFO) << "ReadDDSFile info : s = "<<s<<std::endl;
osg::notify(osg::INFO) << "ReadDDSFile info : t = "<<t<<std::endl;
osg::notify(osg::INFO) << "ReadDDSFile info : power2_s="<<power2_s<<std::endl;
osg::notify(osg::INFO) << "ReadDDSFile info : power2_t="<<power2_t<<std::endl;
//Alberto's fix, which I can't quite figure out why its needed..
// int prop = (int)(s>=t ? (s/t) : (t/s));
// prop = (int)(log(prop)/log(2));
// mipmaps.resize(ddsd.dwMipMapCount+prop);
mipmaps.resize(ddsd.dwMipMapCount-1);
// Handle compressed mipmaps.

View File

@ -82,6 +82,7 @@ bool BlendFunc_matchModeStr(const char* str,int& mode)
else if (strcmp(str,"SRC_ALPHA")==0) mode = BlendFunc::SRC_ALPHA;
else if (strcmp(str,"SRC_ALPHA_SATURATE")==0) mode = BlendFunc::SRC_ALPHA_SATURATE;
else if (strcmp(str,"SRC_COLOR")==0) mode = BlendFunc::SRC_COLOR;
else if (strcmp(str,"ZERO")==0) mode = BlendFunc::ZERO;
else return false;
return true;