Index: ddraw/glDirectDraw.cpp |
— | — | @@ -968,7 +968,7 @@ |
969 | 969 | ZeroMemory(&surfaces[surfacecountmax], 1024 * sizeof(glDirectDrawSurface7 *));
|
970 | 970 | surfacecountmax += 1024;
|
971 | 971 | }
|
972 | | - surfaces[surfacecount - 1] = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version);
|
| 972 | + surfaces[surfacecount - 1] = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version, NULL);
|
973 | 973 | if (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
974 | 974 | {
|
975 | 975 | primary = surfaces[surfacecount - 1];
|
— | — | @@ -979,7 +979,7 @@ |
980 | 980 | else
|
981 | 981 | {
|
982 | 982 | if (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
983 | | - *lplpDDSurface = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version);
|
| 983 | + *lplpDDSurface = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version, NULL);
|
984 | 984 | }
|
985 | 985 | TRACE_VAR("*lplpDDSurface",14,*lplpDDSurface);
|
986 | 986 | TRACE_EXIT(23,error);
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 |
|
40 | 40 | // DDRAW7 routines
|
41 | 41 | glDirectDrawSurface7::glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error,
|
42 | | - glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel, int version)
|
| 42 | + glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel, int version, glDirectDrawSurface7 *front)
|
43 | 43 | {
|
44 | 44 | TRACE_ENTER(5,14,this,14,lpDD7,14,lpDDSurfaceDesc2,14,error,14,palettein);
|
45 | 45 | this->version = version;
|
— | — | @@ -207,6 +207,7 @@ |
208 | 208 | bitmapinfo->bmiHeader.biHeight = -(signed)ddsd.dwHeight;
|
209 | 209 | bitmapinfo->bmiHeader.biPlanes = 1;
|
210 | 210 | backbuffer = NULL;
|
| 211 | + backbufferwraparound = NULL;
|
211 | 212 | if ((ddsd.ddsCaps.dwCaps & DDSCAPS_MIPMAP) && !(ddsd.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL))
|
212 | 213 | {
|
213 | 214 | if (!(ddsd.dwFlags & DDSD_MIPMAPCOUNT))
|
— | — | @@ -332,7 +333,7 @@ |
333 | 334 | newdesc.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
|
334 | 335 | newdesc.dwMipMapCount = ddsd.dwMipMapCount - 1;
|
335 | 336 | HRESULT miperror;
|
336 | | - if(newdesc.dwMipMapCount) miptexture = new glDirectDrawSurface7(lpDD7, &newdesc, &miperror, palette, texture, miplevel + 1, version);
|
| 337 | + if(newdesc.dwMipMapCount) miptexture = new glDirectDrawSurface7(lpDD7, &newdesc, &miperror, palette, texture, miplevel + 1, version, NULL);
|
337 | 338 | }
|
338 | 339 |
|
339 | 340 | if(ddsd.ddpfPixelFormat.dwRGBBitCount > 8)
|
— | — | @@ -367,9 +368,12 @@ |
368 | 369 | ddsdBack.dwBackBufferCount--;
|
369 | 370 | ddsdBack.ddsCaps.dwCaps |= DDSCAPS_BACKBUFFER;
|
370 | 371 | ddsdBack.ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
|
371 | | - backbuffer = new glDirectDrawSurface7(ddInterface,&ddsdBack,error,palette,parenttex,miplevel,version);
|
| 372 | + backbuffer = new glDirectDrawSurface7(ddInterface,&ddsdBack,error,palette,parenttex,miplevel,version,front?front:this);
|
372 | 373 | }
|
373 | | - else if (ddsd.dwFlags & DDSD_BACKBUFFERCOUNT){}
|
| 374 | + else if (ddsd.dwFlags & DDSD_BACKBUFFERCOUNT)
|
| 375 | + {
|
| 376 | + backbufferwraparound = front;
|
| 377 | + }
|
374 | 378 | else *error = DDERR_INVALIDPARAMS;
|
375 | 379 | }
|
376 | 380 | }
|
— | — | @@ -1035,6 +1039,20 @@ |
1036 | 1040 | return DD_OK;
|
1037 | 1041 | }
|
1038 | 1042 | }
|
| 1043 | + if (backbufferwraparound)
|
| 1044 | + {
|
| 1045 | + backbufferwraparound->GetCaps(&ddsComp);
|
| 1046 | + memcpy(&comp1, lpDDSCaps, sizeof(unsigned __int64));
|
| 1047 | + memcpy(&comp2, &ddsComp, sizeof(unsigned __int64));
|
| 1048 | + if ((comp1 & comp2) == comp1)
|
| 1049 | + {
|
| 1050 | + *lplpDDAttachedSurface = backbufferwraparound;
|
| 1051 | + backbufferwraparound->AddRef();
|
| 1052 | + TRACE_VAR("*lplpDDAttachedSurface", 14, *lplpDDAttachedSurface);
|
| 1053 | + TRACE_EXIT(23, DD_OK);
|
| 1054 | + return DD_OK;
|
| 1055 | + }
|
| 1056 | + }
|
1039 | 1057 | if(zbuffer)
|
1040 | 1058 | {
|
1041 | 1059 | zbuffer->GetCaps(&ddsComp);
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -40,7 +40,8 @@ |
41 | 41 | class glDirectDrawSurface7 : public IDirectDrawSurface7
|
42 | 42 | {
|
43 | 43 | public:
|
44 | | - glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error, glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel, int version);
|
| 44 | + glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error, glDirectDrawPalette *palettein,
|
| 45 | + TEXTURE *parenttex, DWORD miplevel, int version, glDirectDrawSurface7 *front);
|
45 | 46 | virtual ~glDirectDrawSurface7();
|
46 | 47 | // ddraw 1+ api
|
47 | 48 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
— | — | @@ -161,6 +162,7 @@ |
162 | 163 | glDirectDrawSurface7 *zbuffer;
|
163 | 164 | glDirectDrawSurface7 *miptexture;
|
164 | 165 | glDirectDrawSurface7 *backbuffer;
|
| 166 | + glDirectDrawSurface7 *backbufferwraparound;
|
165 | 167 | private:
|
166 | 168 | int swapinterval;
|
167 | 169 | ULONG refcount7, refcount4, refcount3, refcount2, refcount1;
|