diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index bd96418a578..9f9a157d9eb 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -816,7 +816,7 @@ IDirectDrawImpl_GetDisplayMode(IDirectDraw7 *iface, EnterCriticalSection(&ddraw_cs); /* This seems sane */ - if(!DDSD) + if (!DDSD) { LeaveCriticalSection(&ddraw_cs); return DDERR_INVALIDPARAMS; @@ -841,7 +841,7 @@ IDirectDrawImpl_GetDisplayMode(IDirectDraw7 *iface, DDSD->dwSize = Size; DDSD->dwFlags |= DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_PITCH | DDSD_REFRESHRATE; DDSD->dwWidth = Mode.Width; - DDSD->dwHeight = Mode.Height; + DDSD->dwHeight = Mode.Height; DDSD->u2.dwRefreshRate = 60; DDSD->ddsCaps.dwCaps = 0; DDSD->u4.ddpfPixelFormat.dwSize = sizeof(DDSD->u4.ddpfPixelFormat); @@ -1101,7 +1101,7 @@ IDirectDrawImpl_FlipToGDISurface(IDirectDraw7 *iface) * Returns: * Always returns DD_OK * - *****************************************************************************/ + *****************************************************************************/ static HRESULT WINAPI IDirectDrawImpl_WaitForVerticalBlank(IDirectDraw7 *iface, DWORD Flags, @@ -1135,7 +1135,7 @@ IDirectDrawImpl_WaitForVerticalBlank(IDirectDraw7 *iface, * Returns: * Always returns DD_OK * - *****************************************************************************/ + *****************************************************************************/ static HRESULT WINAPI IDirectDrawImpl_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline) { IDirectDrawImpl *This = (IDirectDrawImpl *)iface; @@ -1155,7 +1155,7 @@ static HRESULT WINAPI IDirectDrawImpl_GetScanLine(IDirectDraw7 *iface, DWORD *Sc &Mode); /* Fake the line sweeping of the monitor */ - /* FIXME: We should synchronize with a source to keep the refresh rate */ + /* FIXME: We should synchronize with a source to keep the refresh rate */ *Scanline = This->cur_scanline++; /* Assume 20 scan lines in the vertical blank */ if (This->cur_scanline >= Mode.Height + 20) @@ -1176,7 +1176,7 @@ static HRESULT WINAPI IDirectDrawImpl_GetScanLine(IDirectDraw7 *iface, DWORD *Sc * DDERR_NOEXCLUSIVEMODE or DDERR_EXCLUSIVEMODEALREADYSET * if the state is not correct(See below) * - *****************************************************************************/ + *****************************************************************************/ static HRESULT WINAPI IDirectDrawImpl_TestCooperativeLevel(IDirectDraw7 *iface) { @@ -1187,8 +1187,8 @@ IDirectDrawImpl_TestCooperativeLevel(IDirectDraw7 *iface) EnterCriticalSection(&ddraw_cs); /* Description from MSDN: * For fullscreen apps return DDERR_NOEXCLUSIVEMODE if the user switched - * away from the app with e.g. alt-tab. Windowed apps receive - * DDERR_EXCLUSIVEMODEALREADYSET if another application created a + * away from the app with e.g. alt-tab. Windowed apps receive + * DDERR_EXCLUSIVEMODEALREADYSET if another application created a * DirectDraw object in exclusive mode. DDERR_WRONGMODE is returned, * when the video mode has changed */ @@ -1243,7 +1243,7 @@ IDirectDrawImpl_TestCooperativeLevel(IDirectDraw7 *iface) * DD_OK if the surface was found * DDERR_NOTFOUND if the GDI surface wasn't found * - *****************************************************************************/ + *****************************************************************************/ static HRESULT WINAPI IDirectDrawImpl_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurface7 **GDISurface) @@ -1311,7 +1311,7 @@ IDirectDrawImpl_GetGDISurface(IDirectDraw7 *iface, * DD_OK on success * DDERR_INVALIDPARAMS if the callback wasn't set * - *****************************************************************************/ + *****************************************************************************/ static HRESULT WINAPI IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags, @@ -1886,8 +1886,9 @@ IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This, } else { - if((pDDSD->ddsCaps.dwCaps & DDSCAPS_3DDEVICE ) && - (This->ImplType != SURFACE_OPENGL ) && DefaultSurfaceType == SURFACE_UNKNOWN) + if ((pDDSD->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) + && (This->ImplType != SURFACE_OPENGL) + && DefaultSurfaceType == SURFACE_UNKNOWN) { /* We have to change to OpenGL, * and re-create all WineD3DSurfaces diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 44bfe311231..1457bb67041 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -94,7 +94,7 @@ static inline WORD d3d_fpu_setup(void) } /***************************************************************************** - * IUnknown Methods. Common for Version 1, 2, 3 and 7 + * IUnknown Methods. Common for Version 1, 2, 3 and 7 *****************************************************************************/ /***************************************************************************** @@ -4502,7 +4502,7 @@ IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface, EnterCriticalSection(&ddraw_cs); hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, Stage, &Surf); - if( (hr != D3D_OK) || (!Surf) ) + if( (hr != D3D_OK) || (!Surf) ) { *Texture = NULL; LeaveCriticalSection(&ddraw_cs); @@ -5302,7 +5302,7 @@ IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface, TRACE("(%p)->(%p): Relay!\n", This, Mat); EnterCriticalSection(&ddraw_cs); - /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */ + /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */ hr = IWineD3DDevice_GetMaterial(This->wineD3DDevice, (WINED3DMATERIAL*) Mat); LeaveCriticalSection(&ddraw_cs); diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c index 6d6d30418c5..996c558bad2 100644 --- a/dlls/ddraw/executebuffer.c +++ b/dlls/ddraw/executebuffer.c @@ -317,7 +317,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This, for (i = 0; i < count; i++) { LPD3DSTATE ci = (LPD3DSTATE) instr; - + IDirect3DDevice2_SetRenderState(d3d_device2, ci->u1.drstRenderStateType, ci->u2.dwArg[0]); instr += size; @@ -369,33 +369,33 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This, TRACE("UPDATEEXTENTS "); TRACE("\n"); } - + /* This is where doing Direct3D on top on OpenGL is quite difficult. This method transforms a set of vertices using the CURRENT state (lighting, projection, ...) but does not rasterize them. They will only be put on screen later (with the POINT / LINE and TRIANGLE op-codes). The problem is that you can have a triangle with each point having been transformed using another state... - + In this implementation, I will emulate only ONE thing : each vertex can have its own "WORLD" transformation (this is used in the TWIST.EXE demo of the 5.2 SDK). I suppose that all vertices of the execute buffer use the same state. - + If I find applications that change other states, I will try to do a more 'fine-tuned' state emulation (but I may become quite tricky if it changes a light position in the middle of a triangle). - + In this case, a 'direct' approach (i.e. without using OpenGL, but writing our own 3D rasterizer) would be easier. */ - + /* The current method (with the hypothesis that only the WORLD matrix will change between two points) is like this : - I transform 'manually' all the vertices with the current WORLD matrix and store them in the vertex buffer - during the rasterization phase, the WORLD matrix will be set to the Identity matrix */ - + /* Enough for the moment */ if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORMLIGHT) { unsigned int nb; @@ -439,7 +439,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This, src++; dst++; - + } } else if (ci->dwFlags == D3DPROCESSVERTICES_TRANSFORM) { unsigned int nb; @@ -465,7 +465,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This, dst->u6.specular = src->u5.specular; dst->u7.tu = src->u6.tu; dst->u8.tv = src->u7.tv; - + /* Now, the matrix multiplication */ dst->u1.sx = (src->u1.x * mat._11) + (src->u2.y * mat._21) + (src->u3.z * mat._31) + (1.0 * mat._41); dst->u2.sy = (src->u1.x * mat._12) + (src->u2.y * mat._22) + (src->u3.z * mat._32) + (1.0 * mat._42); @@ -551,7 +551,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This, for (i = 0; i < count; i++) { LPD3DSTATUS ci = (LPD3DSTATUS) instr; - + This->data.dsStatus = *ci; instr += size; @@ -705,7 +705,7 @@ IDirect3DExecuteBufferImpl_Lock(IDirect3DExecuteBuffer *iface, dwSize = lpDesc->dwSize; memset(lpDesc, 0, dwSize); memcpy(lpDesc, &This->desc, dwSize); - + if (TRACE_ON(d3d7)) { TRACE(" Returning description :\n"); _dump_D3DEXECUTEBUFFERDESC(lpDesc); @@ -756,7 +756,7 @@ IDirect3DExecuteBufferImpl_SetExecuteData(IDirect3DExecuteBuffer *iface, /* Get the number of vertices in the execute buffer */ nbvert = This->data.dwVertexCount; - + /* Prepares the transformed vertex buffer */ HeapFree(GetProcessHeap(), 0, This->vertex_data); This->vertex_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nbvert * sizeof(D3DTLVERTEX)); diff --git a/dlls/ddraw/light.c b/dlls/ddraw/light.c index 4a759eb2463..030dcf030c4 100644 --- a/dlls/ddraw/light.c +++ b/dlls/ddraw/light.c @@ -179,17 +179,17 @@ IDirect3DLightImpl_SetLight(IDirect3DLight *iface, if ( (lpLight->dltType == 0) || (lpLight->dltType > D3DLIGHT_PARALLELPOINT) ) return DDERR_INVALIDPARAMS; - + if ( lpLight->dltType == D3DLIGHT_PARALLELPOINT ) - FIXME("D3DLIGHT_PARALLELPOINT no supported\n"); - + FIXME("D3DLIGHT_PARALLELPOINT no supported\n"); + /* Translate D3DLIGH2 structure to D3DLIGHT7 */ light7->dltType = lpLight->dltType; light7->dcvDiffuse = lpLight->dcvColor; - if ((((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_NO_SPECULAR) != 0) + if ((((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_NO_SPECULAR) != 0) light7->dcvSpecular = lpLight->dcvColor; else - light7->dcvSpecular = *(const D3DCOLORVALUE*)zero_value; + light7->dcvSpecular = *(const D3DCOLORVALUE*)zero_value; light7->dcvAmbient = lpLight->dcvColor; light7->dvPosition = lpLight->dvPosition; light7->dvDirection = lpLight->dvDirection; @@ -204,7 +204,7 @@ IDirect3DLightImpl_SetLight(IDirect3DLight *iface, EnterCriticalSection(&ddraw_cs); memcpy(&This->light, lpLight, lpLight->dwSize); if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) { - This->update(This); + This->update(This); } LeaveCriticalSection(&ddraw_cs); return D3D_OK; @@ -274,7 +274,7 @@ void light_activate(IDirect3DLightImpl* This) if (!This->active_viewport || !This->active_viewport->active_device) return; device = This->active_viewport->active_device; - + light_update(This); /* If was not active, activate it */ if ((This->light.dwFlags & D3DLIGHT_ACTIVE) == 0) { @@ -299,7 +299,7 @@ void light_desactivate(IDirect3DLightImpl* This) if (!This->active_viewport || !This->active_viewport->active_device) return; device = This->active_viewport->active_device; - + /* If was not active, activate it */ if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) { IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, This->dwLightIndex, FALSE); diff --git a/dlls/ddraw/parent.c b/dlls/ddraw/parent.c index ec4cfde7cfd..473152ed740 100644 --- a/dlls/ddraw/parent.c +++ b/dlls/ddraw/parent.c @@ -117,8 +117,7 @@ IParentImpl_AddRef(IParent *iface) * The new refcount * *****************************************************************************/ -static ULONG WINAPI -IParentImpl_Release(IParent *iface) +static ULONG WINAPI IParentImpl_Release(IParent *iface) { IParentImpl *This = (IParentImpl *)iface; ULONG ref = InterlockedDecrement(&This->ref); diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index bde2234e9d2..25ee1dfefe8 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -920,9 +920,6 @@ IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This, IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice); } - /* MSDN: - * "This method increments the reference count of the surface being attached." - */ IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)Surf); LeaveCriticalSection(&ddraw_cs); return DD_OK; @@ -1033,7 +1030,7 @@ IDirectDrawSurfaceImpl_AddOverlayDirtyRect(IDirectDrawSurface7 *iface, IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface; TRACE("(%p)->(%p)\n",This,Rect); - /* MSDN says it's not implemented. I could forward it to WineD3D, + /* MSDN says it's not implemented. I could forward it to WineD3D, * then we'd implement it, but I don't think that's a good idea * (Stefan Dösinger) */ diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c index 03ac6732bb1..f5245d0edee 100644 --- a/dlls/ddraw/tests/ddrawmodes.c +++ b/dlls/ddraw/tests/ddrawmodes.c @@ -52,18 +52,17 @@ static void createwindow(void) wc.lpszClassName = "TestWindowClass"; if(!RegisterClassA(&wc)) assert(0); - + hwnd = CreateWindowExA(0, "TestWindowClass", "TestWindowClass", WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, GetModuleHandleA(0), NULL); assert(hwnd != NULL); - + ShowWindow(hwnd, SW_HIDE); UpdateWindow(hwnd); SetFocus(hwnd); - } static BOOL createdirectdraw(void) @@ -91,10 +90,10 @@ static void releasedirectdraw(void) static void adddisplaymode(LPDDSURFACEDESC lpddsd) { - if (!modes) - modes = HeapAlloc(GetProcessHeap(), 0, (modes_size = 2) * sizeof(DDSURFACEDESC)); - if (modes_cnt == modes_size) - modes = HeapReAlloc(GetProcessHeap(), 0, modes, (modes_size *= 2) * sizeof(DDSURFACEDESC)); + if (!modes) + modes = HeapAlloc(GetProcessHeap(), 0, (modes_size = 2) * sizeof(DDSURFACEDESC)); + if (modes_cnt == modes_size) + modes = HeapReAlloc(GetProcessHeap(), 0, modes, (modes_size *= 2) * sizeof(DDSURFACEDESC)); assert(modes); modes[modes_cnt++] = *lpddsd; } @@ -196,7 +195,7 @@ static void createsurface(void) DDSURFACEDESC ddsd; DDSCAPS ddscaps; HRESULT rc; - + ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | @@ -224,7 +223,7 @@ static void testsurface(void) const char* testMsg = "ddraw device context test"; HDC hdc; HRESULT rc; - + rc = IDirectDrawSurface_GetDC(lpDDSBack, &hdc); ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n",rc); SetBkColor(hdc, RGB(0, 0, 255)); @@ -232,7 +231,7 @@ static void testsurface(void) TextOut(hdc, 0, 0, testMsg, lstrlen(testMsg)); IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc); ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc); - + while (1) { rc = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, DDFLIP_WAIT); @@ -353,7 +352,7 @@ static void testcooperativelevels_normal(void) rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW); ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc); - + /* Also set the focus window. Should give an error */ rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW); diff --git a/dlls/ddraw/utils.c b/dlls/ddraw/utils.c index a7cef33ca2c..618dba45b8e 100644 --- a/dlls/ddraw/utils.c +++ b/dlls/ddraw/utils.c @@ -349,7 +349,7 @@ PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat) { - TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n"); + TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n"); if(TRACE_ON(ddraw)) { DDRAW_dump_pixelformat(DDPixelFormat); diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c index c6e346e2294..9b0698903f5 100644 --- a/dlls/ddraw/viewport.c +++ b/dlls/ddraw/viewport.c @@ -84,7 +84,7 @@ void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights) { vp.dvMinZ = This->viewports.vp1.dvMinZ; vp.dvMaxZ = This->viewports.vp1.dvMaxZ; } - + /* And also set the viewport */ IDirect3DDevice7_SetViewport((IDirect3DDevice7 *)This->active_device, &vp); } @@ -657,11 +657,8 @@ IDirect3DViewportImpl_GetBackgroundDepth(IDirect3DViewport3 *iface, * The return value of IDirect3DDevice7::Clear * *****************************************************************************/ -static HRESULT WINAPI -IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, - DWORD dwCount, - D3DRECT *lpRects, - DWORD dwFlags) +static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, + DWORD dwCount, D3DRECT *lpRects, DWORD dwFlags) { IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface; DWORD color = 0x00000000; @@ -679,14 +676,15 @@ IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, EnterCriticalSection(&ddraw_cs); if (dwFlags & D3DCLEAR_TARGET) { if (This->background == NULL) { - ERR(" Trying to clear the color buffer without background material !\n"); - } else { - color = - ((int) ((This->background->mat.u.diffuse.u1.r) * 255) << 16) | - ((int) ((This->background->mat.u.diffuse.u2.g) * 255) << 8) | - ((int) ((This->background->mat.u.diffuse.u3.b) * 255) << 0) | - ((int) ((This->background->mat.u.diffuse.u4.a) * 255) << 24); - } + ERR(" Trying to clear the color buffer without background material !\n"); + } + else + { + color = ((int)((This->background->mat.u.diffuse.u1.r) * 255) << 16) + | ((int) ((This->background->mat.u.diffuse.u2.g) * 255) << 8) + | ((int) ((This->background->mat.u.diffuse.u3.b) * 255) << 0) + | ((int) ((This->background->mat.u.diffuse.u4.a) * 255) << 24); + } } /* Need to temporarily activate viewport to clear it. Previously active one will be restored @@ -729,7 +727,7 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface, IDirect3DLightImpl *lpDirect3DLightImpl = (IDirect3DLightImpl *)lpDirect3DLight; DWORD i = 0; DWORD map = This->map_lights; - + TRACE("(%p)->(%p)\n", This, lpDirect3DLight); EnterCriticalSection(&ddraw_cs); @@ -755,7 +753,7 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface, /* Attach the light to the viewport */ lpDirect3DLightImpl->active_viewport = This; - + /* If active, activate the light */ if (This->active_device != NULL) { lpDirect3DLightImpl->activate(lpDirect3DLightImpl); @@ -785,7 +783,7 @@ IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface, IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface; IDirect3DLightImpl *lpDirect3DLightImpl = (IDirect3DLightImpl *)lpDirect3DLight; IDirect3DLightImpl *cur_light, *prev_light = NULL; - + TRACE("(%p)->(%p)\n", This, lpDirect3DLight); EnterCriticalSection(&ddraw_cs);