Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -133,6 +133,7 @@ |
134 | 134 | dds4 = NULL;
|
135 | 135 | buffer = gdibuffer = NULL;
|
136 | 136 | bigbuffer = NULL;
|
| 137 | + zbuffer = NULL;
|
137 | 138 | DWORD colormasks[3];
|
138 | 139 | if(copysurface)
|
139 | 140 | {
|
— | — | @@ -447,6 +448,7 @@ |
448 | 449 | if(backbuffer) backbuffer->Release();
|
449 | 450 | if(buffer) free(buffer);
|
450 | 451 | if(bigbuffer) free(bigbuffer);
|
| 452 | + if(zbuffer) zbuffer->Release();
|
451 | 453 | ddInterface->Release();
|
452 | 454 | }
|
453 | 455 | HRESULT WINAPI glDirectDrawSurface7::QueryInterface(REFIID riid, void** ppvObj)
|
— | — | @@ -538,8 +540,18 @@ |
539 | 541 | }
|
540 | 542 | HRESULT WINAPI glDirectDrawSurface7::AddAttachedSurface(LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface)
|
541 | 543 | {
|
542 | | - FIXME("glDirectDrawSurface7::AddAttachedSurface: stub\n");
|
543 | | - ERR(DDERR_GENERIC);
|
| 544 | + if(zbuffer) ERR(DDERR_SURFACEALREADYATTACHED);
|
| 545 | + glDirectDrawSurface7 *attached = (glDirectDrawSurface7 *)lpDDSAttachedSurface;
|
| 546 | + DDSURFACEDESC2 ddsd;
|
| 547 | + ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 548 | + attached->GetSurfaceDesc(&ddsd);
|
| 549 | + if(ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)
|
| 550 | + {
|
| 551 | + attached->AddRef();
|
| 552 | + zbuffer = attached;
|
| 553 | + return DD_OK;
|
| 554 | + }
|
| 555 | + else return DDERR_CANNOTATTACHSURFACE;
|
544 | 556 | }
|
545 | 557 | HRESULT WINAPI glDirectDrawSurface7::AddOverlayDirtyRect(LPRECT lpRect)
|
546 | 558 | {
|
— | — | @@ -743,8 +755,13 @@ |
744 | 756 | }
|
745 | 757 | HRESULT WINAPI glDirectDrawSurface7::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface)
|
746 | 758 | {
|
747 | | - FIXME("glDirectDrawSurface7::DeleteAttachedSurface: stub\n");
|
748 | | - ERR(DDERR_GENERIC);
|
| 759 | + if(lpDDSAttachedSurface == (LPDIRECTDRAWSURFACE7)zbuffer)
|
| 760 | + {
|
| 761 | + zbuffer->Release();
|
| 762 | + zbuffer = NULL;
|
| 763 | + return DD_OK;
|
| 764 | + }
|
| 765 | + else ERR(DDERR_SURFACENOTATTACHED);
|
749 | 766 | }
|
750 | 767 | HRESULT WINAPI glDirectDrawSurface7::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback)
|
751 | 768 | {
|
— | — | @@ -758,7 +775,6 @@ |
759 | 776 | }
|
760 | 777 | HRESULT WINAPI glDirectDrawSurface7::Flip(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags)
|
761 | 778 | {
|
762 | | - int test;
|
763 | 779 | if(dwFlags & DDFLIP_NOVSYNC) SetSwap(0);
|
764 | 780 | else
|
765 | 781 | {
|
— | — | @@ -817,7 +833,6 @@ |
818 | 834 | HRESULT WINAPI glDirectDrawSurface7::GetAttachedSurface(LPDDSCAPS2 lpDDSCaps, LPDIRECTDRAWSURFACE7 FAR *lplpDDAttachedSurface)
|
819 | 835 | {
|
820 | 836 | DDSCAPS2 ddsComp;
|
821 | | - if(!backbuffer) ERR(DDERR_NOTFOUND);
|
822 | 837 | backbuffer->GetCaps(&ddsComp);
|
823 | 838 | unsigned __int64 comp1,comp2;
|
824 | 839 | memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
|
— | — | @@ -830,8 +845,16 @@ |
831 | 846 | }
|
832 | 847 | else
|
833 | 848 | {
|
834 | | - FIXME("glDirectDrawSurface7::GetAttachedSurface: stub\n");
|
835 | | - ERR(DDERR_GENERIC);
|
| 849 | + zbuffer->GetCaps(&ddsComp);
|
| 850 | + memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
|
| 851 | + memcpy(&comp2,&ddsComp,sizeof(unsigned __int64));
|
| 852 | + if((comp1 & comp2) == comp1)
|
| 853 | + {
|
| 854 | + *lplpDDAttachedSurface = zbuffer;
|
| 855 | + zbuffer->AddRef();
|
| 856 | + return DD_OK;
|
| 857 | + }
|
| 858 | + ERR(DDERR_NOTFOUND);
|
836 | 859 | }
|
837 | 860 | }
|
838 | 861 | HRESULT WINAPI glDirectDrawSurface7::GetBltStatus(DWORD dwFlags)
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | glDirectDrawSurface2 *dds2;
|
108 | 108 | glDirectDrawSurface3 *dds3;
|
109 | 109 | glDirectDrawSurface4 *dds4;
|
110 | | - int flipcount;
|
| 110 | + DWORD flipcount;
|
111 | 111 | GLenum texformat;
|
112 | 112 | GLenum texformat2;
|
113 | 113 | GLint texformat3;
|
— | — | @@ -132,6 +132,7 @@ |
133 | 133 | char *bigbuffer;
|
134 | 134 | char *gdibuffer;
|
135 | 135 | glDirectDrawSurface7 *backbuffer;
|
| 136 | + glDirectDrawSurface7 *zbuffer;
|
136 | 137 | glDirectDrawPalette *palette;
|
137 | 138 | glDirectDrawClipper *clipper;
|
138 | 139 | int pagelocked;
|