DXGL r63 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r62‎ | r63 | r64 >
Date:21:59, 31 December 2011
Author:admin
Status:new
Tags:
Comment:
Add AddAttachedSurface and DeleteAttachedSurface.
Make GetAttachedSurface support Z buffers.
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -133,6 +133,7 @@
134134 dds4 = NULL;
135135 buffer = gdibuffer = NULL;
136136 bigbuffer = NULL;
 137+ zbuffer = NULL;
137138 DWORD colormasks[3];
138139 if(copysurface)
139140 {
@@ -447,6 +448,7 @@
448449 if(backbuffer) backbuffer->Release();
449450 if(buffer) free(buffer);
450451 if(bigbuffer) free(bigbuffer);
 452+ if(zbuffer) zbuffer->Release();
451453 ddInterface->Release();
452454 }
453455 HRESULT WINAPI glDirectDrawSurface7::QueryInterface(REFIID riid, void** ppvObj)
@@ -538,8 +540,18 @@
539541 }
540542 HRESULT WINAPI glDirectDrawSurface7::AddAttachedSurface(LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface)
541543 {
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;
544556 }
545557 HRESULT WINAPI glDirectDrawSurface7::AddOverlayDirtyRect(LPRECT lpRect)
546558 {
@@ -743,8 +755,13 @@
744756 }
745757 HRESULT WINAPI glDirectDrawSurface7::DeleteAttachedSurface(DWORD dwFlags, LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface)
746758 {
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);
749766 }
750767 HRESULT WINAPI glDirectDrawSurface7::EnumAttachedSurfaces(LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpEnumSurfacesCallback)
751768 {
@@ -758,7 +775,6 @@
759776 }
760777 HRESULT WINAPI glDirectDrawSurface7::Flip(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags)
761778 {
762 - int test;
763779 if(dwFlags & DDFLIP_NOVSYNC) SetSwap(0);
764780 else
765781 {
@@ -817,7 +833,6 @@
818834 HRESULT WINAPI glDirectDrawSurface7::GetAttachedSurface(LPDDSCAPS2 lpDDSCaps, LPDIRECTDRAWSURFACE7 FAR *lplpDDAttachedSurface)
819835 {
820836 DDSCAPS2 ddsComp;
821 - if(!backbuffer) ERR(DDERR_NOTFOUND);
822837 backbuffer->GetCaps(&ddsComp);
823838 unsigned __int64 comp1,comp2;
824839 memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
@@ -830,8 +845,16 @@
831846 }
832847 else
833848 {
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);
836859 }
837860 }
838861 HRESULT WINAPI glDirectDrawSurface7::GetBltStatus(DWORD dwFlags)
Index: ddraw/glDirectDrawSurface.h
@@ -106,7 +106,7 @@
107107 glDirectDrawSurface2 *dds2;
108108 glDirectDrawSurface3 *dds3;
109109 glDirectDrawSurface4 *dds4;
110 - int flipcount;
 110+ DWORD flipcount;
111111 GLenum texformat;
112112 GLenum texformat2;
113113 GLint texformat3;
@@ -132,6 +132,7 @@
133133 char *bigbuffer;
134134 char *gdibuffer;
135135 glDirectDrawSurface7 *backbuffer;
 136+ glDirectDrawSurface7 *zbuffer;
136137 glDirectDrawPalette *palette;
137138 glDirectDrawClipper *clipper;
138139 int pagelocked;