Index: ddraw/glDirect3D.cpp |
— | — | @@ -200,6 +200,7 @@ |
201 | 201 | glD3D2 = NULL;
|
202 | 202 | glD3D1 = NULL;
|
203 | 203 | glDD7 = gl_DD7;
|
| 204 | + glDD7->AddRef();
|
204 | 205 | memcpy(stored_devices, devices, 3 * sizeof(D3DDevice));
|
205 | 206 | TRACE_EXIT(-1, 0);
|
206 | 207 | }
|
— | — | @@ -207,6 +208,7 @@ |
208 | 209 | glDirect3D7::~glDirect3D7()
|
209 | 210 | {
|
210 | 211 | TRACE_ENTER(1,14,this);
|
| 212 | + glDD7->Release();
|
211 | 213 | if(glD3D3) glD3D3->Release();
|
212 | 214 | if(glD3D2) glD3D2->Release();
|
213 | 215 | if(glD3D1) glD3D1->Release();
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -504,6 +504,7 @@ |
505 | 505 | return D3D_OK;
|
506 | 506 | }
|
507 | 507 | }
|
| 508 | + if (glDDS7) TRACE_RET(HRESULT, 23, glDDS7->QueryInterface(riid, ppvObj));
|
508 | 509 | TRACE_EXIT(23,E_NOINTERFACE);
|
509 | 510 | return E_NOINTERFACE;
|
510 | 511 | }
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1046,8 +1046,8 @@ |
1047 | 1047 | ddCaps.dwFXCaps = DDFXCAPS_BLTSHRINKX | DDFXCAPS_BLTSHRINKY |
|
1048 | 1048 | DDFXCAPS_BLTSTRETCHX | DDFXCAPS_BLTSTRETCHY | DDFXCAPS_BLTMIRRORLEFTRIGHT |
|
1049 | 1049 | DDFXCAPS_BLTMIRRORUPDOWN;
|
1050 | | - ddCaps.dwPalCaps = DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE;
|
1051 | | - ddCaps.ddsOldCaps.dwCaps = ddCaps.ddsCaps.dwCaps = DDSCAPS_3DDEVICE |
|
| 1050 | + ddCaps.dwPalCaps = DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256;
|
| 1051 | + ddCaps.ddsOldCaps.dwCaps = ddCaps.ddsCaps.dwCaps =
|
1052 | 1052 | DDSCAPS_BACKBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP |
|
1053 | 1053 | DDSCAPS_FRONTBUFFER | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_PALETTE |
|
1054 | 1054 | DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE |
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -702,7 +702,7 @@ |
703 | 703 | {
|
704 | 704 | TRACE_ENTER(6,14,this,8,dwX,8,dwY,14,lpDDSrcSurface,26,lpSrcRect,9,dwTrans);
|
705 | 705 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
706 | | - if (clipper) TRACE_RET(HRESULT,23,DDERR_UNSUPPORTED);
|
| 706 | + if (clipper) TRACE_RET(HRESULT, 23, DDERR_BLTFASTCANTCLIP);
|
707 | 707 | DDSURFACEDESC2 ddsd;
|
708 | 708 | ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
709 | 709 | lpDDSrcSurface->GetSurfaceDesc(&ddsd);
|
— | — | @@ -862,7 +862,7 @@ |
863 | 863 | TRACE_ENTER(3,14,this,14,lpDDSCaps,14,lplpDDAttachedSurface);
|
864 | 864 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
865 | 865 | DDSCAPS2 ddsComp;
|
866 | | - backbuffer->GetCaps(&ddsComp);
|
| 866 | + if (backbuffer) backbuffer->GetCaps(&ddsComp);
|
867 | 867 | unsigned __int64 comp1,comp2;
|
868 | 868 | memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
|
869 | 869 | memcpy(&comp2,&ddsComp,sizeof(unsigned __int64));
|
— | — | @@ -1566,7 +1566,21 @@ |
1567 | 1567 | TRACE_ENTER(2,14,this,14,gl_DDS7);
|
1568 | 1568 | glDDS7 = gl_DDS7;
|
1569 | 1569 | refcount = 1;
|
1570 | | - TRACE_EXIT(-1,0);
|
| 1570 | + attachments = (glDirectDrawSurface1**)malloc(16 * sizeof(glDirectDrawSurface1*));
|
| 1571 | + attachcount = 0;
|
| 1572 | + maxattach = 16;
|
| 1573 | + if (attachments)
|
| 1574 | + {
|
| 1575 | + if (attachcount)
|
| 1576 | + {
|
| 1577 | + for (int i = 0; i < attachcount; i++)
|
| 1578 | + {
|
| 1579 | + if (attachments[i]) attachments[i]->Release();
|
| 1580 | + }
|
| 1581 | + }
|
| 1582 | + free(attachments);
|
| 1583 | + }
|
| 1584 | + TRACE_EXIT(-1, 0);
|
1571 | 1585 | }
|
1572 | 1586 | glDirectDrawSurface1::~glDirectDrawSurface1()
|
1573 | 1587 | {
|
— | — | @@ -1608,12 +1622,60 @@ |
1609 | 1623 | TRACE_EXIT(8,ret);
|
1610 | 1624 | return ret;
|
1611 | 1625 | }
|
| 1626 | +void glDirectDrawSurface1::AddAttach(glDirectDrawSurface1 *attach)
|
| 1627 | +{
|
| 1628 | + bool emptyspace = false;
|
| 1629 | + int index;
|
| 1630 | + for (int i = 0; i < attachcount; i++)
|
| 1631 | + {
|
| 1632 | + if (!attachments[i])
|
| 1633 | + {
|
| 1634 | + emptyspace = true;
|
| 1635 | + index = i;
|
| 1636 | + break;
|
| 1637 | + }
|
| 1638 | + }
|
| 1639 | + if (emptyspace) attachments[index] = attach;
|
| 1640 | + else
|
| 1641 | + {
|
| 1642 | + attachcount++;
|
| 1643 | + if (attachcount >= maxattach)
|
| 1644 | + {
|
| 1645 | + glDirectDrawSurface1 **newattach = (glDirectDrawSurface1**)realloc(attachments,
|
| 1646 | + (maxattach + 16)*sizeof(glDirectDrawSurface1*));
|
| 1647 | + if (newattach)
|
| 1648 | + {
|
| 1649 | + maxattach += 16;
|
| 1650 | + attachments = newattach;
|
| 1651 | + }
|
| 1652 | + }
|
| 1653 | + attachments[attachcount-1] = attach;
|
| 1654 | + }
|
| 1655 | + attach->AddRef();
|
| 1656 | +}
|
| 1657 | +void glDirectDrawSurface1::DeleteAttach(glDirectDrawSurface1 *attach)
|
| 1658 | +{
|
| 1659 | + if (!attachcount) return;
|
| 1660 | + for (int i = 0; i < attachcount; i++)
|
| 1661 | + {
|
| 1662 | + if (attachments[i] == attach)
|
| 1663 | + {
|
| 1664 | + attach->Release();
|
| 1665 | + attachments[i] = NULL;
|
| 1666 | + return;
|
| 1667 | + }
|
| 1668 | + }
|
| 1669 | +}
|
1612 | 1670 | HRESULT WINAPI glDirectDrawSurface1::AddAttachedSurface(LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
|
1613 | 1671 | {
|
1614 | 1672 | TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
1615 | 1673 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1616 | 1674 | if(!lpDDSAttachedSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1617 | | - TRACE_RET(HRESULT,23,glDDS7->AddAttachedSurface(((glDirectDrawSurface1*)lpDDSAttachedSurface)->GetDDS7()));
|
| 1675 | + HRESULT ret = glDDS7->AddAttachedSurface(((glDirectDrawSurface1*)lpDDSAttachedSurface)->GetDDS7());
|
| 1676 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 1677 | + AddAttach((glDirectDrawSurface1*)lpDDSAttachedSurface);
|
| 1678 | + TRACE_EXIT(23, ret);
|
| 1679 | + return ret;
|
1618 | 1680 | }
|
1619 | 1681 | HRESULT WINAPI glDirectDrawSurface1::AddOverlayDirtyRect(LPRECT lpRect)
|
1620 | 1682 | {
|
— | — | @@ -1658,7 +1720,11 @@ |
1659 | 1721 | {
|
1660 | 1722 | TRACE_ENTER(3,14,this,9,dwFlags,14,lpDDSAttachedSurface);
|
1661 | 1723 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1662 | | - TRACE_RET(HRESULT,23,glDDS7->DeleteAttachedSurface(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface));
|
| 1724 | + HRESULT ret = glDDS7->DeleteAttachedSurface(dwFlags, ((glDirectDrawSurface1*)lpDDSAttachedSurface)->GetDDS7());
|
| 1725 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 1726 | + DeleteAttach((glDirectDrawSurface1*)lpDDSAttachedSurface);
|
| 1727 | + TRACE_EXIT(23, ret);
|
| 1728 | + return ret;
|
1663 | 1729 | }
|
1664 | 1730 | HRESULT WINAPI glDirectDrawSurface1::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
|
1665 | 1731 | {
|
— | — | @@ -1855,7 +1921,10 @@ |
1856 | 1922 | TRACE_ENTER(2,14,this,14,gl_DDS7);
|
1857 | 1923 | glDDS7 = gl_DDS7;
|
1858 | 1924 | refcount = 1;
|
1859 | | - TRACE_EXIT(-1,0);
|
| 1925 | + attachments = (glDirectDrawSurface2**)malloc(16 * sizeof(glDirectDrawSurface2*));
|
| 1926 | + attachcount = 0;
|
| 1927 | + maxattach = 16;
|
| 1928 | + TRACE_EXIT(-1, 0);
|
1860 | 1929 | }
|
1861 | 1930 | glDirectDrawSurface2::~glDirectDrawSurface2()
|
1862 | 1931 | {
|
— | — | @@ -1862,7 +1931,18 @@ |
1863 | 1932 | TRACE_ENTER(1,14,this);
|
1864 | 1933 | glDDS7->dds2 = NULL;
|
1865 | 1934 | glDDS7->Release();
|
1866 | | - TRACE_EXIT(-1,0);
|
| 1935 | + if (attachments)
|
| 1936 | + {
|
| 1937 | + if (attachcount)
|
| 1938 | + {
|
| 1939 | + for (int i = 0; i < attachcount; i++)
|
| 1940 | + {
|
| 1941 | + if (attachments[i]) attachments[i]->Release();
|
| 1942 | + }
|
| 1943 | + }
|
| 1944 | + free(attachments);
|
| 1945 | + }
|
| 1946 | + TRACE_EXIT(-1, 0);
|
1867 | 1947 | }
|
1868 | 1948 | HRESULT WINAPI glDirectDrawSurface2::QueryInterface(REFIID riid, void** ppvObj)
|
1869 | 1949 | {
|
— | — | @@ -1896,12 +1976,60 @@ |
1897 | 1977 | TRACE_EXIT(8,ret);
|
1898 | 1978 | return ret;
|
1899 | 1979 | }
|
| 1980 | +void glDirectDrawSurface2::AddAttach(glDirectDrawSurface2 *attach)
|
| 1981 | +{
|
| 1982 | + bool emptyspace = false;
|
| 1983 | + int index;
|
| 1984 | + for (int i = 0; i < attachcount; i++)
|
| 1985 | + {
|
| 1986 | + if (!attachments[i])
|
| 1987 | + {
|
| 1988 | + emptyspace = true;
|
| 1989 | + index = i;
|
| 1990 | + break;
|
| 1991 | + }
|
| 1992 | + }
|
| 1993 | + if (emptyspace) attachments[index] = attach;
|
| 1994 | + else
|
| 1995 | + {
|
| 1996 | + attachcount++;
|
| 1997 | + if (attachcount >= maxattach)
|
| 1998 | + {
|
| 1999 | + glDirectDrawSurface2 **newattach = (glDirectDrawSurface2**)realloc(attachments,
|
| 2000 | + (maxattach + 16)*sizeof(glDirectDrawSurface2*));
|
| 2001 | + if (newattach)
|
| 2002 | + {
|
| 2003 | + maxattach += 16;
|
| 2004 | + attachments = newattach;
|
| 2005 | + }
|
| 2006 | + }
|
| 2007 | + attachments[attachcount-1] = attach;
|
| 2008 | + }
|
| 2009 | + attach->AddRef();
|
| 2010 | +}
|
| 2011 | +void glDirectDrawSurface2::DeleteAttach(glDirectDrawSurface2 *attach)
|
| 2012 | +{
|
| 2013 | + if (!attachcount) return;
|
| 2014 | + for (int i = 0; i < attachcount; i++)
|
| 2015 | + {
|
| 2016 | + if (attachments[i] == attach)
|
| 2017 | + {
|
| 2018 | + attach->Release();
|
| 2019 | + attachments[i] = NULL;
|
| 2020 | + return;
|
| 2021 | + }
|
| 2022 | + }
|
| 2023 | +}
|
1900 | 2024 | HRESULT WINAPI glDirectDrawSurface2::AddAttachedSurface(LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface)
|
1901 | 2025 | {
|
1902 | 2026 | TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
1903 | 2027 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1904 | 2028 | if(!lpDDSAttachedSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1905 | | - TRACE_RET(HRESULT,23,glDDS7->AddAttachedSurface(((glDirectDrawSurface2*)lpDDSAttachedSurface)->GetDDS7()));
|
| 2029 | + HRESULT ret = glDDS7->AddAttachedSurface(((glDirectDrawSurface2*)lpDDSAttachedSurface)->GetDDS7());
|
| 2030 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2031 | + AddAttach((glDirectDrawSurface2*)lpDDSAttachedSurface);
|
| 2032 | + TRACE_EXIT(23, ret);
|
| 2033 | + return ret;
|
1906 | 2034 | }
|
1907 | 2035 | HRESULT WINAPI glDirectDrawSurface2::AddOverlayDirtyRect(LPRECT lpRect)
|
1908 | 2036 | {
|
— | — | @@ -1946,7 +2074,11 @@ |
1947 | 2075 | {
|
1948 | 2076 | TRACE_ENTER(3,14,this,9,dwFlags,14,lpDDSAttachedSurface);
|
1949 | 2077 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1950 | | - TRACE_RET(HRESULT,23,glDDS7->DeleteAttachedSurface(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface));
|
| 2078 | + HRESULT ret = glDDS7->DeleteAttachedSurface(dwFlags, ((glDirectDrawSurface2*)lpDDSAttachedSurface)->GetDDS7());
|
| 2079 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2080 | + DeleteAttach((glDirectDrawSurface2*)lpDDSAttachedSurface);
|
| 2081 | + TRACE_EXIT(23, ret);
|
| 2082 | + return ret;
|
1951 | 2083 | }
|
1952 | 2084 | HRESULT WINAPI glDirectDrawSurface2::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
|
1953 | 2085 | {
|
— | — | @@ -2166,7 +2298,10 @@ |
2167 | 2299 | TRACE_ENTER(2,14,this,14,gl_DDS7);
|
2168 | 2300 | glDDS7 = gl_DDS7;
|
2169 | 2301 | refcount = 1;
|
2170 | | - TRACE_EXIT(-1,0);
|
| 2302 | + attachments = (glDirectDrawSurface3**)malloc(16 * sizeof(glDirectDrawSurface3*));
|
| 2303 | + attachcount = 0;
|
| 2304 | + maxattach = 16;
|
| 2305 | + TRACE_EXIT(-1, 0);
|
2171 | 2306 | }
|
2172 | 2307 | glDirectDrawSurface3::~glDirectDrawSurface3()
|
2173 | 2308 | {
|
— | — | @@ -2173,7 +2308,18 @@ |
2174 | 2309 | TRACE_ENTER(1,14,this);
|
2175 | 2310 | glDDS7->dds3 = NULL;
|
2176 | 2311 | glDDS7->Release();
|
2177 | | - TRACE_EXIT(-1,0);
|
| 2312 | + if (attachments)
|
| 2313 | + {
|
| 2314 | + if (attachcount)
|
| 2315 | + {
|
| 2316 | + for (int i = 0; i < attachcount; i++)
|
| 2317 | + {
|
| 2318 | + if (attachments[i]) attachments[i]->Release();
|
| 2319 | + }
|
| 2320 | + }
|
| 2321 | + free(attachments);
|
| 2322 | + }
|
| 2323 | + TRACE_EXIT(-1, 0);
|
2178 | 2324 | }
|
2179 | 2325 | HRESULT WINAPI glDirectDrawSurface3::QueryInterface(REFIID riid, void** ppvObj)
|
2180 | 2326 | {
|
— | — | @@ -2208,12 +2354,60 @@ |
2209 | 2355 | TRACE_EXIT(8,ret);
|
2210 | 2356 | return ret;
|
2211 | 2357 | }
|
| 2358 | +void glDirectDrawSurface3::AddAttach(glDirectDrawSurface3 *attach)
|
| 2359 | +{
|
| 2360 | + bool emptyspace = false;
|
| 2361 | + int index;
|
| 2362 | + for (int i = 0; i < attachcount; i++)
|
| 2363 | + {
|
| 2364 | + if (!attachments[i])
|
| 2365 | + {
|
| 2366 | + emptyspace = true;
|
| 2367 | + index = i;
|
| 2368 | + break;
|
| 2369 | + }
|
| 2370 | + }
|
| 2371 | + if (emptyspace) attachments[index] = attach;
|
| 2372 | + else
|
| 2373 | + {
|
| 2374 | + attachcount++;
|
| 2375 | + if (attachcount >= maxattach)
|
| 2376 | + {
|
| 2377 | + glDirectDrawSurface3 **newattach = (glDirectDrawSurface3**)realloc(attachments,
|
| 2378 | + (maxattach + 16)*sizeof(glDirectDrawSurface3*));
|
| 2379 | + if (newattach)
|
| 2380 | + {
|
| 2381 | + maxattach += 16;
|
| 2382 | + attachments = newattach;
|
| 2383 | + }
|
| 2384 | + }
|
| 2385 | + attachments[attachcount-1] = attach;
|
| 2386 | + }
|
| 2387 | + attach->AddRef();
|
| 2388 | +}
|
| 2389 | +void glDirectDrawSurface3::DeleteAttach(glDirectDrawSurface3 *attach)
|
| 2390 | +{
|
| 2391 | + if (!attachcount) return;
|
| 2392 | + for (int i = 0; i < attachcount; i++)
|
| 2393 | + {
|
| 2394 | + if (attachments[i] == attach)
|
| 2395 | + {
|
| 2396 | + attach->Release();
|
| 2397 | + attachments[i] = NULL;
|
| 2398 | + return;
|
| 2399 | + }
|
| 2400 | + }
|
| 2401 | +}
|
2212 | 2402 | HRESULT WINAPI glDirectDrawSurface3::AddAttachedSurface(LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface)
|
2213 | 2403 | {
|
2214 | 2404 | TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
2215 | 2405 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2216 | 2406 | if(!lpDDSAttachedSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
2217 | | - TRACE_RET(HRESULT,23,glDDS7->AddAttachedSurface(((glDirectDrawSurface3*)lpDDSAttachedSurface)->GetDDS7()));
|
| 2407 | + HRESULT ret = glDDS7->AddAttachedSurface(((glDirectDrawSurface3*)lpDDSAttachedSurface)->GetDDS7());
|
| 2408 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2409 | + AddAttach((glDirectDrawSurface3*)lpDDSAttachedSurface);
|
| 2410 | + TRACE_EXIT(23, ret);
|
| 2411 | + return ret;
|
2218 | 2412 | }
|
2219 | 2413 | HRESULT WINAPI glDirectDrawSurface3::AddOverlayDirtyRect(LPRECT lpRect)
|
2220 | 2414 | {
|
— | — | @@ -2258,7 +2452,11 @@ |
2259 | 2453 | {
|
2260 | 2454 | TRACE_ENTER(3,14,this,9,dwFlags,14,lpDDSAttachedSurface);
|
2261 | 2455 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2262 | | - TRACE_RET(HRESULT,23,glDDS7->DeleteAttachedSurface(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface));
|
| 2456 | + HRESULT ret = glDDS7->DeleteAttachedSurface(dwFlags, ((glDirectDrawSurface3*)lpDDSAttachedSurface)->GetDDS7());
|
| 2457 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2458 | + DeleteAttach((glDirectDrawSurface3*)lpDDSAttachedSurface);
|
| 2459 | + TRACE_EXIT(23, ret);
|
| 2460 | + return ret;
|
2263 | 2461 | }
|
2264 | 2462 | HRESULT WINAPI glDirectDrawSurface3::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
|
2265 | 2463 | {
|
— | — | @@ -2485,7 +2683,10 @@ |
2486 | 2684 | TRACE_ENTER(2,14,this,14,gl_DDS7);
|
2487 | 2685 | glDDS7 = gl_DDS7;
|
2488 | 2686 | refcount = 1;
|
2489 | | - TRACE_EXIT(-1,0);
|
| 2687 | + attachments = (glDirectDrawSurface4**)malloc(16 * sizeof(glDirectDrawSurface4*));
|
| 2688 | + attachcount = 0;
|
| 2689 | + maxattach = 16;
|
| 2690 | + TRACE_EXIT(-1, 0);
|
2490 | 2691 | }
|
2491 | 2692 | glDirectDrawSurface4::~glDirectDrawSurface4()
|
2492 | 2693 | {
|
— | — | @@ -2492,6 +2693,17 @@ |
2493 | 2694 | TRACE_ENTER(1,14,this);
|
2494 | 2695 | glDDS7->dds4 = NULL;
|
2495 | 2696 | glDDS7->Release();
|
| 2697 | + if (attachments)
|
| 2698 | + {
|
| 2699 | + if (attachcount)
|
| 2700 | + {
|
| 2701 | + for (int i = 0; i < attachcount; i++)
|
| 2702 | + {
|
| 2703 | + if (attachments[i]) attachments[i]->Release();
|
| 2704 | + }
|
| 2705 | + }
|
| 2706 | + free(attachments);
|
| 2707 | + }
|
2496 | 2708 | TRACE_EXIT(-1,0);
|
2497 | 2709 | }
|
2498 | 2710 | HRESULT WINAPI glDirectDrawSurface4::QueryInterface(REFIID riid, void** ppvObj)
|
— | — | @@ -2527,11 +2739,59 @@ |
2528 | 2740 | TRACE_EXIT(8,ret);
|
2529 | 2741 | return ret;
|
2530 | 2742 | }
|
| 2743 | +void glDirectDrawSurface4::AddAttach(glDirectDrawSurface4 *attach)
|
| 2744 | +{
|
| 2745 | + bool emptyspace = false;
|
| 2746 | + int index;
|
| 2747 | + for (int i = 0; i < attachcount; i++)
|
| 2748 | + {
|
| 2749 | + if (!attachments[i])
|
| 2750 | + {
|
| 2751 | + emptyspace = true;
|
| 2752 | + index = i;
|
| 2753 | + break;
|
| 2754 | + }
|
| 2755 | + }
|
| 2756 | + if (emptyspace) attachments[index] = attach;
|
| 2757 | + else
|
| 2758 | + {
|
| 2759 | + attachcount++;
|
| 2760 | + if (attachcount >= maxattach)
|
| 2761 | + {
|
| 2762 | + glDirectDrawSurface4 **newattach = (glDirectDrawSurface4**)realloc(attachments,
|
| 2763 | + (maxattach + 16)*sizeof(glDirectDrawSurface4*));
|
| 2764 | + if (newattach)
|
| 2765 | + {
|
| 2766 | + maxattach += 16;
|
| 2767 | + attachments = newattach;
|
| 2768 | + }
|
| 2769 | + }
|
| 2770 | + attachments[attachcount-1] = attach;
|
| 2771 | + }
|
| 2772 | + attach->AddRef();
|
| 2773 | +}
|
| 2774 | +void glDirectDrawSurface4::DeleteAttach(glDirectDrawSurface4 *attach)
|
| 2775 | +{
|
| 2776 | + if (!attachcount) return;
|
| 2777 | + for (int i = 0; i < attachcount; i++)
|
| 2778 | + {
|
| 2779 | + if (attachments[i] == attach)
|
| 2780 | + {
|
| 2781 | + attach->Release();
|
| 2782 | + attachments[i] = NULL;
|
| 2783 | + return;
|
| 2784 | + }
|
| 2785 | + }
|
| 2786 | +}
|
2531 | 2787 | HRESULT WINAPI glDirectDrawSurface4::AddAttachedSurface(LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface)
|
2532 | 2788 | {
|
2533 | 2789 | TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
2534 | 2790 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2535 | | - TRACE_RET(HRESULT,23,glDDS7->AddAttachedSurface(((glDirectDrawSurface4*)lpDDSAttachedSurface)->GetDDS7()));
|
| 2791 | + HRESULT ret = glDDS7->AddAttachedSurface(((glDirectDrawSurface4*)lpDDSAttachedSurface)->GetDDS7());
|
| 2792 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2793 | + AddAttach((glDirectDrawSurface4*)lpDDSAttachedSurface);
|
| 2794 | + TRACE_EXIT(23, ret);
|
| 2795 | + return ret;
|
2536 | 2796 | }
|
2537 | 2797 | HRESULT WINAPI glDirectDrawSurface4::AddOverlayDirtyRect(LPRECT lpRect)
|
2538 | 2798 | {
|
— | — | @@ -2576,7 +2836,11 @@ |
2577 | 2837 | {
|
2578 | 2838 | TRACE_ENTER(3,14,this,9,dwFlags,14,lpDDSAttachedSurface);
|
2579 | 2839 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2580 | | - TRACE_RET(HRESULT,23,glDDS7->DeleteAttachedSurface(dwFlags,(LPDIRECTDRAWSURFACE7)lpDDSAttachedSurface));
|
| 2840 | + HRESULT ret = glDDS7->DeleteAttachedSurface(dwFlags, ((glDirectDrawSurface4*)lpDDSAttachedSurface)->GetDDS7());
|
| 2841 | + if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2842 | + DeleteAttach((glDirectDrawSurface4*)lpDDSAttachedSurface);
|
| 2843 | + TRACE_EXIT(23, ret);
|
| 2844 | + return ret;
|
2581 | 2845 | }
|
2582 | 2846 | HRESULT WINAPI glDirectDrawSurface4::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpEnumSurfacesCallback)
|
2583 | 2847 | {
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -198,9 +198,14 @@ |
199 | 199 | HRESULT WINAPI UpdateOverlayDisplay(DWORD dwFlags);
|
200 | 200 | HRESULT WINAPI UpdateOverlayZOrder(DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSReference);
|
201 | 201 | glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
|
| 202 | + void AddAttach(glDirectDrawSurface1 *attach);
|
| 203 | + void DeleteAttach(glDirectDrawSurface1 *attach);
|
202 | 204 | private:
|
203 | 205 | UINT refcount;
|
204 | 206 | glDirectDrawSurface7 *glDDS7;
|
| 207 | + glDirectDrawSurface1 **attachments;
|
| 208 | + int attachcount;
|
| 209 | + int maxattach;
|
205 | 210 | };
|
206 | 211 | class glDirectDrawSurface2 : public IDirectDrawSurface2
|
207 | 212 | {
|
— | — | @@ -249,9 +254,14 @@ |
250 | 255 | HRESULT WINAPI PageLock(DWORD dwFlags);
|
251 | 256 | HRESULT WINAPI PageUnlock(DWORD dwFlags);
|
252 | 257 | glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
|
| 258 | + void AddAttach(glDirectDrawSurface2 *attach);
|
| 259 | + void DeleteAttach(glDirectDrawSurface2 *attach);
|
253 | 260 | private:
|
254 | 261 | UINT refcount;
|
255 | 262 | glDirectDrawSurface7 *glDDS7;
|
| 263 | + glDirectDrawSurface2 **attachments;
|
| 264 | + int attachcount;
|
| 265 | + int maxattach;
|
256 | 266 | };
|
257 | 267 | class glDirectDrawSurface3 : public IDirectDrawSurface3
|
258 | 268 | {
|
— | — | @@ -302,9 +312,14 @@ |
303 | 313 | // ddraw 3+ api
|
304 | 314 | HRESULT WINAPI SetSurfaceDesc(LPDDSURFACEDESC lpddsd2, DWORD dwFlags);
|
305 | 315 | glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
|
| 316 | + void AddAttach(glDirectDrawSurface3 *attach);
|
| 317 | + void DeleteAttach(glDirectDrawSurface3 *attach);
|
306 | 318 | private:
|
307 | 319 | UINT refcount;
|
308 | 320 | glDirectDrawSurface7 *glDDS7;
|
| 321 | + glDirectDrawSurface3 **attachments;
|
| 322 | + int attachcount;
|
| 323 | + int maxattach;
|
309 | 324 | };
|
310 | 325 | class glDirectDrawSurface4 : public IDirectDrawSurface4
|
311 | 326 | {
|
— | — | @@ -361,8 +376,13 @@ |
362 | 377 | HRESULT WINAPI GetUniquenessValue(LPDWORD lpValue);
|
363 | 378 | HRESULT WINAPI ChangeUniquenessValue();
|
364 | 379 | glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
|
| 380 | + void AddAttach(glDirectDrawSurface4 *attach);
|
| 381 | + void DeleteAttach(glDirectDrawSurface4 *attach);
|
365 | 382 | private:
|
366 | 383 | UINT refcount;
|
367 | 384 | glDirectDrawSurface7 *glDDS7;
|
| 385 | + glDirectDrawSurface4 **attachments;
|
| 386 | + int attachcount;
|
| 387 | + int maxattach;
|
368 | 388 | };
|
369 | 389 | #endif //_GLDIRECTDRAWSURFACE_H
|