wined3d: Clamp material power to 128.0.

This commit is contained in:
Stefan Dösinger 2007-06-15 22:38:14 +02:00 committed by Alexandre Julliard
parent c2cf60fcee
commit 4f8eb6a32e
2 changed files with 34 additions and 1 deletions

View File

@ -172,6 +172,7 @@ static void LightTest(void)
BOOL bEnabled = FALSE; BOOL bEnabled = FALSE;
float one = 1.0f; float one = 1.0f;
float zero= 0.0f; float zero= 0.0f;
D3DMATERIAL7 mat;
/* Set a few lights with funky indices. */ /* Set a few lights with funky indices. */
memset(&light, 0, sizeof(light)); memset(&light, 0, sizeof(light));
@ -315,6 +316,26 @@ static void LightTest(void)
light.dvAttenuation0 = -1.0; light.dvAttenuation0 = -1.0;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light); rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
ok(rc==D3D_OK, "SetLight returned: %x\n", rc); ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
memset(&mat, 0, sizeof(mat));
rc = IDirect3DDevice7_SetMaterial(lpD3DDevice, &mat);
ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial returned: %x\n", rc);
mat.power = 129.0;
rc = IDirect3DDevice7_SetMaterial(lpD3DDevice, &mat);
ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial(power = 129.0) returned: %x\n", rc);
memset(&mat, 0, sizeof(mat));
rc = IDirect3DDevice7_GetMaterial(lpD3DDevice, &mat);
ok(rc == D3D_OK, "IDirect3DDevice7_GetMaterial returned: %x\n", rc);
ok(mat.power == 129, "Returned power is %f\n", mat.power);
mat.power = -1.0;
rc = IDirect3DDevice7_SetMaterial(lpD3DDevice, &mat);
ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial(power = -1.0) returned: %x\n", rc);
memset(&mat, 0, sizeof(mat));
rc = IDirect3DDevice7_GetMaterial(lpD3DDevice, &mat);
ok(rc == D3D_OK, "IDirect3DDevice7_GetMaterial returned: %x\n", rc);
ok(mat.power == -1, "Returned power is %f\n", mat.power);
} }
static void ProcessVerticesTest(void) static void ProcessVerticesTest(void)

View File

@ -509,8 +509,20 @@ state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) { if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
checkGLcall("glMaterialfv"); checkGLcall("glMaterialfv");
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, stateblock->material.Power);
if(stateblock->material.Power > 128.0) {
/* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
* and 128.0, although in d3d neither -1 nor 129 produce an error. For values > 128 clamp
* them, since 128 results in a hardly visible specular highlight, so it should be safe to
* to clamp to 128
*/
WARN("Material power > 128\n");
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 128.0);
} else {
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, stateblock->material.Power);
}
checkGLcall("glMaterialf(GL_SHININESS"); checkGLcall("glMaterialf(GL_SHININESS");
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
glEnable(GL_COLOR_SUM_EXT); glEnable(GL_COLOR_SUM_EXT);
} else { } else {