diff --git a/dlls/ddraw/d3d_private.h b/dlls/ddraw/d3d_private.h index 01a81ead263..67901585fb3 100644 --- a/dlls/ddraw/d3d_private.h +++ b/dlls/ddraw/d3d_private.h @@ -35,12 +35,10 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -typedef struct IDirect3DImpl IDirect3DImpl; typedef struct IDirect3DLightImpl IDirect3DLightImpl; typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl; typedef struct IDirect3DViewportImpl IDirect3DViewportImpl; typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl; -typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl; typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl; #include "ddraw_private.h" @@ -56,30 +54,6 @@ typedef struct STATEBLOCK { DWORD texture_stage_state[MAX_TEXTURES][HIGHEST_TEXTURE_STAGE_STATE]; } STATEBLOCK; -/***************************************************************************** - * IDirect3D implementation structure. - * This is common for interfaces 1, 2, 3 and 7. - */ -struct IDirect3DImpl -{ - ICOM_VFIELD_MULTI(IDirect3D7); - ICOM_VFIELD_MULTI(IDirect3D3); - ICOM_VFIELD_MULTI(IDirect3D2); - ICOM_VFIELD_MULTI(IDirect3D); - DWORD ref; - /* IDirect3D fields */ - IDirectDrawImpl* ddraw; - - /* Used as a callback function to create a texture */ - HRESULT (*create_texture)(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main); - - /* Used as a callback for Devices to tell to the D3D object it's been created */ - HRESULT (*added_device)(IDirect3DImpl *d3d, IDirect3DDeviceImpl *device); - HRESULT (*removed_device)(IDirect3DImpl *d3d, IDirect3DDeviceImpl *device); - - /* This is needed for delayed texture creation and Z buffer blits */ - IDirect3DDeviceImpl *current_device; -}; /***************************************************************************** * IDirect3DLight implementation structure @@ -89,7 +63,7 @@ struct IDirect3DLightImpl ICOM_VFIELD_MULTI(IDirect3DLight); DWORD ref; /* IDirect3DLight fields */ - IDirect3DImpl *d3d; + IDirectDrawImpl *d3d; /* If this light is active for one viewport, put the viewport here */ IDirect3DViewportImpl *active_viewport; @@ -117,7 +91,7 @@ struct IDirect3DMaterialImpl ICOM_VFIELD_MULTI(IDirect3DMaterial); DWORD ref; /* IDirect3DMaterial2 fields */ - IDirect3DImpl *d3d; + IDirectDrawImpl *d3d; IDirect3DDeviceImpl *active_device; D3DMATERIAL mat; @@ -133,7 +107,7 @@ struct IDirect3DViewportImpl ICOM_VFIELD_MULTI(IDirect3DViewport3); DWORD ref; /* IDirect3DViewport fields */ - IDirect3DImpl *d3d; + IDirectDrawImpl *d3d; /* If this viewport is active for one device, put the device here */ IDirect3DDeviceImpl *active_device; @@ -167,7 +141,7 @@ struct IDirect3DExecuteBufferImpl ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer); DWORD ref; /* IDirect3DExecuteBuffer fields */ - IDirect3DImpl *d3d; + IDirectDrawImpl *d3d; IDirect3DDeviceImpl* d3ddev; D3DEXECUTEBUFFERDESC desc; @@ -217,7 +191,7 @@ struct IDirect3DDeviceImpl ICOM_VFIELD_MULTI(IDirect3DDevice); DWORD ref; /* IDirect3DDevice fields */ - IDirect3DImpl *d3d; + IDirectDrawImpl *d3d; IDirectDrawSurfaceImpl *surface; IDirect3DViewportImpl *viewport_list; @@ -270,7 +244,7 @@ struct IDirect3DVertexBufferImpl ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7); ICOM_VFIELD_MULTI(IDirect3DVertexBuffer); DWORD ref; - IDirect3DImpl *d3d; + IDirectDrawImpl *d3d; D3DVERTEXBUFFERDESC desc; LPVOID *vertices; DWORD vertex_buffer_size; diff --git a/dlls/ddraw/d3ddevice/main.c b/dlls/ddraw/d3ddevice/main.c index 46c81aedaf4..25b34baa1ea 100644 --- a/dlls/ddraw/d3ddevice/main.c +++ b/dlls/ddraw/d3ddevice/main.c @@ -318,15 +318,15 @@ Main_IDirect3DDeviceImpl_7_3T_2T_1T_EndScene(LPDIRECT3DDEVICE7 iface) HRESULT WINAPI Main_IDirect3DDeviceImpl_7_3T_2T_1T_GetDirect3D(LPDIRECT3DDEVICE7 iface, - LPDIRECT3D7* lplpDirect3D3) + LPDIRECT3D7* lplpDirect3D7) { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lplpDirect3D3); + TRACE("(%p/%p)->(%p)\n", This, iface, lplpDirect3D7); - *lplpDirect3D3 = ICOM_INTERFACE(This->d3d, IDirect3D7); + *lplpDirect3D7 = ICOM_INTERFACE(This->d3d, IDirect3D7); IDirect3D7_AddRef(ICOM_INTERFACE(This->d3d, IDirect3D7)); - TRACE(" returning interface %p\n", *lplpDirect3D3); + TRACE(" returning interface %p\n", *lplpDirect3D7); return DD_OK; } @@ -812,14 +812,13 @@ Main_IDirect3DDeviceImpl_7_3T_GetTexture(LPDIRECT3DDEVICE7 iface, if (This->current_texture[dwStage] != NULL) { *lpTexture = ICOM_INTERFACE(This->current_texture[dwStage], IDirectDrawSurface7); + IDirectDrawSurface7_AddRef(*lpTexture); } else { *lpTexture = NULL; } TRACE(" returning interface at %p (for implementation at %p).\n", *lpTexture, This->current_texture[dwStage]); - /* Note: should this method increase the reference count for this ?? */ - return DD_OK; } @@ -1559,7 +1558,7 @@ Thunk_IDirect3DDeviceImpl_3_GetDirect3D(LPDIRECT3DDEVICE3 iface, TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lplpDirect3D3); ret = IDirect3DDevice7_GetDirect3D(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), &ret_ptr); - *lplpDirect3D3 = COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D7, IDirect3D3, ret_ptr); + *lplpDirect3D3 = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D3, ret_ptr); TRACE(" returning interface %p\n", *lplpDirect3D3); return ret; } @@ -1574,7 +1573,7 @@ Thunk_IDirect3DDeviceImpl_2_GetDirect3D(LPDIRECT3DDEVICE2 iface, TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lplpDirect3D2); ret = IDirect3DDevice7_GetDirect3D(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), &ret_ptr); - *lplpDirect3D2 = COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D7, IDirect3D2, ret_ptr); + *lplpDirect3D2 = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D2, ret_ptr); TRACE(" returning interface %p\n", *lplpDirect3D2); return ret; } @@ -1589,7 +1588,7 @@ Thunk_IDirect3DDeviceImpl_1_GetDirect3D(LPDIRECT3DDEVICE iface, TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lplpDirect3D); ret = IDirect3DDevice7_GetDirect3D(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface), &ret_ptr); - *lplpDirect3D = COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D7, IDirect3D, ret_ptr); + *lplpDirect3D = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D, ret_ptr); TRACE(" returning interface %p\n", *lplpDirect3D); return ret; } diff --git a/dlls/ddraw/d3ddevice/mesa.c b/dlls/ddraw/d3ddevice/mesa.c index 96cc1681936..ac071f12875 100644 --- a/dlls/ddraw/d3ddevice/mesa.c +++ b/dlls/ddraw/d3ddevice/mesa.c @@ -351,7 +351,7 @@ GL_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface) } /* And warn the D3D object that this device is no longer active... */ - This->d3d->removed_device(This->d3d, This); + This->d3d->d3d_removed_device(This->d3d, This); HeapFree(GetProcessHeap(), 0, This->world_mat); HeapFree(GetProcessHeap(), 0, This->view_mat); @@ -415,19 +415,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, pformat->dwSize = sizeof(DDPIXELFORMAT); pformat->dwFourCC = 0; -#if 0 - /* See argument about the RGBA format for 'packed' texture formats */ - TRACE("Enumerating GL_RGBA unpacked (32)\n"); - pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; - pformat->u1.dwRGBBitCount = 32; - pformat->u2.dwRBitMask = 0xFF000000; - pformat->u3.dwGBitMask = 0x00FF0000; - pformat->u4.dwBBitMask = 0x0000FF00; - pformat->u5.dwRGBAlphaBitMask = 0x000000FF; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; -#endif - TRACE("Enumerating GL_RGBA unpacked (32)\n"); pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; pformat->u1.dwRGBBitCount = 32; @@ -438,7 +425,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; -#if 0 /* Enabling this breaks Tomb Raider 3, need to investigate... */ TRACE("Enumerating GL_RGB unpacked (32)\n"); pformat->dwFlags = DDPF_RGB; pformat->u1.dwRGBBitCount = 32; @@ -448,7 +434,6 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, pformat->u5.dwRGBAlphaBitMask = 0x00000000; if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; -#endif TRACE("Enumerating GL_RGB unpacked (24)\n"); pformat->dwFlags = DDPF_RGB; @@ -508,6 +493,17 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, So basically, forget our OpenGL roots and do not even enumerate our RGBA ones. */ + /* See argument about the RGBA format for 'packed' texture formats */ + TRACE("Enumerating GL_RGBA unpacked (32)\n"); + pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; + pformat->u1.dwRGBBitCount = 32; + pformat->u2.dwRBitMask = 0xFF000000; + pformat->u3.dwGBitMask = 0x00FF0000; + pformat->u4.dwBBitMask = 0x0000FF00; + pformat->u5.dwRGBAlphaBitMask = 0x000000FF; + if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; + if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; + TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (16)\n"); pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; pformat->u1.dwRGBBitCount = 16; @@ -555,7 +551,7 @@ static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, HRESULT -d3ddevice_find(IDirect3DImpl *d3d, +d3ddevice_find(IDirectDrawImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice) { @@ -3079,7 +3075,7 @@ apply_texture_state(IDirect3DDeviceImpl *This) } HRESULT -d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surface) +d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface) { IDirect3DDeviceImpl *object; IDirect3DDeviceGLImpl *gl_object; @@ -3240,7 +3236,7 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa TRACE(" creating implementation at %p.\n", *obj); /* And finally warn D3D that this device is now present */ - object->d3d->added_device(object->d3d, object); + object->d3d->d3d_added_device(object->d3d, object); /* FIXME: Should handle other versions than just 7 */ InitDefaultStateBlock(&object->state_block, 7); diff --git a/dlls/ddraw/d3dexecutebuffer.c b/dlls/ddraw/d3dexecutebuffer.c index 9ff5e1c9046..5e389eff0e9 100644 --- a/dlls/ddraw/d3dexecutebuffer.c +++ b/dlls/ddraw/d3dexecutebuffer.c @@ -661,7 +661,7 @@ ICOM_VTABLE(IDirect3DExecuteBuffer) VTABLE_IDirect3DExecuteBuffer = #endif -HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirect3DImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc) +HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirectDrawImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc) { IDirect3DExecuteBufferImpl* object; diff --git a/dlls/ddraw/d3dlight.c b/dlls/ddraw/d3dlight.c index 0e4a9efc33e..d85a290ba17 100644 --- a/dlls/ddraw/d3dlight.c +++ b/dlls/ddraw/d3dlight.c @@ -214,7 +214,7 @@ ICOM_VTABLE(IDirect3DLight) VTABLE_IDirect3DLight = -HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirect3DImpl *d3d, GLenum light_num) +HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d, GLenum light_num) { IDirect3DLightImpl *object; IDirect3DLightGLImpl *gl_object; diff --git a/dlls/ddraw/d3dmaterial.c b/dlls/ddraw/d3dmaterial.c index efb175d8285..30785f62961 100644 --- a/dlls/ddraw/d3dmaterial.c +++ b/dlls/ddraw/d3dmaterial.c @@ -388,7 +388,7 @@ ICOM_VTABLE(IDirect3DMaterial) VTABLE_IDirect3DMaterial = -HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirect3DImpl *d3d) +HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d) { IDirect3DMaterialImpl *object; diff --git a/dlls/ddraw/d3dtexture.c b/dlls/ddraw/d3dtexture.c index 748ee0e4030..8ad0b775572 100644 --- a/dlls/ddraw/d3dtexture.c +++ b/dlls/ddraw/d3dtexture.c @@ -650,7 +650,7 @@ ICOM_VTABLE(IDirect3DTexture) VTABLE_IDirect3DTexture = #undef XCAST #endif -HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, +HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main) { /* First, initialize the texture vtables... */ diff --git a/dlls/ddraw/d3dvertexbuffer.c b/dlls/ddraw/d3dvertexbuffer.c index 4da4bb06631..d51004b7128 100644 --- a/dlls/ddraw/d3dvertexbuffer.c +++ b/dlls/ddraw/d3dvertexbuffer.c @@ -507,7 +507,7 @@ ICOM_VTABLE(IDirect3DVertexBuffer) VTABLE_IDirect3DVertexBuffer = #undef XCAST #endif -HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags) +HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirectDrawImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags) { IDirect3DVertexBufferImpl *object; static const flag_info flags[] = { diff --git a/dlls/ddraw/d3dviewport.c b/dlls/ddraw/d3dviewport.c index 64231d2f17f..24931640652 100644 --- a/dlls/ddraw/d3dviewport.c +++ b/dlls/ddraw/d3dviewport.c @@ -479,7 +479,7 @@ ICOM_VTABLE(IDirect3DViewport3) VTABLE_IDirect3DViewport3 = -HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirect3DImpl *d3d) +HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d) { IDirect3DViewportImpl *object; diff --git a/dlls/ddraw/ddraw/main.c b/dlls/ddraw/ddraw/main.c index f3c87b03466..2ecd87b87a2 100644 --- a/dlls/ddraw/ddraw/main.c +++ b/dlls/ddraw/ddraw/main.c @@ -185,28 +185,24 @@ HRESULT WINAPI Main_DirectDraw_QueryInterface( IsEqualGUID( &IID_IDirect3D7 , refiid ) ) { if (opengl_initialized) { - IDirect3DImpl *d3d_impl; HRESULT ret_value; - ret_value = direct3d_create(&d3d_impl, This); + ret_value = direct3d_create(This); if (FAILED(ret_value)) return ret_value; if ( IsEqualGUID( &IID_IDirect3D , refiid ) ) { - *obj = ICOM_INTERFACE(d3d_impl, IDirect3D); + *obj = ICOM_INTERFACE(This, IDirect3D); TRACE(" returning Direct3D interface at %p.\n", *obj); } else if ( IsEqualGUID( &IID_IDirect3D2 , refiid ) ) { - *obj = ICOM_INTERFACE(d3d_impl, IDirect3D2); + *obj = ICOM_INTERFACE(This, IDirect3D2); TRACE(" returning Direct3D2 interface at %p.\n", *obj); } else if ( IsEqualGUID( &IID_IDirect3D3 , refiid ) ) { - *obj = ICOM_INTERFACE(d3d_impl, IDirect3D3); + *obj = ICOM_INTERFACE(This, IDirect3D3); TRACE(" returning Direct3D3 interface at %p.\n", *obj); } else { - *obj = ICOM_INTERFACE(d3d_impl, IDirect3D7); + *obj = ICOM_INTERFACE(This, IDirect3D7); TRACE(" returning Direct3D7 interface at %p.\n", *obj); } - - /* And store the D3D object */ - This->d3d = d3d_impl; } else { ERR("Application requests a Direct3D interface but dynamic OpenGL support loading failed !\n"); ERR("(%p)->(%s,%p): no interface\n",This,debugstr_guid(refiid),obj); @@ -384,8 +380,8 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD, hr = This->create_texture(This, &ddsd, ppSurf, pUnkOuter, mipmap_level); if (FAILED(hr)) return hr; - if (This->d3d) This->d3d->create_texture(This->d3d, ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), TRUE, - ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf)); + if (This->d3d_private) This->d3d_create_texture(This, ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf), TRUE, + ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf)); /* Create attached mipmaps if required. */ if (more_mipmaps(&ddsd)) @@ -430,8 +426,8 @@ create_texture(IDirectDrawImpl* This, const DDSURFACEDESC2 *pDDSD, mipmap_impl->mip_main = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf); mipmap_impl->mipmap_level = mipmap_level; - if (This->d3d) This->d3d->create_texture(This->d3d, ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, mipmap), TRUE, - ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf)); + if (This->d3d_private) This->d3d_create_texture(This, ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, mipmap), TRUE, + ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurf)); IDirectDrawSurface7_AddAttachedSurface(prev_mipmap, mipmap); IDirectDrawSurface7_Release(prev_mipmap); diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 2c52efc4103..813ab5cbc95 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -58,6 +58,7 @@ typedef struct IDirectDrawImpl IDirectDrawImpl; typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl; typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl; typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl; +typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl; typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width, DWORD height, LONG pitch, @@ -73,6 +74,10 @@ struct IDirectDrawImpl ICOM_VFIELD_MULTI(IDirectDraw4); ICOM_VFIELD_MULTI(IDirectDraw2); ICOM_VFIELD_MULTI(IDirectDraw); + ICOM_VFIELD_MULTI(IDirect3D7); + ICOM_VFIELD_MULTI(IDirect3D3); + ICOM_VFIELD_MULTI(IDirect3D2); + ICOM_VFIELD_MULTI(IDirect3D); DWORD ref; @@ -159,9 +164,19 @@ struct IDirectDrawImpl void (*free_memory)(IDirectDrawImpl *This, DWORD mem); DWORD total_vidmem, available_vidmem; - /* This is to get the D3D object associated to this DDraw object */ - struct IDirect3DImpl *d3d; - + /* IDirect3D fields */ + LPVOID d3d_private; + + /* Used as a callback function to create a texture */ + HRESULT (*d3d_create_texture)(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main); + + /* Used as a callback for Devices to tell to the D3D object it's been created */ + HRESULT (*d3d_added_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device); + HRESULT (*d3d_removed_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device); + + /* This is needed for delayed texture creation and Z buffer blits */ + IDirect3DDeviceImpl *current_device; + /* This is for the fake mainWindow */ ATOM winclass; PAINTSTRUCT ps; diff --git a/dlls/ddraw/direct3d/main.c b/dlls/ddraw/direct3d/main.c index d6c8aa87bf4..ed3dedfb1ab 100644 --- a/dlls/ddraw/direct3d/main.c +++ b/dlls/ddraw/direct3d/main.c @@ -35,96 +35,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); -HRESULT WINAPI -Main_IDirect3DImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3D7 iface, - REFIID riid, - LPVOID* obp) -{ - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); - - TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obp); - - /* By default, set the object pointer to NULL */ - *obp = NULL; - - if (( IsEqualGUID( &IID_IDirectDraw, riid ) ) || - ( IsEqualGUID (&IID_IDirectDraw2, riid ) ) || - ( IsEqualGUID (&IID_IDirectDraw4, riid ) ) || - ( IsEqualGUID( &IID_IDirectDraw7, riid ) ) - ) { - HRESULT ret; - TRACE(" Creating IDirectDrawX interface by calling DirectDraw function.\n"); - ret = IDirectDraw_QueryInterface(ICOM_INTERFACE(This->ddraw,IDirectDraw), riid, obp); - if (ret == S_OK) { - IDirectDraw_Release(ICOM_INTERFACE(This->ddraw,IDirectDraw)); - IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D)); - } - return ret; - } - if ( IsEqualGUID( &IID_IUnknown, riid ) ) { - IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D)); - *obp = iface; - TRACE(" Creating IUnknown interface at %p.\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3D, riid ) ) { - IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D)); - *obp = ICOM_INTERFACE(This, IDirect3D); - TRACE(" Creating IDirect3D interface %p\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3D2, riid ) ) { - IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D)); - *obp = ICOM_INTERFACE(This, IDirect3D2); - TRACE(" Creating IDirect3D2 interface %p\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3D3, riid ) ) { - IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D)); - *obp = ICOM_INTERFACE(This, IDirect3D3); - TRACE(" Creating IDirect3D3 interface %p\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3D7, riid ) ) { - /* This is not 100 % true as we should not be able to QueryInterface a '7' version from another one. - But well, to factorize the code, why check for application bugs :-) ? - */ - IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D)); - *obp = ICOM_INTERFACE(This, IDirect3D7); - TRACE(" Creating IDirect3D7 interface %p\n", *obp); - return S_OK; - } - FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid)); - return OLE_E_ENUM_NOMORE; -} - -ULONG WINAPI -Main_IDirect3DImpl_7_3T_2T_1T_AddRef(LPDIRECT3D7 iface) -{ - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); - TRACE("(%p/%p)->() incrementing from %lu.\n", This, iface, This->ref); - - return ++(This->ref); -} - -ULONG WINAPI -Main_IDirect3DImpl_7_3T_2T_1T_Release(LPDIRECT3D7 iface) -{ - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); - TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, This->ref); - if (--(This->ref) == 0) { - IDirectDraw_Release(ICOM_INTERFACE(This->ddraw, IDirectDraw)); - HeapFree(GetProcessHeap(), 0, This); - return 0; - } - return This->ref; -} HRESULT WINAPI Main_IDirect3DImpl_1_Initialize(LPDIRECT3D iface, REFIID riid) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface); TRACE("(%p/%p)->(%s) no-op...\n", This, iface, debugstr_guid(riid)); return D3D_OK; } @@ -134,7 +50,7 @@ Main_IDirect3DImpl_3_2T_1T_EnumDevices(LPDIRECT3D3 iface, LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpEnumDevicesCallback, lpUserArg); return D3D_OK; } @@ -144,7 +60,7 @@ Main_IDirect3DImpl_3_2T_1T_CreateLight(LPDIRECT3D3 iface, LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDirect3DLight, pUnkOuter); return D3D_OK; } @@ -154,7 +70,7 @@ Main_IDirect3DImpl_3_2T_1T_CreateMaterial(LPDIRECT3D3 iface, LPDIRECT3DMATERIAL3* lplpDirect3DMaterial3, IUnknown* pUnkOuter) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDirect3DMaterial3, pUnkOuter); return D3D_OK; } @@ -164,7 +80,7 @@ Main_IDirect3DImpl_3_2T_1T_CreateViewport(LPDIRECT3D3 iface, LPDIRECT3DVIEWPORT3* lplpD3DViewport3, IUnknown* pUnkOuter) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpD3DViewport3, pUnkOuter); return D3D_OK; } @@ -174,7 +90,7 @@ Main_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lpD3DFDR) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lpD3DFDR); return D3D_OK; } @@ -185,7 +101,7 @@ Main_IDirect3DImpl_2_CreateDevice(LPDIRECT3D2 iface, LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DDEVICE2* lplpD3DDevice2) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D2, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface); FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice2); return D3D_OK; } @@ -197,7 +113,7 @@ Main_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface, LPDIRECT3DDEVICE3* lplpD3DDevice3, LPUNKNOWN lpUnk) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); FIXME("(%p/%p)->(%s,%p,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice3, lpUnk); return D3D_OK; } @@ -208,7 +124,7 @@ Main_IDirect3DImpl_7_3T_EnumZBufferFormats(LPDIRECT3D7 iface, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext); return D3D_OK; } @@ -216,7 +132,7 @@ Main_IDirect3DImpl_7_3T_EnumZBufferFormats(LPDIRECT3D7 iface, HRESULT WINAPI Main_IDirect3DImpl_7_3T_EvictManagedTextures(LPDIRECT3D7 iface) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); FIXME("(%p/%p)->(): stub!\n", This, iface); return D3D_OK; } @@ -226,7 +142,7 @@ Main_IDirect3DImpl_7_EnumDevices(LPDIRECT3D7 iface, LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, LPVOID lpUserArg) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpEnumDevicesCallback, lpUserArg); return D3D_OK; } @@ -237,7 +153,7 @@ Main_IDirect3DImpl_7_CreateDevice(LPDIRECT3D7 iface, LPDIRECTDRAWSURFACE7 lpDDS, LPDIRECT3DDEVICE7* lplpD3DDevice) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice); return D3D_OK; } @@ -248,20 +164,31 @@ Main_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface, LPDIRECT3DVERTEXBUFFER7* lplpD3DVertBuf, DWORD dwFlags) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); FIXME("(%p/%p)->(%p,%p,%08lx): stub!\n", This, iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags); return D3D_OK; } +HRESULT WINAPI +Thunk_IDirect3DImpl_7_QueryInterface(LPDIRECT3D7 iface, + REFIID riid, + LPVOID* obp) +{ + TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp); + return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface), + riid, + obp); +} + HRESULT WINAPI Thunk_IDirect3DImpl_3_QueryInterface(LPDIRECT3D3 iface, REFIID riid, LPVOID* obp) { - TRACE("(%p)->(%s,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riid), obp); - return IDirect3D7_QueryInterface(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface), - riid, - obp); + TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp); + return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface), + riid, + obp); } HRESULT WINAPI @@ -269,10 +196,10 @@ Thunk_IDirect3DImpl_2_QueryInterface(LPDIRECT3D2 iface, REFIID riid, LPVOID* obp) { - TRACE("(%p)->(%s,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riid), obp); - return IDirect3D7_QueryInterface(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D7, iface), - riid, - obp); + TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp); + return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface), + riid, + obp); } HRESULT WINAPI @@ -280,52 +207,66 @@ Thunk_IDirect3DImpl_1_QueryInterface(LPDIRECT3D iface, REFIID riid, LPVOID* obp) { - TRACE("(%p)->(%s,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riid), obp); - return IDirect3D7_QueryInterface(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D7, iface), - riid, - obp); + TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp); + return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface), + riid, + obp); +} + +ULONG WINAPI +Thunk_IDirect3DImpl_7_AddRef(LPDIRECT3D7 iface) +{ + TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface); + return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface)); } ULONG WINAPI Thunk_IDirect3DImpl_3_AddRef(LPDIRECT3D3 iface) { - TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface); - return IDirect3D7_AddRef(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface)); + TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface); + return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface)); } ULONG WINAPI Thunk_IDirect3DImpl_2_AddRef(LPDIRECT3D2 iface) { - TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface); - return IDirect3D7_AddRef(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D7, iface)); + TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface); + return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface)); } ULONG WINAPI Thunk_IDirect3DImpl_1_AddRef(LPDIRECT3D iface) { - TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface); - return IDirect3D7_AddRef(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D7, iface)); + TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface); + return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface)); +} + +ULONG WINAPI +Thunk_IDirect3DImpl_7_Release(LPDIRECT3D7 iface) +{ + TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface); + return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface)); } ULONG WINAPI Thunk_IDirect3DImpl_3_Release(LPDIRECT3D3 iface) { - TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface); - return IDirect3D7_Release(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface)); + TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface); + return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface)); } ULONG WINAPI Thunk_IDirect3DImpl_2_Release(LPDIRECT3D2 iface) { - TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface); - return IDirect3D7_Release(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D7, iface)); + TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface); + return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface)); } ULONG WINAPI Thunk_IDirect3DImpl_1_Release(LPDIRECT3D iface) { - TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface); - return IDirect3D7_Release(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D7, iface)); + TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface); + return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface)); } HRESULT WINAPI @@ -335,7 +276,7 @@ Thunk_IDirect3DImpl_3_EnumZBufferFormats(LPDIRECT3D3 iface, LPVOID lpContext) { TRACE("(%p)->(%s,%p,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext); - return IDirect3D7_EnumZBufferFormats(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface), + return IDirect3D7_EnumZBufferFormats(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface), riidDevice, lpEnumCallback, lpContext); @@ -345,7 +286,7 @@ HRESULT WINAPI Thunk_IDirect3DImpl_3_EvictManagedTextures(LPDIRECT3D3 iface) { TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface); - return IDirect3D7_EvictManagedTextures(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface)); + return IDirect3D7_EvictManagedTextures(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface)); } HRESULT WINAPI @@ -354,7 +295,7 @@ Thunk_IDirect3DImpl_2_EnumDevices(LPDIRECT3D2 iface, LPVOID lpUserArg) { TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpEnumDevicesCallback, lpUserArg); - return IDirect3D3_EnumDevices(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface), + return IDirect3D3_EnumDevices(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface), lpEnumDevicesCallback, lpUserArg); } @@ -365,7 +306,7 @@ Thunk_IDirect3DImpl_2_CreateLight(LPDIRECT3D2 iface, IUnknown* pUnkOuter) { TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DLight, pUnkOuter); - return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface), + return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface), lplpDirect3DLight, pUnkOuter); } @@ -376,7 +317,7 @@ Thunk_IDirect3DImpl_1_CreateLight(LPDIRECT3D iface, IUnknown* pUnkOuter) { TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DLight, pUnkOuter); - return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface), + return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface), lplpDirect3DLight, pUnkOuter); } @@ -390,7 +331,7 @@ Thunk_IDirect3DImpl_1_CreateMaterial(LPDIRECT3D iface, LPDIRECT3DMATERIAL3 ret_val; TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DMaterial, pUnkOuter); - ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface), + ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface), &ret_val, pUnkOuter); @@ -407,7 +348,7 @@ Thunk_IDirect3DImpl_1_CreateViewport(LPDIRECT3D iface, IUnknown* pUnkOuter) { TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpD3DViewport, pUnkOuter); - return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface), + return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface), (LPDIRECT3DVIEWPORT3 *) lplpD3DViewport /* No need to cast here */, pUnkOuter); } @@ -421,7 +362,7 @@ Thunk_IDirect3DImpl_2_CreateMaterial(LPDIRECT3D2 iface, LPDIRECT3DMATERIAL3 ret_val; TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DMaterial2, pUnkOuter); - ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface), + ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface), &ret_val, pUnkOuter); @@ -438,7 +379,7 @@ Thunk_IDirect3DImpl_2_CreateViewport(LPDIRECT3D2 iface, IUnknown* pUnkOuter) { TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpD3DViewport2, pUnkOuter); - return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface), + return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface), (LPDIRECT3DVIEWPORT3 *) lplpD3DViewport2 /* No need to cast here */, pUnkOuter); } @@ -459,7 +400,7 @@ Thunk_IDirect3DImpl_3_CreateVertexBuffer(LPDIRECT3D3 iface, /* dwFlags is not used in the D3D7 interface, use the vertex buffer description instead */ if (dwFlags & D3DDP_DONOTCLIP) lpD3DVertBufDesc->dwCaps |= D3DVBCAPS_DONOTCLIP; - ret = IDirect3D7_CreateVertexBuffer(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface), + ret = IDirect3D7_CreateVertexBuffer(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface), lpD3DVertBufDesc, &ret_val, dwFlags); @@ -477,7 +418,7 @@ Thunk_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface, LPD3DFINDDEVICERESULT lplpD3DDevice) { TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lplpD3DDevice); - return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface), + return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface), lpD3DDFS, lplpD3DDevice); } @@ -488,7 +429,7 @@ Thunk_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface, LPD3DFINDDEVICERESULT lpD3DFDR) { TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lpD3DFDR); - return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface), + return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface), lpD3DDFS, lpD3DFDR); } diff --git a/dlls/ddraw/direct3d/main.h b/dlls/ddraw/direct3d/main.h index 15ed6e6b47a..49e44c400cf 100644 --- a/dlls/ddraw/direct3d/main.h +++ b/dlls/ddraw/direct3d/main.h @@ -18,17 +18,6 @@ /* This is defined here so as to be able to put them in 'drivers' */ -HRESULT WINAPI -Main_IDirect3DImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3D7 iface, - REFIID riid, - LPVOID* obp); - -ULONG WINAPI -Main_IDirect3DImpl_7_3T_2T_1T_AddRef(LPDIRECT3D7 iface); - -ULONG WINAPI -Main_IDirect3DImpl_7_3T_2T_1T_Release(LPDIRECT3D7 iface); - HRESULT WINAPI Main_IDirect3DImpl_7_EnumDevices(LPDIRECT3D7 iface, LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, @@ -129,6 +118,11 @@ Main_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice); +HRESULT WINAPI +Thunk_IDirect3DImpl_7_QueryInterface(LPDIRECT3D7 iface, + REFIID riid, + LPVOID* obp); + HRESULT WINAPI Thunk_IDirect3DImpl_3_QueryInterface(LPDIRECT3D3 iface, REFIID riid, @@ -144,6 +138,9 @@ Thunk_IDirect3DImpl_1_QueryInterface(LPDIRECT3D iface, REFIID riid, LPVOID* obp); +ULONG WINAPI +Thunk_IDirect3DImpl_7_AddRef(LPDIRECT3D7 iface); + ULONG WINAPI Thunk_IDirect3DImpl_3_AddRef(LPDIRECT3D3 iface); @@ -153,6 +150,9 @@ Thunk_IDirect3DImpl_2_AddRef(LPDIRECT3D2 iface); ULONG WINAPI Thunk_IDirect3DImpl_1_AddRef(LPDIRECT3D iface); +ULONG WINAPI +Thunk_IDirect3DImpl_7_Release(LPDIRECT3D7 iface); + ULONG WINAPI Thunk_IDirect3DImpl_3_Release(LPDIRECT3D3 iface); diff --git a/dlls/ddraw/direct3d/mesa.c b/dlls/ddraw/direct3d/mesa.c index 0f843424819..d6eb9e80d3d 100644 --- a/dlls/ddraw/direct3d/mesa.c +++ b/dlls/ddraw/direct3d/mesa.c @@ -47,7 +47,7 @@ GL_IDirect3DImpl_1_EnumDevices(LPDIRECT3D iface, LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface); TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg); /* Call functions defined in d3ddevices.c */ @@ -62,7 +62,7 @@ GL_IDirect3DImpl_3_2T_EnumDevices(LPDIRECT3D3 iface, LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, LPVOID lpUserArg) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg); /* Call functions defined in d3ddevices.c */ @@ -77,7 +77,7 @@ GL_IDirect3DImpl_3_2T_1T_CreateLight(LPDIRECT3D3 iface, LPDIRECT3DLIGHT* lplpDirect3DLight, IUnknown* pUnkOuter) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This; int fl; IDirect3DLightImpl *d3dlimpl; @@ -106,7 +106,7 @@ GL_IDirect3DImpl_3_2T_1T_CreateMaterial(LPDIRECT3D3 iface, { IDirect3DMaterialImpl *D3Dmat_impl; HRESULT ret_value; - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); TRACE("(%p/%p)->(%p,%p)\n", This, iface, lplpDirect3DMaterial3, pUnkOuter); ret_value = d3dmaterial_create(&D3Dmat_impl, This); @@ -123,7 +123,7 @@ GL_IDirect3DImpl_3_2T_1T_CreateViewport(LPDIRECT3D3 iface, { IDirect3DViewportImpl *D3Dvp_impl; HRESULT ret_value; - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); TRACE("(%p/%p)->(%p,%p)\n", This, iface, lplpD3DViewport3, pUnkOuter); ret_value = d3dviewport_create(&D3Dvp_impl, This); @@ -134,7 +134,7 @@ GL_IDirect3DImpl_3_2T_1T_CreateViewport(LPDIRECT3D3 iface, } static HRESULT -create_device_helper(IDirect3DImpl *This, +create_device_helper(IDirectDrawImpl *This, REFCLSID iid, IDirectDrawSurfaceImpl *lpDDS, void **obj, @@ -186,7 +186,7 @@ GL_IDirect3DImpl_2_CreateDevice(LPDIRECT3D2 iface, LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DDEVICE2* lplpD3DDevice2) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D2, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface); IDirectDrawSurfaceImpl *ddsurfaceimpl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface3, lpDDS); TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice2); return create_device_helper(This, rclsid, ddsurfaceimpl, (void **) lplpD3DDevice2, 2); @@ -199,7 +199,7 @@ GL_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface, LPDIRECT3DDEVICE3* lplpD3DDevice3, LPUNKNOWN lpUnk) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); IDirectDrawSurfaceImpl *ddsurfaceimpl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, lpDDS); TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice3); return create_device_helper(This, rclsid, ddsurfaceimpl, (void **) lplpD3DDevice3, 3); @@ -210,7 +210,7 @@ GL_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lpD3DFDR) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface); TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DDFS, lpD3DFDR); return d3ddevice_find(This, lpD3DDFS, lpD3DFDR); } @@ -221,7 +221,7 @@ GL_IDirect3DImpl_7_3T_EnumZBufferFormats(LPDIRECT3D7 iface, LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, LPVOID lpContext) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); DDPIXELFORMAT pformat; TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext); @@ -246,7 +246,7 @@ GL_IDirect3DImpl_7_EnumDevices(LPDIRECT3D7 iface, LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, LPVOID lpUserArg) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg); if (d3ddevice_enumerate7(lpEnumDevicesCallback, lpUserArg) != D3DENUMRET_OK) @@ -261,7 +261,7 @@ GL_IDirect3DImpl_7_CreateDevice(LPDIRECT3D7 iface, LPDIRECTDRAWSURFACE7 lpDDS, LPDIRECT3DDEVICE7* lplpD3DDevice) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); IDirectDrawSurfaceImpl *ddsurfaceimpl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, lpDDS); TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice); return create_device_helper(This, rclsid, ddsurfaceimpl, (void **) lplpD3DDevice, 7); @@ -273,7 +273,7 @@ GL_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface, LPDIRECT3DVERTEXBUFFER7* lplpD3DVertBuf, DWORD dwFlags) { - ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface); + ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface); IDirect3DVertexBufferImpl *vbimpl; HRESULT res; @@ -286,7 +286,7 @@ GL_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface, return res; } -static void light_released(IDirect3DImpl *This, GLenum light_num) +static void light_released(IDirectDrawImpl *This, GLenum light_num) { IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This; glThis->free_lights |= (light_num - GL_LIGHT0); @@ -301,9 +301,9 @@ static void light_released(IDirect3DImpl *This, GLenum light_num) ICOM_VTABLE(IDirect3D7) VTABLE_IDirect3D7 = { ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE - XCAST(QueryInterface) Main_IDirect3DImpl_7_3T_2T_1T_QueryInterface, - XCAST(AddRef) Main_IDirect3DImpl_7_3T_2T_1T_AddRef, - XCAST(Release) Main_IDirect3DImpl_7_3T_2T_1T_Release, + XCAST(QueryInterface) Thunk_IDirect3DImpl_7_QueryInterface, + XCAST(AddRef) Thunk_IDirect3DImpl_7_AddRef, + XCAST(Release) Thunk_IDirect3DImpl_7_Release, XCAST(EnumDevices) GL_IDirect3DImpl_7_EnumDevices, XCAST(CreateDevice) GL_IDirect3DImpl_7_CreateDevice, XCAST(CreateVertexBuffer) GL_IDirect3DImpl_7_3T_CreateVertexBuffer, @@ -393,13 +393,13 @@ ICOM_VTABLE(IDirect3D) VTABLE_IDirect3D = #undef XCAST #endif -static HRESULT d3d_add_device(IDirect3DImpl *This, IDirect3DDeviceImpl *device) +static HRESULT d3d_add_device(IDirectDrawImpl *This, IDirect3DDeviceImpl *device) { if (This->current_device == NULL) { /* Create delayed textures now that we have an OpenGL context... For that, go through all surface attached to our DDraw object and create OpenGL textures for all textures.. */ - IDirectDrawSurfaceImpl *surf = This->ddraw->surfaces; + IDirectDrawSurfaceImpl *surf = This->surfaces; while (surf != NULL) { if (surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) { @@ -415,38 +415,34 @@ static HRESULT d3d_add_device(IDirect3DImpl *This, IDirect3DDeviceImpl *device) return DD_OK; } -static HRESULT d3d_remove_device(IDirect3DImpl *This, IDirect3DDeviceImpl *device) +static HRESULT d3d_remove_device(IDirectDrawImpl *This, IDirect3DDeviceImpl *device) { This->current_device = NULL; return DD_OK; } -HRESULT direct3d_create(IDirect3DImpl **obj, IDirectDrawImpl *ddraw) +HRESULT direct3d_create(IDirectDrawImpl *This) { - IDirect3DImpl *object; IDirect3DGLImpl *globject; - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DGLImpl)); - if (object == NULL) return DDERR_OUTOFMEMORY; + globject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DGLImpl)); + if (globject == NULL) return DDERR_OUTOFMEMORY; - object->ref = 1; - object->ddraw = ddraw; - object->create_texture = d3dtexture_create; - object->added_device = d3d_add_device; - object->removed_device = d3d_remove_device; + This->d3d_create_texture = d3dtexture_create; + This->d3d_added_device = d3d_add_device; + This->d3d_removed_device = d3d_remove_device; - ICOM_INIT_INTERFACE(object, IDirect3D, VTABLE_IDirect3D); - ICOM_INIT_INTERFACE(object, IDirect3D2, VTABLE_IDirect3D2); - ICOM_INIT_INTERFACE(object, IDirect3D3, VTABLE_IDirect3D3); - ICOM_INIT_INTERFACE(object, IDirect3D7, VTABLE_IDirect3D7); + ICOM_INIT_INTERFACE(This, IDirect3D, VTABLE_IDirect3D); + ICOM_INIT_INTERFACE(This, IDirect3D2, VTABLE_IDirect3D2); + ICOM_INIT_INTERFACE(This, IDirect3D3, VTABLE_IDirect3D3); + ICOM_INIT_INTERFACE(This, IDirect3D7, VTABLE_IDirect3D7); - globject = (IDirect3DGLImpl *) object; globject->free_lights = (0x01 << MAX_LIGHTS) - 1; /* There are, in total, 8 lights in OpenGL */ globject->light_released = light_released; - *obj = object; + This->d3d_private = globject; - TRACE(" creating implementation at %p.\n", *obj); + TRACE(" creating Mesa private storage at %p.\n", globject); return D3D_OK; } diff --git a/dlls/ddraw/dsurface/fakezbuffer.c b/dlls/ddraw/dsurface/fakezbuffer.c index 63d4b600942..d101acc3172 100644 --- a/dlls/ddraw/dsurface/fakezbuffer.c +++ b/dlls/ddraw/dsurface/fakezbuffer.c @@ -132,8 +132,8 @@ FakeZBuffer_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst, } /* We only support the BLT with DEPTH_FILL for now */ - if ((dwFlags & DDBLT_DEPTHFILL) && (This->ddraw_owner->d3d != NULL)) { - if (This->ddraw_owner->d3d->current_device != NULL) { + if ((dwFlags & DDBLT_DEPTHFILL) && (This->ddraw_owner->d3d_private != NULL)) { + if (This->ddraw_owner->current_device != NULL) { D3DRECT rect; if (rdst) { rect.u1.x1 = rdst->left; @@ -141,12 +141,12 @@ FakeZBuffer_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst, rect.u3.x2 = rdst->right; rect.u4.y2 = rdst->bottom; } - This->ddraw_owner->d3d->current_device->clear(This->ddraw_owner->d3d->current_device, - (rdst == NULL ? 0 : 1), &rect, - D3DCLEAR_ZBUFFER, - 0x00000000, - ((double) lpbltfx->u5.dwFillDepth) / 4294967295.0, - 0x00000000); + This->ddraw_owner->current_device->clear(This->ddraw_owner->current_device, + (rdst == NULL ? 0 : 1), &rect, + D3DCLEAR_ZBUFFER, + 0x00000000, + ((double) lpbltfx->u5.dwFillDepth) / 4294967295.0, + 0x00000000); return DD_OK; } } diff --git a/dlls/ddraw/dsurface/main.c b/dlls/ddraw/dsurface/main.c index 4f78f3096cc..9ae9ba13e8d 100644 --- a/dlls/ddraw/dsurface/main.c +++ b/dlls/ddraw/dsurface/main.c @@ -189,7 +189,7 @@ Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid, IDirect3DDeviceImpl *d3ddevimpl; HRESULT ret_value; - ret_value = d3ddevice_create(&d3ddevimpl, This->ddraw_owner->d3d, This); + ret_value = d3ddevice_create(&d3ddevimpl, This->ddraw_owner, This); if (FAILED(ret_value)) return ret_value; *ppObj = ICOM_INTERFACE(d3ddevimpl, IDirect3DDevice); @@ -207,12 +207,12 @@ Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid, /* In case the texture surface was created before the D3D creation */ if (This->tex_private == NULL) { - if (This->ddraw_owner->d3d == NULL) { + if (This->ddraw_owner->d3d_private == NULL) { ERR("Texture created with no D3D object yet.. Not supported !\n"); return E_NOINTERFACE; } - ret_value = This->ddraw_owner->d3d->create_texture(This->ddraw_owner->d3d, This, FALSE, This->mip_main); + ret_value = This->ddraw_owner->d3d_create_texture(This->ddraw_owner, This, FALSE, This->mip_main); if (FAILED(ret_value)) return ret_value; } if (IsEqualGUID( &IID_IDirect3DTexture, riid )) { diff --git a/dlls/ddraw/mesa.c b/dlls/ddraw/mesa.c index a18d2ef2e6f..b2e6bcedaca 100644 --- a/dlls/ddraw/mesa.c +++ b/dlls/ddraw/mesa.c @@ -773,7 +773,7 @@ HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLui (src_pf->u3.dwGBitMask == 0x0000FF00) && (src_pf->u4.dwBBitMask == 0x000000FF) && (src_pf->u5.dwRGBAlphaBitMask == 0x00000000)) { - if (need_alpha_ck) { + if (need_alpha_ck == TRUE) { convert_type = CONVERT_RGB32_888; current_format = GL_RGBA; internal_format = GL_RGBA; @@ -889,7 +889,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v DWORD i; WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(WORD)); dst = (WORD *) *temp_buffer; @@ -909,7 +909,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v DWORD i; WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(WORD)); dst = (WORD *) *temp_buffer; @@ -929,7 +929,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v DWORD i; WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(WORD)); dst = (WORD *) *temp_buffer; @@ -968,7 +968,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v DWORD i; WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(WORD)); dst = (WORD *) *temp_buffer; @@ -988,7 +988,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v DWORD i; WORD *src = (WORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(WORD)); dst = (WORD *) *temp_buffer; @@ -1017,7 +1017,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v BYTE *src = (BYTE *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)); DWORD *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(DWORD)); dst = (DWORD *) *temp_buffer; @@ -1038,7 +1038,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v DWORD i; DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(DWORD)); dst = (DWORD *) *temp_buffer; @@ -1057,7 +1057,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v DWORD i; DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(DWORD)); dst = (DWORD *) *temp_buffer; @@ -1077,7 +1077,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, v DWORD i; DWORD *src = (DWORD *) (((BYTE *) src_d->lpSurface) + (bpp * rect->left) + (src_d->u1.lPitch * rect->top)), *dst; - if (*temp_buffer != NULL) + if (*temp_buffer == NULL) *temp_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, current_tex_width * current_tex_height * sizeof(DWORD)); dst = (DWORD *) *temp_buffer; diff --git a/dlls/ddraw/mesa_private.h b/dlls/ddraw/mesa_private.h index db57bc9c2cb..a7094de5ad1 100644 --- a/dlls/ddraw/mesa_private.h +++ b/dlls/ddraw/mesa_private.h @@ -45,11 +45,11 @@ typedef enum { SURFACE_MEMORY_DIRTY } SURFACE_STATE; +/* This structure is used for the 'd3d_private' field of the IDirectDraw structure */ typedef struct IDirect3DGLImpl { - struct IDirect3DImpl parent; DWORD free_lights; - void (*light_released)(IDirect3DImpl *, GLenum light_num); + void (*light_released)(IDirectDrawImpl *, GLenum light_num); } IDirect3DGLImpl; typedef struct IDirect3DLightGLImpl @@ -124,19 +124,19 @@ typedef struct { } IDirect3DVertexBufferGLImpl; /* All non-static functions 'exported' by various sub-objects */ -extern HRESULT direct3d_create(IDirect3DImpl **obj, IDirectDrawImpl *ddraw); -extern HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf); -extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirect3DImpl *d3d, GLenum light_num); -extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirect3DImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc); -extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirect3DImpl *d3d); -extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirect3DImpl *d3d); -extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags); -extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surface); +extern HRESULT direct3d_create(IDirectDrawImpl *This); +extern HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf); +extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d, GLenum light_num); +extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirectDrawImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc); +extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d); +extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d); +extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirectDrawImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags); +extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface); /* Used for Direct3D to request the device to enumerate itself */ extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) ; extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ; -extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice); +extern HRESULT d3ddevice_find(IDirectDrawImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice); /* Used to upload the texture */ extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This) ;