From 81a1dce0cb8a4871fae60517aaeb832f031e1c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sun, 10 Dec 2006 22:44:18 +0100 Subject: [PATCH] wined3d: Move WINED3DRS_COLORVERTEX to the state table. --- dlls/wined3d/device.c | 41 +----------------------------------- dlls/wined3d/state.c | 49 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 0b2645a6978..42d9308fe23 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3384,51 +3384,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, W case WINED3DRS_VERTEXBLEND : case WINED3DRS_TWEENFACTOR : case WINED3DRS_INDEXEDVERTEXBLENDENABLE : - StateTable[STATE_RENDER(State)].apply(STATE_RENDER(State), This->stateBlock); - break; - case WINED3DRS_COLORVERTEX : case WINED3DRS_DIFFUSEMATERIALSOURCE : case WINED3DRS_SPECULARMATERIALSOURCE : case WINED3DRS_AMBIENTMATERIALSOURCE : case WINED3DRS_EMISSIVEMATERIALSOURCE : - { - GLenum Parm = GL_AMBIENT_AND_DIFFUSE; - - if (This->stateBlock->renderState[WINED3DRS_COLORVERTEX]) { - TRACE("diff %d, amb %d, emis %d, spec %d\n", - This->stateBlock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE], - This->stateBlock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE], - This->stateBlock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE], - This->stateBlock->renderState[WINED3DRS_SPECULARMATERIALSOURCE]); - - if (This->stateBlock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE] == WINED3DMCS_COLOR1) { - if (This->stateBlock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == WINED3DMCS_COLOR1) { - Parm = GL_AMBIENT_AND_DIFFUSE; - } else { - Parm = GL_DIFFUSE; - } - } else if (This->stateBlock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == WINED3DMCS_COLOR1) { - Parm = GL_AMBIENT; - } else if (This->stateBlock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == WINED3DMCS_COLOR1) { - Parm = GL_EMISSION; - } else if (This->stateBlock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == WINED3DMCS_COLOR1) { - Parm = GL_SPECULAR; - } else { - Parm = -1; - } - - if (Parm == -1) { - if (This->tracking_color != DISABLED_TRACKING) This->tracking_color = NEEDS_DISABLE; - } else { - This->tracking_color = NEEDS_TRACKING; - This->tracking_parm = Parm; - } - - } else { - if (This->tracking_color != DISABLED_TRACKING) This->tracking_color = NEEDS_DISABLE; - } - } + StateTable[STATE_RENDER(State)].apply(STATE_RENDER(State), This->stateBlock); break; case WINED3DRS_LINEPATTERN : diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index a2272f6eb0a..24006cdf205 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -810,6 +810,45 @@ static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock) { checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)"); } +/* TODO: Merge with primitive type + init_materials()!! */ +static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock) { + GLenum Parm = GL_AMBIENT_AND_DIFFUSE; + + if (stateblock->renderState[WINED3DRS_COLORVERTEX]) { + TRACE("diff %d, amb %d, emis %d, spec %d\n", + stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE], + stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE], + stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE], + stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE]); + + if (stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE] == D3DMCS_COLOR1) { + if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) { + Parm = GL_AMBIENT_AND_DIFFUSE; + } else { + Parm = GL_DIFFUSE; + } + } else if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) { + Parm = GL_AMBIENT; + } else if (stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == D3DMCS_COLOR1) { + Parm = GL_EMISSION; + } else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == D3DMCS_COLOR1) { + Parm = GL_SPECULAR; + } else { + Parm = -1; + } + + if (Parm == -1) { + if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE; + } else { + stateblock->wineD3DDevice->tracking_color = NEEDS_TRACKING; + stateblock->wineD3DDevice->tracking_parm = Parm; + } + + } else { + if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE; + } +} + const struct StateEntry StateTable[] = { /* State name representative, apply function */ @@ -956,14 +995,14 @@ const struct StateEntry StateTable[] = { /*138, WINED3DRS_EXTENTS */ STATE_RENDER(WINED3DRS_EXTENTS), state_unknown }, { /*139, WINED3DRS_AMBIENT */ STATE_RENDER(WINED3DRS_AMBIENT), state_ambient }, { /*140, WINED3DRS_FOGVERTEXMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog }, - { /*141, WINED3DRS_COLORVERTEX */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_unknown }, + { /*141, WINED3DRS_COLORVERTEX */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat }, { /*142, WINED3DRS_LOCALVIEWER */ STATE_RENDER(WINED3DRS_LOCALVIEWER), state_unknown }, { /*143, WINED3DRS_NORMALIZENORMALS */ STATE_RENDER(WINED3DRS_NORMALIZENORMALS), state_unknown }, { /*144, WINED3DRS_COLORKEYBLENDENABLE */ STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE), state_unknown }, - { /*145, WINED3DRS_DIFFUSEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_unknown }, - { /*146, WINED3DRS_SPECULARMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_unknown }, - { /*147, WINED3DRS_AMBIENTMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_unknown }, - { /*148, WINED3DRS_EMISSIVEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_unknown }, + { /*145, WINED3DRS_DIFFUSEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat }, + { /*146, WINED3DRS_SPECULARMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat }, + { /*147, WINED3DRS_AMBIENTMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat }, + { /*148, WINED3DRS_EMISSIVEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat }, { /*149, Undefined */ 0, state_undefined }, { /*150, Undefined */ 0, state_undefined }, { /*151, WINED3DRS_VERTEXBLEND */ 0, state_nogl },