Module: wine Branch: master Commit: fd15b8d0643caee864d7fff5c0d557e220237881 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=fd15b8d0643caee864d7fff5...
Author: Jan Zerebecki jan.wine@zerebecki.de Date: Fri Aug 25 16:28:34 2006 +0200
wined3d: Use a common function for all D3DCMPFUNC -> GLenum conversions.
---
dlls/wined3d/device.c | 40 ++++++++++------------------------------ dlls/wined3d/utils.c | 4 ++-- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 13 insertions(+), 33 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 3c2f9ea..c6a2af5 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3325,9 +3325,11 @@ static void renderstate_stencil(IWineD3D if( This->stateBlock->set.renderState[WINED3DRS_TWOSIDEDSTENCILMODE] ) twosided_enable = This->stateBlock->renderState[WINED3DRS_TWOSIDEDSTENCILMODE]; if( This->stateBlock->set.renderState[WINED3DRS_STENCILFUNC] ) - func = StencilFunc(This->stateBlock->renderState[WINED3DRS_STENCILFUNC]); + if( !( func = CompareFunc(This->stateBlock->renderState[WINED3DRS_STENCILFUNC]) ) ) + func = GL_ALWAYS; if( This->stateBlock->set.renderState[WINED3DRS_CCW_STENCILFUNC] ) - func_ccw = StencilFunc(This->stateBlock->renderState[WINED3DRS_CCW_STENCILFUNC]); + if( !( func_ccw = CompareFunc(This->stateBlock->renderState[WINED3DRS_CCW_STENCILFUNC]) ) ) + func = GL_ALWAYS; if( This->stateBlock->set.renderState[WINED3DRS_STENCILREF] ) ref = This->stateBlock->renderState[WINED3DRS_STENCILREF]; if( This->stateBlock->set.renderState[WINED3DRS_STENCILMASK] ) @@ -3353,10 +3355,12 @@ static void renderstate_stencil(IWineD3D twosided_enable = Value; break; case WINED3DRS_STENCILFUNC : - func = StencilFunc(Value); + if( !( func = CompareFunc(Value) ) ) + func = GL_ALWAYS; break; case WINED3DRS_CCW_STENCILFUNC : - func_ccw = StencilFunc(Value); + if( !( func_ccw = CompareFunc(Value) ) ) + func_ccw = GL_ALWAYS; break; case WINED3DRS_STENCILREF : ref = Value; @@ -3560,20 +3564,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl
case WINED3DRS_ZFUNC : { - int glParm = 0; + int glParm = CompareFunc(Value);
- switch ((D3DCMPFUNC) Value) { - case D3DCMP_NEVER: glParm=GL_NEVER; break; - case D3DCMP_LESS: glParm=GL_LESS; break; - case D3DCMP_EQUAL: glParm=GL_EQUAL; break; - case D3DCMP_LESSEQUAL: glParm=GL_LEQUAL; break; - case D3DCMP_GREATER: glParm=GL_GREATER; break; - case D3DCMP_NOTEQUAL: glParm=GL_NOTEQUAL; break; - case D3DCMP_GREATEREQUAL: glParm=GL_GEQUAL; break; - case D3DCMP_ALWAYS: glParm=GL_ALWAYS; break; - default: - FIXME("Unrecognized/Unhandled D3DCMPFUNC value %ld\n", Value); - } if(glParm) { glDepthFunc(glParm); checkGLcall("glDepthFunc"); @@ -3676,19 +3668,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl ref = 0.0; } else { ref = ((float) This->stateBlock->renderState[WINED3DRS_ALPHAREF]) / 255.0f; - - switch ((D3DCMPFUNC) This->stateBlock->renderState[WINED3DRS_ALPHAFUNC]) { - case D3DCMP_NEVER: glParm = GL_NEVER; break; - case D3DCMP_LESS: glParm = GL_LESS; break; - case D3DCMP_EQUAL: glParm = GL_EQUAL; break; - case D3DCMP_LESSEQUAL: glParm = GL_LEQUAL; break; - case D3DCMP_GREATER: glParm = GL_GREATER; break; - case D3DCMP_NOTEQUAL: glParm = GL_NOTEQUAL; break; - case D3DCMP_GREATEREQUAL: glParm = GL_GEQUAL; break; - case D3DCMP_ALWAYS: glParm = GL_ALWAYS; break; - default: - FIXME("Unrecognized/Unhandled D3DCMPFUNC value %ld\n", This->stateBlock->renderState[WINED3DRS_ALPHAFUNC]); - } + glParm = CompareFunc(This->stateBlock->renderState[WINED3DRS_ALPHAFUNC]); } if(glParm) { This->alphafunc = glParm; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index debd8a3..48b18bd 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -665,7 +665,7 @@ GLenum StencilOp(DWORD op) { } }
-GLenum StencilFunc(DWORD func) { +GLenum CompareFunc(DWORD func) { switch ((D3DCMPFUNC)func) { case D3DCMP_NEVER : return GL_NEVER; case D3DCMP_LESS : return GL_LESS; @@ -677,7 +677,7 @@ GLenum StencilFunc(DWORD func) { case D3DCMP_ALWAYS : return GL_ALWAYS; default: FIXME("Unrecognized D3DCMPFUNC value %ld\n", func); - return GL_ALWAYS; + return 0; } }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index cfb8a7d..bc8a9b5 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1244,7 +1244,7 @@ const char* debug_d3dpool(WINED3DPOOL po
/* Routines for GL <-> D3D values */ GLenum StencilOp(DWORD op); -GLenum StencilFunc(DWORD func); +GLenum CompareFunc(DWORD func); void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3); void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx); void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords);