Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1975,7 +1975,11 @@ |
1976 | 1976 | if(!lpDDSurfaceDesc) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1977 | 1977 | if(lpDDSurfaceDesc->dwSize < sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1978 | 1978 | LPDIRECTDRAWSURFACE7 lpDDS7;
|
1979 | | - HRESULT err = glDD7->CreateSurface2((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter,TRUE);
|
| 1979 | + DDSURFACEDESC2 ddsd2;
|
| 1980 | + ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
|
| 1981 | + memcpy(&ddsd2, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
|
| 1982 | + ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
| 1983 | + HRESULT err = glDD7->CreateSurface2(&ddsd2,&lpDDS7,pUnkOuter,TRUE);
|
1980 | 1984 | if(err == DD_OK)
|
1981 | 1985 | {
|
1982 | 1986 | lpDDS7->QueryInterface(IID_IDirectDrawSurface,(LPVOID*) lplpDDSurface);
|
— | — | @@ -2179,7 +2183,11 @@ |
2180 | 2184 | if(!lpDDSurfaceDesc) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
2181 | 2185 | if(lpDDSurfaceDesc->dwSize < sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
2182 | 2186 | LPDIRECTDRAWSURFACE7 lpDDS7;
|
2183 | | - HRESULT err = glDD7->CreateSurface2((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter,TRUE);
|
| 2187 | + DDSURFACEDESC2 ddsd2;
|
| 2188 | + ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
|
| 2189 | + memcpy(&ddsd2, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
|
| 2190 | + ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
| 2191 | + HRESULT err = glDD7->CreateSurface2(&ddsd2, &lpDDS7, pUnkOuter, TRUE);
|
2184 | 2192 | if(err == DD_OK)
|
2185 | 2193 | {
|
2186 | 2194 | lpDDS7->QueryInterface(IID_IDirectDrawSurface,(LPVOID*) lplpDDSurface);
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -74,6 +74,7 @@ |
75 | 75 | ddInterface = (glDirectDraw7 *)lpDD7;
|
76 | 76 | hRC = ddInterface->renderer->hRC;
|
77 | 77 | ddsd = *lpDDSurfaceDesc2;
|
| 78 | + miptexture = NULL;
|
78 | 79 | LONG sizes[6];
|
79 | 80 | ddInterface->GetSizes(sizes);
|
80 | 81 | if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
— | — | @@ -877,19 +878,23 @@ |
878 | 879 | TRACE_ENTER(3,14,this,14,lpDDSCaps,14,lplpDDAttachedSurface);
|
879 | 880 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
880 | 881 | DDSCAPS2 ddsComp;
|
881 | | - if (backbuffer) backbuffer->GetCaps(&ddsComp);
|
| 882 | + ZeroMemory(&ddsComp, sizeof(DDSCAPS2));
|
882 | 883 | unsigned __int64 comp1,comp2;
|
883 | | - memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
|
884 | | - memcpy(&comp2,&ddsComp,sizeof(unsigned __int64));
|
885 | | - if((comp1 & comp2) == comp1)
|
886 | | - {
|
887 | | - *lplpDDAttachedSurface = backbuffer;
|
888 | | - backbuffer->AddRef();
|
889 | | - TRACE_VAR("*lplpDDAttachedSurface",14,*lplpDDAttachedSurface);
|
890 | | - TRACE_EXIT(23,DD_OK);
|
891 | | - return DD_OK;
|
| 884 | + if (backbuffer)
|
| 885 | + {
|
| 886 | + backbuffer->GetCaps(&ddsComp);
|
| 887 | + memcpy(&comp1, lpDDSCaps, sizeof(unsigned __int64));
|
| 888 | + memcpy(&comp2, &ddsComp, sizeof(unsigned __int64));
|
| 889 | + if ((comp1 & comp2) == comp1)
|
| 890 | + {
|
| 891 | + *lplpDDAttachedSurface = backbuffer;
|
| 892 | + backbuffer->AddRef();
|
| 893 | + TRACE_VAR("*lplpDDAttachedSurface", 14, *lplpDDAttachedSurface);
|
| 894 | + TRACE_EXIT(23, DD_OK);
|
| 895 | + return DD_OK;
|
| 896 | + }
|
892 | 897 | }
|
893 | | - else if(zbuffer)
|
| 898 | + if(zbuffer)
|
894 | 899 | {
|
895 | 900 | zbuffer->GetCaps(&ddsComp);
|
896 | 901 | memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
|
— | — | @@ -903,6 +908,21 @@ |
904 | 909 | return DD_OK;
|
905 | 910 | }
|
906 | 911 | }
|
| 912 | + if (miptexture)
|
| 913 | + {
|
| 914 | + miptexture->GetCaps(&ddsComp);
|
| 915 | + memcpy(&comp1, lpDDSCaps, sizeof(unsigned __int64));
|
| 916 | + memcpy(&comp2, &ddsComp, sizeof(unsigned __int64));
|
| 917 | + if ((comp1 & comp2) == comp1)
|
| 918 | + {
|
| 919 | + *lplpDDAttachedSurface = miptexture;
|
| 920 | + miptexture->AddRef();
|
| 921 | + TRACE_VAR("*lplpDDAttachedSurface", 14, *lplpDDAttachedSurface);
|
| 922 | + TRACE_EXIT(23, DD_OK);
|
| 923 | + return DD_OK;
|
| 924 | + }
|
| 925 | + }
|
| 926 | +
|
907 | 927 | TRACE_EXIT(23,DDERR_NOTFOUND);
|
908 | 928 | ERR(DDERR_NOTFOUND);
|
909 | 929 | }
|