Commit 2f4b9e42 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Move material applying to the state table.

parent e84158f5
......@@ -2697,37 +2697,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONS
return WINED3D_OK;
}
ENTER_GL();
TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g,
pMaterial->Diffuse.b, pMaterial->Diffuse.a);
TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g,
pMaterial->Ambient.b, pMaterial->Ambient.a);
TRACE("(%p) : Specular (%f,%f,%f,%f)\n", This, pMaterial->Specular.r, pMaterial->Specular.g,
pMaterial->Specular.b, pMaterial->Specular.a);
TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", This, pMaterial->Emissive.r, pMaterial->Emissive.g,
pMaterial->Emissive.b, pMaterial->Emissive.a);
TRACE("(%p) : Power (%f)\n", This, pMaterial->Power);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*) &This->updateStateBlock->material.Ambient);
checkGLcall("glMaterialfv(GL_AMBIENT)");
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*) &This->updateStateBlock->material.Diffuse);
checkGLcall("glMaterialfv(GL_DIFFUSE)");
/* Only change material color if specular is enabled, otherwise it is set to black */
if (This->stateBlock->renderState[WINED3DRS_SPECULARENABLE]) {
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &This->updateStateBlock->material.Specular);
checkGLcall("glMaterialfv(GL_SPECULAR");
} else {
float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
checkGLcall("glMaterialfv(GL_SPECULAR");
}
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float*) &This->updateStateBlock->material.Emissive);
checkGLcall("glMaterialfv(GL_EMISSION)");
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, This->updateStateBlock->material.Power);
checkGLcall("glMaterialf(GL_SHININESS");
LEAVE_GL();
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_MATERIAL);
return WINED3D_OK;
}
......
......@@ -505,11 +505,12 @@ state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
* whether WINED3DRS_SPECULARENABLE is enabled or not.
*/
TRACE("Setting specular enable state\n");
/* TODO: Add to the material setting functions */
TRACE("Setting specular enable state and materials\n");
if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
checkGLcall("glMaterialfv");
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, stateblock->material.Power);
checkGLcall("glMaterialf(GL_SHININESS");
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
glEnable(GL_COLOR_SUM_EXT);
} else {
......@@ -541,6 +542,22 @@ state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
checkGLcall("glFinalCombinerInputNV()");
}
}
TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", stateblock->wineD3DDevice, stateblock->material.Diffuse.r, stateblock->material.Diffuse.g,
stateblock->material.Diffuse.b, stateblock->material.Diffuse.a);
TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", stateblock->wineD3DDevice, stateblock->material.Ambient.r, stateblock->material.Ambient.g,
stateblock->material.Ambient.b, stateblock->material.Ambient.a);
TRACE("(%p) : Specular (%f,%f,%f,%f)\n", stateblock->wineD3DDevice, stateblock->material.Specular.r, stateblock->material.Specular.g,
stateblock->material.Specular.b, stateblock->material.Specular.a);
TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", stateblock->wineD3DDevice, stateblock->material.Emissive.r, stateblock->material.Emissive.g,
stateblock->material.Emissive.b, stateblock->material.Emissive.a);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*) &stateblock->material.Ambient);
checkGLcall("glMaterialfv(GL_AMBIENT)");
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*) &stateblock->material.Diffuse);
checkGLcall("glMaterialfv(GL_DIFFUSE)");
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float*) &stateblock->material.Emissive);
checkGLcall("glMaterialfv(GL_EMISSION)");
}
static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
......@@ -4517,4 +4534,6 @@ const struct StateEntry StateTable[] =
{ /* STATE_CLIPPLANE(29) */ STATE_CLIPPLANE(29), clipplane },
{ /* STATE_CLIPPLANE(30) */ STATE_CLIPPLANE(30), clipplane },
{ /* STATE_CLIPPLANE(31) */ STATE_CLIPPLANE(31), clipplane },
{ /* STATE_MATERIAL */ STATE_RENDER(WINED3DRS_SPECULARENABLE), state_specularenable},
};
......@@ -473,7 +473,9 @@ typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock,
#define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
#define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIPPLANES - 1))
#define STATE_HIGHEST (STATE_CLIPPLANE(MAX_CLIPPLANES - 1))
#define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIPPLANES))
#define STATE_HIGHEST (STATE_MATERIAL)
struct StateEntry
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment