wined3d: Move WINED3DRS_COLORVERTEX to the state table.

This commit is contained in:
Stefan Dösinger 2006-12-10 22:44:18 +01:00 committed by Alexandre Julliard
parent 0c305a3492
commit 81a1dce0cb
2 changed files with 45 additions and 45 deletions

View File

@ -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 :

View File

@ -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 },