From dc9f0ce2418738b850bd8cff15ca2630e4926174 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 4 Nov 2005 15:04:35 +0000 Subject: [PATCH] fix D3D z-bias to work like OpenGL's glDepthRange --- stepmania/src/RageDisplay_D3D.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 067d65d11a..90ce9e3e59 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -61,6 +61,7 @@ D3DPRESENT_PARAMETERS g_d3dpp; int g_ModelMatrixCnt=0; int g_iCurrentTextureIndex = 0; static int g_iActualRefreshRateInHz = 60; +static float g_fZBias = 0; /* Direct3D doesn't associate a palette with textures. * Instead, we load a palette into a slot. We need to keep track @@ -626,6 +627,9 @@ void RageDisplay_D3D::SetViewport(int shift_left, int shift_down) shift_down = int( shift_down * float(p.height) / SCREEN_HEIGHT ); D3DVIEWPORT8 viewData = { shift_left, -shift_down, p.width, p.height, 0.f, 1.f }; + viewData.MinZ = SCALE( g_fZBias, 0.0f, 1.0f, 0.05f, 0.0f ); + viewData.MaxZ = SCALE( g_fZBias, 0.0f, 1.0f, 1.0f, 0.95f ); + g_pd3dDevice->SetViewport( &viewData ); } @@ -1112,7 +1116,8 @@ bool RageDisplay_D3D::IsZWriteEnabled() const void RageDisplay_D3D::SetZBias( float f ) { - g_pd3dDevice->SetRenderState( D3DRS_ZBIAS, (int) SCALE( f, 0.0f, 1.0f, 0, 30 ) ); + g_fZBias = f; + SetViewport( 0, 0 ); }