DXGL r495 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r494‎ | r495 | r496 >
Date:00:11, 21 August 2014
Author:admin
Status:new
Tags:
Comment:
Add querying render target from D3D device.
Reference count for versions 1, 2, 3, and 4 of IDirectDrawSurface::AddAttachedSurface and DeleteAttachedSurface.
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -200,6 +200,7 @@
201201 glD3D2 = NULL;
202202 glD3D1 = NULL;
203203 glDD7 = gl_DD7;
 204+ glDD7->AddRef();
204205 memcpy(stored_devices, devices, 3 * sizeof(D3DDevice));
205206 TRACE_EXIT(-1, 0);
206207 }
@@ -207,6 +208,7 @@
208209 glDirect3D7::~glDirect3D7()
209210 {
210211 TRACE_ENTER(1,14,this);
 212+ glDD7->Release();
211213 if(glD3D3) glD3D3->Release();
212214 if(glD3D2) glD3D2->Release();
213215 if(glD3D1) glD3D1->Release();
Index: ddraw/glDirect3DDevice.cpp
@@ -504,6 +504,7 @@
505505 return D3D_OK;
506506 }
507507 }
 508+ if (glDDS7) TRACE_RET(HRESULT, 23, glDDS7->QueryInterface(riid, ppvObj));
508509 TRACE_EXIT(23,E_NOINTERFACE);
509510 return E_NOINTERFACE;
510511 }
Index: ddraw/glDirectDraw.cpp
@@ -1046,8 +1046,8 @@
10471047 ddCaps.dwFXCaps = DDFXCAPS_BLTSHRINKX | DDFXCAPS_BLTSHRINKY |
10481048 DDFXCAPS_BLTSTRETCHX | DDFXCAPS_BLTSTRETCHY | DDFXCAPS_BLTMIRRORLEFTRIGHT |
10491049 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 =
10521052 DDSCAPS_BACKBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP |
10531053 DDSCAPS_FRONTBUFFER | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_PALETTE |
10541054 DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE |
Index: ddraw/glDirectDrawSurface.cpp
@@ -702,7 +702,7 @@
703703 {
704704 TRACE_ENTER(6,14,this,8,dwX,8,dwY,14,lpDDSrcSurface,26,lpSrcRect,9,dwTrans);
705705 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);
707707 DDSURFACEDESC2 ddsd;
708708 ddsd.dwSize = sizeof(DDSURFACEDESC2);
709709 lpDDSrcSurface->GetSurfaceDesc(&ddsd);
@@ -862,7 +862,7 @@
863863 TRACE_ENTER(3,14,this,14,lpDDSCaps,14,lplpDDAttachedSurface);
864864 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
865865 DDSCAPS2 ddsComp;
866 - backbuffer->GetCaps(&ddsComp);
 866+ if (backbuffer) backbuffer->GetCaps(&ddsComp);
867867 unsigned __int64 comp1,comp2;
868868 memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
869869 memcpy(&comp2,&ddsComp,sizeof(unsigned __int64));
@@ -1566,7 +1566,21 @@
15671567 TRACE_ENTER(2,14,this,14,gl_DDS7);
15681568 glDDS7 = gl_DDS7;
15691569 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);
15711585 }
15721586 glDirectDrawSurface1::~glDirectDrawSurface1()
15731587 {
@@ -1608,12 +1622,60 @@
16091623 TRACE_EXIT(8,ret);
16101624 return ret;
16111625 }
 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+}
16121670 HRESULT WINAPI glDirectDrawSurface1::AddAttachedSurface(LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
16131671 {
16141672 TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
16151673 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
16161674 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;
16181680 }
16191681 HRESULT WINAPI glDirectDrawSurface1::AddOverlayDirtyRect(LPRECT lpRect)
16201682 {
@@ -1658,7 +1720,11 @@
16591721 {
16601722 TRACE_ENTER(3,14,this,9,dwFlags,14,lpDDSAttachedSurface);
16611723 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;
16631729 }
16641730 HRESULT WINAPI glDirectDrawSurface1::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
16651731 {
@@ -1855,7 +1921,10 @@
18561922 TRACE_ENTER(2,14,this,14,gl_DDS7);
18571923 glDDS7 = gl_DDS7;
18581924 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);
18601929 }
18611930 glDirectDrawSurface2::~glDirectDrawSurface2()
18621931 {
@@ -1862,7 +1931,18 @@
18631932 TRACE_ENTER(1,14,this);
18641933 glDDS7->dds2 = NULL;
18651934 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);
18671947 }
18681948 HRESULT WINAPI glDirectDrawSurface2::QueryInterface(REFIID riid, void** ppvObj)
18691949 {
@@ -1896,12 +1976,60 @@
18971977 TRACE_EXIT(8,ret);
18981978 return ret;
18991979 }
 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+}
