Stefan Dösinger : wined3d: Clamp material power to 128 .0.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jun 26 07:11:42 CDT 2007
Module: wine
Branch: master
Commit: 4f8eb6a32e0cf67842f42c4b5b66e23e9c6a9a77
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4f8eb6a32e0cf67842f42c4b5b66e23e9c6a9a77
Author: Stefan Dösinger <stefandoesinger at gmx.at>
Date: Fri Jun 15 22:38:14 2007 +0200
wined3d: Clamp material power to 128.0.
---
dlls/ddraw/tests/d3d.c | 21 +++++++++++++++++++++
dlls/wined3d/state.c | 14 +++++++++++++-
2 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index e994097..0c69b42 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -172,6 +172,7 @@ static void LightTest(void)
BOOL bEnabled = FALSE;
float one = 1.0f;
float zero= 0.0f;
+ D3DMATERIAL7 mat;
/* Set a few lights with funky indices. */
memset(&light, 0, sizeof(light));
@@ -315,6 +316,26 @@ static void LightTest(void)
light.dvAttenuation0 = -1.0;
rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
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)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index d83e7f7..2a5f67e 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -509,8 +509,20 @@ state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
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);
+
+ 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");
+
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
glEnable(GL_COLOR_SUM_EXT);
} else {
More information about the wine-cvs
mailing list