mirror of https://github.com/aap/librw.git
fixed ztest on d3d9; texture refcounting in matfx
This commit is contained in:
parent
eb49dd007c
commit
7cea137baf
|
@ -246,6 +246,36 @@ resetD3d9Device(void)
|
||||||
|
|
||||||
// RW render state
|
// RW render state
|
||||||
|
|
||||||
|
static void
|
||||||
|
setDepthTest(bool32 enable)
|
||||||
|
{
|
||||||
|
if(rwStateCache.ztest != enable){
|
||||||
|
rwStateCache.ztest = enable;
|
||||||
|
if(rwStateCache.zwrite && !enable){
|
||||||
|
// If we still want to write, enable but set mode to always
|
||||||
|
setRenderState(D3DRS_ZENABLE, TRUE);
|
||||||
|
setRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
|
||||||
|
}else{
|
||||||
|
setRenderState(D3DRS_ZENABLE, rwStateCache.ztest);
|
||||||
|
setRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setDepthWrite(bool32 enable)
|
||||||
|
{
|
||||||
|
if(rwStateCache.zwrite != enable){
|
||||||
|
rwStateCache.zwrite = enable;
|
||||||
|
if(enable && !rwStateCache.ztest){
|
||||||
|
// Have to switch on ztest so writing can work
|
||||||
|
setRenderState(D3DRS_ZENABLE, TRUE);
|
||||||
|
setRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
|
||||||
|
}
|
||||||
|
setRenderState(D3DRS_ZWRITEENABLE, rwStateCache.zwrite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setVertexAlpha(bool32 enable)
|
setVertexAlpha(bool32 enable)
|
||||||
{
|
{
|
||||||
|
@ -415,16 +445,10 @@ setRwRenderState(int32 state, void *pvalue)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ZTESTENABLE:
|
case ZTESTENABLE:
|
||||||
if(rwStateCache.ztest != bval){
|
setDepthTest(bval);
|
||||||
rwStateCache.ztest = bval;
|
|
||||||
setRenderState(D3DRS_ZENABLE, rwStateCache.ztest);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ZWRITEENABLE:
|
case ZWRITEENABLE:
|
||||||
if(rwStateCache.zwrite != bval){
|
setDepthWrite(bval);
|
||||||
rwStateCache.zwrite = bval;
|
|
||||||
setRenderState(D3DRS_ZWRITEENABLE, rwStateCache.zwrite);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case FOGENABLE:
|
case FOGENABLE:
|
||||||
if(rwStateCache.fogenable != bval){
|
if(rwStateCache.fogenable != bval){
|
||||||
|
|
|
@ -159,8 +159,12 @@ void
|
||||||
MatFX::setBumpTexture(Texture *t)
|
MatFX::setBumpTexture(Texture *t)
|
||||||
{
|
{
|
||||||
int32 i = this->getEffectIndex(BUMPMAP);
|
int32 i = this->getEffectIndex(BUMPMAP);
|
||||||
if(i >= 0)
|
if(i >= 0){
|
||||||
|
if(this->fx[i].bump.tex)
|
||||||
|
this->fx[i].bump.tex->destroy();
|
||||||
this->fx[i].bump.tex = t;
|
this->fx[i].bump.tex = t;
|
||||||
|
t->refCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -193,8 +197,12 @@ void
|
||||||
MatFX::setEnvTexture(Texture *t)
|
MatFX::setEnvTexture(Texture *t)
|
||||||
{
|
{
|
||||||
int32 i = this->getEffectIndex(ENVMAP);
|
int32 i = this->getEffectIndex(ENVMAP);
|
||||||
if(i >= 0)
|
if(i >= 0){
|
||||||
|
if(this->fx[i].env.tex)
|
||||||
|
this->fx[i].env.tex->destroy();
|
||||||
this->fx[i].env.tex = t;
|
this->fx[i].env.tex = t;
|
||||||
|
t->refCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -245,8 +253,12 @@ void
|
||||||
MatFX::setDualTexture(Texture *t)
|
MatFX::setDualTexture(Texture *t)
|
||||||
{
|
{
|
||||||
int32 i = this->getEffectIndex(DUAL);
|
int32 i = this->getEffectIndex(DUAL);
|
||||||
if(i >= 0)
|
if(i >= 0){
|
||||||
|
if(this->fx[i].dual.tex)
|
||||||
|
this->fx[i].dual.tex->destroy();
|
||||||
this->fx[i].dual.tex = t;
|
this->fx[i].dual.tex = t;
|
||||||
|
t->refCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue