mirror of
https://github.com/aap/librw.git
synced 2024-11-25 05:05:42 +00:00
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
|
||||
|
||||
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
|
||||
setVertexAlpha(bool32 enable)
|
||||
{
|
||||
@ -415,16 +445,10 @@ setRwRenderState(int32 state, void *pvalue)
|
||||
}
|
||||
break;
|
||||
case ZTESTENABLE:
|
||||
if(rwStateCache.ztest != bval){
|
||||
rwStateCache.ztest = bval;
|
||||
setRenderState(D3DRS_ZENABLE, rwStateCache.ztest);
|
||||
}
|
||||
setDepthTest(bval);
|
||||
break;
|
||||
case ZWRITEENABLE:
|
||||
if(rwStateCache.zwrite != bval){
|
||||
rwStateCache.zwrite = bval;
|
||||
setRenderState(D3DRS_ZWRITEENABLE, rwStateCache.zwrite);
|
||||
}
|
||||
setDepthWrite(bval);
|
||||
break;
|
||||
case FOGENABLE:
|
||||
if(rwStateCache.fogenable != bval){
|
||||
|
@ -159,8 +159,12 @@ void
|
||||
MatFX::setBumpTexture(Texture *t)
|
||||
{
|
||||
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;
|
||||
t->refCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -193,8 +197,12 @@ void
|
||||
MatFX::setEnvTexture(Texture *t)
|
||||
{
|
||||
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;
|
||||
t->refCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -245,8 +253,12 @@ void
|
||||
MatFX::setDualTexture(Texture *t)
|
||||
{
|
||||
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;
|
||||
t->refCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user