Module: wine Branch: master Commit: 8c9c084004356d9605c33ca013192a395dce8127 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8c9c084004356d9605c33ca013...
Author: Stefan Dösinger stefan@codeweavers.com Date: Tue Aug 21 18:05:27 2007 +0200
wined3d: Use 0/0/0 as normal if no normal is supplied.
---
dlls/wined3d/drawprim.c | 2 +- dlls/wined3d/state.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 3b45db3..0cc6789 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -350,7 +350,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
/* Default settings for data that is not passed */ if (sd->u.s.normal.lpData == NULL) { - glNormal3f(0, 0, 1); + glNormal3f(0, 0, 0); } if(sd->u.s.diffuse.lpData == NULL) { glColor4f(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 4b38e40..fe25e4b 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1196,7 +1196,16 @@ static void state_zbias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - if (stateblock->renderState[WINED3DRS_NORMALIZENORMALS]) { + if(isStateDirty(context, STATE_VDECL)) { + return; + } + /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor + * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division + * by zero and is not properly defined in opengl, so avoid it + */ + if (stateblock->renderState[WINED3DRS_NORMALIZENORMALS] && ( + stateblock->wineD3DDevice->strided_streams.u.s.normal.lpData || + stateblock->wineD3DDevice->strided_streams.u.s.normal.VBO)) { glEnable(GL_NORMALIZE); checkGLcall("glEnable(GL_NORMALIZE);"); } else { @@ -3031,8 +3040,8 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVerte checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
} else { - glNormal3f(0, 0, 1); - checkGLcall("glNormal3f(0, 0, 1)"); + glNormal3f(0, 0, 0); + checkGLcall("glNormal3f(0, 0, 0)"); }
/* Diffuse Colour --------------------------------------------*/ @@ -3307,6 +3316,9 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, W if(context->last_was_vshader && !isStateDirty(context, STATE_RENDER(WINED3DRS_CLIPPLANEENABLE))) { state_clipping(STATE_RENDER(WINED3DRS_CLIPPLANEENABLE), stateblock, context); } + if(!isStateDirty(context, STATE_RENDER(WINED3DRS_NORMALIZENORMALS))) { + state_normalize(STATE_RENDER(WINED3DRS_NORMALIZENORMALS), stateblock, context); + } } else { /* We compile the shader here because we need the vertex declaration * in order to determine if we need to do any swizzling for D3DCOLOR