fix aniso filter settings

This commit is contained in:
cxgeorge 2002-10-02 02:09:13 +00:00
parent afab5a63dd
commit 11f9acb00a
2 changed files with 43 additions and 38 deletions

View File

@ -727,7 +727,9 @@ dx_init( void) {
scrn.pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE); // disables texturing scrn.pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE); // disables texturing
// Init more Texture State // Init more Texture State
_CurTexMagFilter=_CurTexMinFilter=Texture::FT_nearest; _CurTexMagFilter=(D3DTEXTUREMAGFILTER) 0x0;
_CurTexMinFilter=(D3DTEXTUREMINFILTER) 0x0;
_CurTexMipFilter=(D3DTEXTUREMIPFILTER) 0x0;
_CurTexWrapModeU=_CurTexWrapModeV=Texture::WM_clamp; _CurTexWrapModeU=_CurTexWrapModeV=Texture::WM_clamp;
_CurTexAnisoDegree=1; _CurTexAnisoDegree=1;
@ -3569,25 +3571,29 @@ apply_texture(TextureContext *tc) {
} }
uint aniso_degree=tex->get_anisotropic_degree(); uint aniso_degree=tex->get_anisotropic_degree();
if(_CurTexAnisoDegree != aniso_degree) {
scrn.pD3DDevice->SetTextureStageState(0,D3DTSS_MAXANISOTROPY,aniso_degree);
_CurTexAnisoDegree = aniso_degree;
}
Texture::FilterType ft=tex->get_magfilter(); Texture::FilterType ft=tex->get_magfilter();
D3DTEXTUREMAGFILTER newMagFilter;
if (aniso_degree<=1) { if (aniso_degree<=1) {
if (_CurTexMagFilter!=ft) { newMagFilter=((ft!=Texture::FT_nearest) ? D3DTFG_LINEAR : D3DTFG_POINT);
_CurTexMagFilter = ft; #ifdef _DEBUG
scrn.pD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER,(ft==Texture::FT_nearest)? D3DTFG_POINT : D3DTFG_LINEAR); if((ft!=Texture::FT_linear)&&(ft!=Texture::FT_nearest)) {
#ifdef _DEBUG dxgsg_cat.error() << "MipMap filter type setting for texture magfilter makes no sense, texture: " << tex->get_name() << "\n";
if((ft!=Texture::FT_linear)&&(ft!=Texture::FT_nearest)) {
dxgsg_cat.error() << "MipMap filter type setting for texture magfilter makes no sense, texture: " << tex->get_name() << "\n";
}
#endif
} }
#endif
} else { } else {
if (aniso_degree!=_CurTexAnisoDegree) { newMagFilter=D3DTFG_ANISOTROPIC;
_CurTexAnisoDegree = aniso_degree; }
scrn.pD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_ANISOTROPIC );
scrn.pD3DDevice->SetTextureStageState(0, D3DTSS_MAXANISOTROPY,aniso_degree); if(_CurTexMagFilter!=newMagFilter) {
} _CurTexMagFilter=newMagFilter;
scrn.pD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, newMagFilter);
} }
#ifdef _DEBUG #ifdef _DEBUG
@ -3605,35 +3611,32 @@ apply_texture(TextureContext *tc) {
ft=tex->get_minfilter(); ft=tex->get_minfilter();
if ((ft!=_CurTexMinFilter)||(aniso_degree!=_CurTexAnisoDegree)) { D3DTEXTUREMIPFILTER newMipFilter = PandaToD3DMipType[(DWORD)ft];
#ifdef _DEBUG #ifndef NDEBUG
if(ft > Texture::FT_linear_mipmap_linear) { // sanity check
dxgsg_cat.error() << "Unknown tex filter type for tex: " << tex->get_name() << " filter: "<<(DWORD)ft<<"\n"; extern char *PandaFilterNameStrs[];
return; if((!(dtc->_bHasMipMaps))&&(mipfilter!=D3DTFP_NONE)) {
}
#endif
D3DTEXTUREMINFILTER minfilter = PandaToD3DMinType[(DWORD)ft];
D3DTEXTUREMIPFILTER mipfilter = PandaToD3DMipType[(DWORD)ft];
#ifndef NDEBUG
extern char *PandaFilterNameStrs[];
if((!(dtc->_bHasMipMaps))&&(mipfilter!=D3DTFP_NONE)) {
dxgsg_cat.error() << "Trying to set mipmap filtering for texture with no generated mipmaps!! texname[" << tex->get_name() << "], filter("<<PandaFilterNameStrs[ft]<<")\n"; dxgsg_cat.error() << "Trying to set mipmap filtering for texture with no generated mipmaps!! texname[" << tex->get_name() << "], filter("<<PandaFilterNameStrs[ft]<<")\n";
mipfilter=D3DTFP_NONE; mipfilter=D3DTFP_NONE;
} }
#endif #endif
if (aniso_degree>1) {
minfilter=D3DTFN_ANISOTROPIC;
}
scrn.pD3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, minfilter); D3DTEXTUREMINFILTER newMinFilter = PandaToD3DMinType[(DWORD)ft];
scrn.pD3DDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, mipfilter);
_CurTexMinFilter = ft; if(aniso_degree>=2) {
_CurTexAnisoDegree = aniso_degree; newMinFilter=D3DTFN_ANISOTROPIC;
}
if(newMinFilter!=_CurTexMinFilter) {
_CurTexMinFilter = newMinFilter;
scrn.pD3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, newMinFilter);
}
if(newMipFilter!=_CurTexMipFilter) {
_CurTexMipFilter = newMipFilter;
scrn.pD3DDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, newMipFilter);
} }
// bugbug: does this handle the case of untextured geometry? // bugbug: does this handle the case of untextured geometry?

View File

@ -303,7 +303,9 @@ protected:
// Cur Texture State // Cur Texture State
TextureApplyAttrib::Mode _CurTexBlendMode; TextureApplyAttrib::Mode _CurTexBlendMode;
Texture::FilterType _CurTexMagFilter,_CurTexMinFilter; D3DTEXTUREMAGFILTER _CurTexMagFilter;
D3DTEXTUREMINFILTER _CurTexMinFilter;
D3DTEXTUREMIPFILTER _CurTexMipFilter;
DWORD _CurTexAnisoDegree; DWORD _CurTexAnisoDegree;
Texture::WrapMode _CurTexWrapModeU,_CurTexWrapModeV; Texture::WrapMode _CurTexWrapModeU,_CurTexWrapModeV;