DXGL r499 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r498‎ | r499 | r500 >
Date:23:44, 26 August 2014
Author:admin
Status:new
Tags:
Comment:
More mipmap work.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1975,7 +1975,11 @@
19761976 if(!lpDDSurfaceDesc) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
19771977 if(lpDDSurfaceDesc->dwSize < sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
19781978 LPDIRECTDRAWSURFACE7 lpDDS7;
1979 - HRESULT err = glDD7->CreateSurface2((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter,TRUE);
 1979+ DDSURFACEDESC2 ddsd2;
 1980+ ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
 1981+ memcpy(&ddsd2, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
 1982+ ddsd2.dwSize = sizeof(DDSURFACEDESC2);
 1983+ HRESULT err = glDD7->CreateSurface2(&ddsd2,&lpDDS7,pUnkOuter,TRUE);
19801984 if(err == DD_OK)
19811985 {
19821986 lpDDS7->QueryInterface(IID_IDirectDrawSurface,(LPVOID*) lplpDDSurface);
@@ -2179,7 +2183,11 @@
21802184 if(!lpDDSurfaceDesc) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
21812185 if(lpDDSurfaceDesc->dwSize < sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
21822186 LPDIRECTDRAWSURFACE7 lpDDS7;
2183 - HRESULT err = glDD7->CreateSurface2((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter,TRUE);
 2187+ DDSURFACEDESC2 ddsd2;
 2188+ ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
 2189+ memcpy(&ddsd2, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
 2190+ ddsd2.dwSize = sizeof(DDSURFACEDESC2);
 2191+ HRESULT err = glDD7->CreateSurface2(&ddsd2, &lpDDS7, pUnkOuter, TRUE);
21842192 if(err == DD_OK)
21852193 {
21862194 lpDDS7->QueryInterface(IID_IDirectDrawSurface,(LPVOID*) lplpDDSurface);
Index: ddraw/glDirectDrawSurface.cpp
@@ -74,6 +74,7 @@
7575 ddInterface = (glDirectDraw7 *)lpDD7;
7676 hRC = ddInterface->renderer->hRC;
7777 ddsd = *lpDDSurfaceDesc2;
 78+ miptexture = NULL;
7879 LONG sizes[6];
7980 ddInterface->GetSizes(sizes);
8081 if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
@@ -877,19 +878,23 @@
878879 TRACE_ENTER(3,14,this,14,lpDDSCaps,14,lplpDDAttachedSurface);
879880 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
880881 DDSCAPS2 ddsComp;
881 - if (backbuffer) backbuffer->GetCaps(&ddsComp);
 882+ ZeroMemory(&ddsComp, sizeof(DDSCAPS2));
882883 unsigned __int64 comp1,comp2;
883 - memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
884 - memcpy(&comp2,&ddsComp,sizeof(unsigned __int64));
885 - if((comp1 & comp2) == comp1)
886 - {
887 - *lplpDDAttachedSurface = backbuffer;
888 - backbuffer->AddRef();
889 - TRACE_VAR("*lplpDDAttachedSurface",14,*lplpDDAttachedSurface);
890 - TRACE_EXIT(23,DD_OK);
891 - return DD_OK;
 884+ if (backbuffer)
 885+ {
 886+ backbuffer->GetCaps(&ddsComp);
 887+ memcpy(&comp1, lpDDSCaps, sizeof(unsigned __int64));
 888+ memcpy(&comp2, &ddsComp, sizeof(unsigned __int64));
 889+ if ((comp1 & comp2) == comp1)
 890+ {
 891+ *lplpDDAttachedSurface = backbuffer;
 892+ backbuffer->AddRef();
 893+ TRACE_VAR("*lplpDDAttachedSurface", 14, *lplpDDAttachedSurface);
 894+ TRACE_EXIT(23, DD_OK);
 895+ return DD_OK;
 896+ }
892897 }
893 - else if(zbuffer)
 898+ if(zbuffer)
894899 {
895900 zbuffer->GetCaps(&ddsComp);
896901 memcpy(&comp1,lpDDSCaps,sizeof(unsigned __int64));
@@ -903,6 +908,21 @@
904909 return DD_OK;
905910 }
906911 }
 912+ if (miptexture)
 913+ {
 914+ miptexture->GetCaps(&ddsComp);
 915+ memcpy(&comp1, lpDDSCaps, sizeof(unsigned __int64));
 916+ memcpy(&comp2, &ddsComp, sizeof(unsigned __int64));
 917+ if ((comp1 & comp2) == comp1)
 918+ {
 919+ *lplpDDAttachedSurface = miptexture;
 920+ miptexture->AddRef();
 921+ TRACE_VAR("*lplpDDAttachedSurface", 14, *lplpDDAttachedSurface);
 922+ TRACE_EXIT(23, DD_OK);
 923+ return DD_OK;
 924+ }
 925+ }
 926+
907927 TRACE_EXIT(23,DDERR_NOTFOUND);
908928 ERR(DDERR_NOTFOUND);
909929 }