Index: ddraw/glDirectDraw.cpp |
— | — | @@ -895,9 +895,16 @@ |
896 | 896 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
897 | 897 | if(!lpDDSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
898 | 898 | if(!lplpDupDDSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
899 | | - FIXME("IDirectDraw::DuplicateSurface: stub\n");
|
900 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
901 | | - ERR(DDERR_GENERIC);
|
| 899 | + DDSURFACEDESC2 ddsd;
|
| 900 | + HRESULT ret;
|
| 901 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
| 902 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 903 | + lpDDSurface->GetSurfaceDesc(&ddsd);
|
| 904 | + ret = CreateSurface(&ddsd, lplpDupDDSurface, NULL);
|
| 905 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 906 | + ret = (*lplpDupDDSurface)->Blt(NULL, lpDDSurface, NULL, 0, NULL);
|
| 907 | + TRACE_EXIT(23, ret);
|
| 908 | + return ret;
|
902 | 909 | }
|
903 | 910 | HRESULT WINAPI glDirectDraw7::EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback)
|
904 | 911 | {
|
— | — | @@ -908,16 +915,95 @@ |
909 | 916 | TRACE_EXIT(23,ret);
|
910 | 917 | return ret;
|
911 | 918 | }
|
| 919 | +
|
| 920 | +HRESULT WINAPI EnumSurfacesCallback1(LPDIRECTDRAWSURFACE7 lpDDSurface, LPDDSURFACEDESC2 lpDDSD2, LPVOID lpContext)
|
| 921 | +{
|
| 922 | + LPVOID *lplpContext = (LPVOID*)lpContext;
|
| 923 | + LPDDENUMSURFACESCALLBACK callback = (LPDDENUMSURFACESCALLBACK)lplpContext[0];
|
| 924 | + LPVOID context = (LPVOID)lplpContext[1];
|
| 925 | + LPDIRECTDRAWSURFACE dds1;
|
| 926 | + DDSURFACEDESC ddsd;
|
| 927 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
|
| 928 | + ddsd.dwSize = sizeof(DDSURFACEDESC);
|
| 929 | + lpDDSurface->QueryInterface(IID_IDirectDrawSurface, (void**)&dds1);
|
| 930 | + lpDDSurface->Release();
|
| 931 | + dds1->GetSurfaceDesc(&ddsd);
|
| 932 | + return callback(dds1, &ddsd, context);
|
| 933 | +}
|
| 934 | +HRESULT WINAPI EnumSurfacesCallback2(LPDIRECTDRAWSURFACE7 lpDDSurface, LPDDSURFACEDESC2 lpDDSD2, LPVOID lpContext)
|
| 935 | +{
|
| 936 | + LPVOID *lplpContext = (LPVOID*)lpContext;
|
| 937 | + LPDDENUMSURFACESCALLBACK2 callback = (LPDDENUMSURFACESCALLBACK2)lplpContext[0];
|
| 938 | + LPVOID context = (LPVOID)lplpContext[1];
|
| 939 | + LPDIRECTDRAWSURFACE4 dds4;
|
| 940 | + DDSURFACEDESC2 ddsd;
|
| 941 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
| 942 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 943 | + lpDDSurface->QueryInterface(IID_IDirectDrawSurface4, (void**)&dds4);
|
| 944 | + lpDDSurface->Release();
|
| 945 | + dds4->GetSurfaceDesc(&ddsd);
|
| 946 | + return callback(dds4, &ddsd, context);
|
| 947 | +}
|
| 948 | +
|
912 | 949 | HRESULT WINAPI glDirectDraw7::EnumSurfaces(DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD2, LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback)
|
913 | 950 | {
|
| 951 | + int i;
|
| 952 | + BOOL match;
|
| 953 | + HRESULT ret;
|
| 954 | + LPDIRECTDRAWSURFACE7 surface;
|
| 955 | + DDSURFACEDESC2 ddsd;
|
| 956 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
| 957 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
914 | 958 | TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDSD2,14,lpContext,14,lpEnumSurfacesCallback);
|
915 | 959 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
916 | | - if(!lpDDSD2) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 960 | + if(!lpDDSD2 && !(dwFlags & DDENUMSURFACES_ALL)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
917 | 961 | if(!lpEnumSurfacesCallback) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
918 | 962 | if(dwFlags & 0xFFFFFFE0) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
919 | | - FIXME("IDirectDraw::EnumSurfaces: stub\n");
|
920 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
921 | | - ERR(DDERR_GENERIC);
|
| 963 | + if ((dwFlags & DDENUMSURFACES_CANBECREATED) && (dwFlags & DDENUMSURFACES_DOESEXIST)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 964 | + if (!(dwFlags & DDENUMSURFACES_CANBECREATED) && !(dwFlags & DDENUMSURFACES_DOESEXIST)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 965 | + if ((dwFlags & DDENUMSURFACES_CANBECREATED) && !(dwFlags & DDENUMSURFACES_MATCH)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 966 | + if ((dwFlags & DDENUMSURFACES_ALL) && (dwFlags & DDENUMSURFACES_MATCH)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 967 | + if ((dwFlags & DDENUMSURFACES_ALL) && (dwFlags & DDENUMSURFACES_NOMATCH)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 968 | + if ((dwFlags & DDENUMSURFACES_MATCH) && (dwFlags & DDENUMSURFACES_NOMATCH)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 969 | + if (dwFlags & DDENUMSURFACES_CANBECREATED)
|
| 970 | + {
|
| 971 | + // create surface
|
| 972 | + ret = CreateSurface(lpDDSD2, &surface, NULL);
|
| 973 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 974 | + surface->GetSurfaceDesc(&ddsd);
|
| 975 | + lpEnumSurfacesCallback(surface, &ddsd, lpContext);
|
| 976 | + TRACE_EXIT(23, DD_OK);
|
| 977 | + return DD_OK;
|
| 978 | + }
|
| 979 | + else
|
| 980 | + {
|
| 981 | + for (i = 0; i < surfacecount; i++)
|
| 982 | + {
|
| 983 | + if (surfaces[i])
|
| 984 | + {
|
| 985 | + if (dwFlags & DDENUMSURFACES_ALL) match = TRUE;
|
| 986 | + if (dwFlags & DDENUMSURFACES_MATCH)
|
| 987 | + {
|
| 988 | + if (!memcmp(&surfaces[i]->ddsd, lpDDSD2, sizeof(DDSURFACEDESC2))) match = TRUE;
|
| 989 | + else match = FALSE;
|
| 990 | + }
|
| 991 | + if (dwFlags & DDENUMSURFACES_NOMATCH)
|
| 992 | + {
|
| 993 | + if (memcmp(&surfaces[i]->ddsd, lpDDSD2, sizeof(DDSURFACEDESC2))) match = TRUE;
|
| 994 | + else match = FALSE;
|
| 995 | + }
|
| 996 | + if (match)
|
| 997 | + {
|
| 998 | + surfaces[i]->AddRef();
|
| 999 | + surfaces[i]->GetSurfaceDesc(&ddsd);
|
| 1000 | + ret = lpEnumSurfacesCallback(surfaces[i], &ddsd, lpContext);
|
| 1001 | + if (ret == DDENUMRET_CANCEL) break;
|
| 1002 | + }
|
| 1003 | + }
|
| 1004 | + }
|
| 1005 | + }
|
| 1006 | + TRACE_EXIT(23,DD_OK);
|
| 1007 | + return DD_OK;
|
922 | 1008 | }
|
923 | 1009 | HRESULT WINAPI glDirectDraw7::FlipToGDISurface()
|
924 | 1010 | {
|
— | — | @@ -1888,10 +1974,19 @@ |
1889 | 1975 | HRESULT WINAPI glDirectDraw1::DuplicateSurface(LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWSURFACE FAR *lplpDupDDSurface)
|
1890 | 1976 | {
|
1891 | 1977 | TRACE_ENTER(3,14,this,14,lpDDSurface,14,lplpDupDDSurface);
|
1892 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1893 | | - FIXME("glDirectDraw1::DuplicateSurface: stub\n");
|
1894 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
1895 | | - ERR(DDERR_GENERIC);
|
| 1978 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 1979 | + if (!lpDDSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1980 | + if (!lplpDupDDSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1981 | + DDSURFACEDESC ddsd;
|
| 1982 | + HRESULT ret;
|
| 1983 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
|
| 1984 | + ddsd.dwSize = sizeof(DDSURFACEDESC);
|
| 1985 | + lpDDSurface->GetSurfaceDesc(&ddsd);
|
| 1986 | + ret = CreateSurface(&ddsd, lplpDupDDSurface, NULL);
|
| 1987 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 1988 | + ret = (*lplpDupDDSurface)->Blt(NULL, lpDDSurface, NULL, 0, NULL);
|
| 1989 | + TRACE_EXIT(23, ret);
|
| 1990 | + return ret;
|
1896 | 1991 | }
|
1897 | 1992 | HRESULT WINAPI glDirectDraw1::EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback)
|
1898 | 1993 | {
|
— | — | @@ -1903,9 +1998,16 @@ |
1904 | 1999 | {
|
1905 | 2000 | TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDSD,14,lpContext,14,lpEnumSurfacesCallback);
|
1906 | 2001 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1907 | | - FIXME("glDirectDraw1::EnumSurfaces: stub\n");
|
1908 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
1909 | | - ERR(DDERR_GENERIC);
|
| 2002 | + if (!lpDDSD)TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2003 | + if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2004 | + LPVOID context[2];
|
| 2005 | + context[0] = lpEnumSurfacesCallback;
|
| 2006 | + context[1] = lpContext;
|
| 2007 | + DDSURFACEDESC2 ddsd;
|
| 2008 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
| 2009 | + memcpy(&ddsd, lpDDSD, sizeof(DDSURFACEDESC));
|
| 2010 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 2011 | + TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, &ddsd, context, EnumSurfacesCallback1));
|
1910 | 2012 | }
|
1911 | 2013 | HRESULT WINAPI glDirectDraw1::FlipToGDISurface()
|
1912 | 2014 | {
|
— | — | @@ -2075,10 +2177,19 @@ |
2076 | 2178 | HRESULT WINAPI glDirectDraw2::DuplicateSurface(LPDIRECTDRAWSURFACE lpDDSurface, LPDIRECTDRAWSURFACE FAR *lplpDupDDSurface)
|
2077 | 2179 | {
|
2078 | 2180 | TRACE_ENTER(3,14,this,14,lpDDSurface,14,lplpDupDDSurface);
|
2079 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2080 | | - FIXME("glDirectDraw2::DuplicateSurface: stub\n");
|
2081 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
2082 | | - ERR(DDERR_GENERIC);
|
| 2181 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 2182 | + if (!lpDDSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2183 | + if (!lplpDupDDSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2184 | + DDSURFACEDESC ddsd;
|
| 2185 | + HRESULT ret;
|
| 2186 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
|
| 2187 | + ddsd.dwSize = sizeof(DDSURFACEDESC);
|
| 2188 | + lpDDSurface->GetSurfaceDesc(&ddsd);
|
| 2189 | + ret = CreateSurface(&ddsd, lplpDupDDSurface, NULL);
|
| 2190 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2191 | + ret = (*lplpDupDDSurface)->Blt(NULL, lpDDSurface, NULL, 0, NULL);
|
| 2192 | + TRACE_EXIT(23, ret);
|
| 2193 | + return ret;
|
2083 | 2194 | }
|
2084 | 2195 | HRESULT WINAPI glDirectDraw2::EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback)
|
2085 | 2196 | {
|
— | — | @@ -2090,9 +2201,16 @@ |
2091 | 2202 | {
|
2092 | 2203 | TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDSD,14,lpContext,14,lpEnumSurfacesCallback);
|
2093 | 2204 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2094 | | - FIXME("glDirectDraw2::EnumSurfaces: stub\n");
|
2095 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
2096 | | - ERR(DDERR_GENERIC);
|
| 2205 | + if (!lpDDSD)TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2206 | + if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2207 | + LPVOID context[2];
|
| 2208 | + context[0] = lpEnumSurfacesCallback;
|
| 2209 | + context[1] = lpContext;
|
| 2210 | + DDSURFACEDESC2 ddsd;
|
| 2211 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
| 2212 | + memcpy(&ddsd, lpDDSD, sizeof(DDSURFACEDESC));
|
| 2213 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 2214 | + TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, &ddsd, context, EnumSurfacesCallback1));
|
2097 | 2215 | }
|
2098 | 2216 | HRESULT WINAPI glDirectDraw2::FlipToGDISurface()
|
2099 | 2217 | {
|
— | — | @@ -2286,10 +2404,19 @@ |
2287 | 2405 | HRESULT WINAPI glDirectDraw4::DuplicateSurface(LPDIRECTDRAWSURFACE4 lpDDSurface, LPDIRECTDRAWSURFACE4 FAR *lplpDupDDSurface)
|
2288 | 2406 | {
|
2289 | 2407 | TRACE_ENTER(3,14,this,14,lpDDSurface,14,lplpDupDDSurface);
|
2290 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2291 | | - FIXME("glDirectDraw4::DuplicateSurface: stub\n");
|
2292 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
2293 | | - ERR(DDERR_GENERIC);
|
| 2408 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 2409 | + if (!lpDDSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2410 | + if (!lplpDupDDSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2411 | + DDSURFACEDESC2 ddsd;
|
| 2412 | + HRESULT ret;
|
| 2413 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
| 2414 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 2415 | + lpDDSurface->GetSurfaceDesc(&ddsd);
|
| 2416 | + ret = CreateSurface(&ddsd, lplpDupDDSurface, NULL);
|
| 2417 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2418 | + ret = (*lplpDupDDSurface)->Blt(NULL, lpDDSurface, NULL, 0, NULL);
|
| 2419 | + TRACE_EXIT(23, ret);
|
| 2420 | + return ret;
|
2294 | 2421 | }
|
2295 | 2422 | HRESULT WINAPI glDirectDraw4::EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpEnumModesCallback)
|
2296 | 2423 | {
|
— | — | @@ -2301,9 +2428,12 @@ |
2302 | 2429 | {
|
2303 | 2430 | TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDSD,14,lpContext,14,lpEnumSurfacesCallback);
|
2304 | 2431 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2305 | | - FIXME("glDirectDraw4::EnumSurfaces: stub\n");
|
2306 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
2307 | | - ERR(DDERR_GENERIC);
|
| 2432 | + if (!lpDDSD)TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2433 | + if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2434 | + LPVOID context[2];
|
| 2435 | + context[0] = lpEnumSurfacesCallback;
|
| 2436 | + context[1] = lpContext;
|
| 2437 | + TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, lpDDSD, context, EnumSurfacesCallback2));
|
2308 | 2438 | }
|
2309 | 2439 | HRESULT WINAPI glDirectDraw4::FlipToGDISurface()
|
2310 | 2440 | {
|