DXGL r56 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r55‎ | r56 | r57 >
Date:20:44, 28 December 2011
Author:admin
Status:new
Tags:
Comment:
Add Z buffer to D3D tests
Modified paths:
  • / (modified) (history)
  • /dxgltest/MultiDD.cpp (modified) (history)
  • /dxgltest/Tests3D.cpp (modified) (history)

Diff [purge]

Index: dxgltest/MultiDD.cpp
@@ -263,6 +263,25 @@
264264 return ret;
265265 }
266266
 267+HRESULT MultiDirectDrawSurface::AddAttachedSurface(MultiDirectDrawSurface *lpDDSAttachedSurface)
 268+{
 269+ switch(version)
 270+ {
 271+ case 1:
 272+ return dds1->AddAttachedSurface(lpDDSAttachedSurface->dds1);
 273+ case 2:
 274+ return dds2->AddAttachedSurface(lpDDSAttachedSurface->dds2);
 275+ case 3:
 276+ return dds3->AddAttachedSurface(lpDDSAttachedSurface->dds3);
 277+ case 4:
 278+ return dds4->AddAttachedSurface(lpDDSAttachedSurface->dds4);
 279+ case 7:
 280+ return dds7->AddAttachedSurface(lpDDSAttachedSurface->dds7);
 281+ default:
 282+ return DDERR_GENERIC;
 283+ }
 284+}
 285+
267286 HRESULT MultiDirectDrawSurface::Lock(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent)
268287 {
269288 switch(version)
Index: dxgltest/Tests3D.cpp
@@ -33,6 +33,7 @@
3434 static MultiDirectDraw *ddinterface;
3535 static MultiDirectDrawSurface *ddsurface;
3636 static MultiDirectDrawSurface *ddsrender;
 37+static MultiDirectDrawSurface *zbuffer;
3738 static IDirect3D7 *d3d7;
3839 static IDirect3DDevice7 *d3d7dev;
3940 static LPDIRECTDRAWCLIPPER ddclipper;
@@ -161,6 +162,15 @@
162163
163164 const TCHAR wndclassname3d[] = _T("D3DTestWndClass");
164165
 166+static HRESULT WINAPI zcallback(DDPIXELFORMAT *ddpf, VOID *context)
 167+{
 168+ if(ddpf->dwFlags == DDPF_ZBUFFER)
 169+ {
 170+ memcpy(context,ddpf,sizeof(DDPIXELFORMAT));
 171+ return D3DENUMRET_CANCEL;
 172+ }
 173+ return D3DENUMRET_OK;
 174+}
165175
166176 void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
167177 int filter, int msaa, double fps, bool fullscreen, bool resizable)
@@ -167,6 +177,7 @@
168178 {
169179 DDSCAPS2 caps;
170180 DDSURFACEDESC2 ddsd;
 181+ DDPIXELFORMAT ddpfz;
171182 BOOL done = false;
172183 ::testnum = testnum;
173184 randnum = (unsigned int)time(NULL);
@@ -271,6 +282,12 @@
272283 }
273284 }
274285 error = ddinterface->QueryInterface(IID_IDirect3D7,(VOID**)&d3d7);
 286+ error = d3d7->EnumZBufferFormats(IID_IDirect3DHALDevice,zcallback,&ddpfz);
 287+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
 288+ ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER|DDSCAPS_VIDEOMEMORY;
 289+ memcpy(&ddsd.ddpfPixelFormat,&ddpfz,sizeof(DDPIXELFORMAT));
 290+ error = ddinterface->CreateSurface(&ddsd,&zbuffer,NULL);
 291+ error = ddsrender->AddAttachedSurface(zbuffer);
275292 error = d3d7->CreateDevice(IID_IDirect3DHALDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
276293 if(error != D3D_OK)
277294 error = d3d7->CreateDevice(IID_IDirect3DRGBDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
@@ -277,7 +294,7 @@
278295 ddsrender->GetSurfaceDesc(&ddsd);
279296 D3DVIEWPORT7 vp = {0,0,ddsd.dwWidth,ddsd.dwHeight,0.0f,1.0f};
280297 error = d3d7dev->SetViewport(&vp);
281 -
 298+ error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
282299 InitTest3D(testnum);
283300 if(!fullscreen) SendMessage(hWnd,WM_PAINT,0,0);
284301 if(testtypes[testnum] == 1)
@@ -414,11 +431,7 @@
415432 ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
416433 if(d3dver >= 3) ddsd.dwSize = sizeof(DDSURFACEDESC2);
417434 else ddsd.dwSize = sizeof(DDSURFACEDESC);
418 - DDBLTFX bltfx;
419 - ZeroMemory(&bltfx,sizeof(DDBLTFX));
420 - bltfx.dwSize = sizeof(DDBLTFX);
421 - bltfx.dwFillColor = 0;
422 - ddsrender->Blt(NULL,NULL,NULL,DDBLT_COLORFILL,&bltfx);
 435+ d3d7dev->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0,1.0,0);
423436 float time = (float)clock() / (float)CLOCKS_PER_SEC;
424437 switch(test)
425438 {
Index: .
Property changes on: .
___________________________________________________________________
Modified: svn:ignore
## -7,3 +7,4 ##
426439 Release
427440 Release no DXGL
428441 *.opensdf
 442+enc_temp_folder