19002024 HRESULT WINAPI glDirectDrawSurface2::AddAttachedSurface(LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface)
19012025 {
19022026 TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
19032027 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
19042028 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;
19062034 }
19072035 HRESULT WINAPI glDirectDrawSurface2::AddOverlayDirtyRect(LPRECT lpRect)
19082036 {
@@ -1946,7 +2074,11 @@
19472075 {
19482076 TRACE_ENTER(3,14,this,9,dwFlags,14,lpDDSAttachedSurface);
19492077 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;
19512083 }
19522084 HRESULT WINAPI glDirectDrawSurface2::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
19532085 {
@@ -2166,7 +2298,10 @@
21672299 TRACE_ENTER(2,14,this,14,gl_DDS7);
21682300 glDDS7 = gl_DDS7;
21692301 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);
21712306 }
21722307 glDirectDrawSurface3::~glDirectDrawSurface3()
21732308 {
@@ -2173,7 +2308,18 @@
21742309 TRACE_ENTER(1,14,this);
21752310 glDDS7->dds3 = NULL;
21762311 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);
21782324 }
21792325 HRESULT WINAPI glDirectDrawSurface3::QueryInterface(REFIID riid, void** ppvObj)
21802326 {
@@ -2208,12 +2354,60 @@
22092355 TRACE_EXIT(8,ret);
22102356 return ret;
22112357 }
 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+}
22122402 HRESULT WINAPI glDirectDrawSurface3::AddAttachedSurface(LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface)
22132403 {
22142404 TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
22152405 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
22162406 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;
22182412 }
22192413 HRESULT WINAPI glDirectDrawSurface3::AddOverlayDirtyRect(LPRECT lpRect)
22202414 {
@@ -2258,7 +2452,11 @@
22592453 {
22602454 TRACE_ENTER(3,14,this,9,dwFlags,14,lpDDSAttachedSurface);
22612455 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;
22632461 }
22642462 HRESULT WINAPI glDirectDrawSurface3::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
22652463 {
@@ -2485,7 +2683,10 @@
24862684 TRACE_ENTER(2,14,this,14,gl_DDS7);
24872685 glDDS7 = gl_DDS7;
24882686 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);
24902691 }
24912692 glDirectDrawSurface4::~glDirectDrawSurface4()
24922693 {
@@ -2492,6 +2693,17 @@
24932694 TRACE_ENTER(1,14,this);
24942695 glDDS7->dds4 = NULL;
24952696 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+ }
24962708 TRACE_EXIT(-1,0);
24972709 }
24982710 HRESULT WINAPI glDirectDrawSurface4::QueryInterface(REFIID riid, void** ppvObj)
@@ -2527,11 +2739,59 @@
25282740 TRACE_EXIT(8,ret);
25292741 return ret;
25302742 }
 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+}
25312787 HRESULT WINAPI glDirectDrawSurface4::AddAttachedSurface(LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface)
25322788 {
25332789 TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
25342790 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;
25362796 }
25372797 HRESULT WINAPI glDirectDrawSurface4::AddOverlayDirtyRect(LPRECT lpRect)
25382798 {
@@ -2576,7 +2836,11 @@
25772837 {
25782838 TRACE_ENTER(3,14,this,9,dwFlags,14,lpDDSAttachedSurface);
25792839 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;
25812845 }
25822846 HRESULT WINAPI glDirectDrawSurface4::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpEnumSurfacesCallback)
25832847 {
Index: ddraw/glDirectDrawSurface.h
@@ -198,9 +198,14 @@
199199 HRESULT WINAPI UpdateOverlayDisplay(DWORD dwFlags);
200200 HRESULT WINAPI UpdateOverlayZOrder(DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSReference);
201201 glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
 202+ void AddAttach(glDirectDrawSurface1 *attach);
 203+ void DeleteAttach(glDirectDrawSurface1 *attach);
202204 private:
203205 UINT refcount;
204206 glDirectDrawSurface7 *glDDS7;
 207+ glDirectDrawSurface1 **attachments;
 208+ int attachcount;
 209+ int maxattach;
205210 };
206211 class glDirectDrawSurface2 : public IDirectDrawSurface2
207212 {
@@ -249,9 +254,14 @@
250255 HRESULT WINAPI PageLock(DWORD dwFlags);
251256 HRESULT WINAPI PageUnlock(DWORD dwFlags);
252257 glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
 258+ void AddAttach(glDirectDrawSurface2 *attach);
 259+ void DeleteAttach(glDirectDrawSurface2 *attach);
253260 private:
254261 UINT refcount;
255262 glDirectDrawSurface7 *glDDS7;
 263+ glDirectDrawSurface2 **attachments;
 264+ int attachcount;
 265+ int maxattach;
256266 };
257267 class glDirectDrawSurface3 : public IDirectDrawSurface3
258268 {
@@ -302,9 +312,14 @@
303313 // ddraw 3+ api
304314 HRESULT WINAPI SetSurfaceDesc(LPDDSURFACEDESC lpddsd2, DWORD dwFlags);
305315 glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
 316+ void AddAttach(glDirectDrawSurface3 *attach);
 317+ void DeleteAttach(glDirectDrawSurface3 *attach);
306318 private:
307319 UINT refcount;
308320 glDirectDrawSurface7 *glDDS7;
 321+ glDirectDrawSurface3 **attachments;
 322+ int attachcount;
 323+ int maxattach;
309324 };
310325 class glDirectDrawSurface4 : public IDirectDrawSurface4
311326 {
@@ -361,8 +376,13 @@
362377 HRESULT WINAPI GetUniquenessValue(LPDWORD lpValue);
363378 HRESULT WINAPI ChangeUniquenessValue();
364379 glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
 380+ void AddAttach(glDirectDrawSurface4 *attach);
 381+ void DeleteAttach(glDirectDrawSurface4 *attach);
365382 private:
366383 UINT refcount;
367384 glDirectDrawSurface7 *glDDS7;
 385+ glDirectDrawSurface4 **attachments;
 386+ int attachcount;
 387+ int maxattach;
368388 };
369389 #endif //_GLDIRECTDRAWSURFACE_H