Index: dxgltest/Tests3D.cpp |
— | — | @@ -51,6 +51,7 @@ |
52 | 52 | static WORD mesh[256];
|
53 | 53 | static WORD cube_mesh[] = {0,1,2, 2,1,3, 4,5,6, 6,5,7, 8,9,10, 10,9,11, 12,13,14, 14,13,15, 16,17,18,
|
54 | 54 | 18,17,19, 20,21,22, 22,21,23 };
|
| 55 | +static D3DLIGHT7 lights[8];
|
55 | 56 |
|
56 | 57 | LRESULT CALLBACK D3DWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
57 | 58 | {
|
— | — | @@ -86,6 +87,11 @@ |
87 | 88 | ddsurface->Release();
|
88 | 89 | ddsurface = NULL;
|
89 | 90 | }
|
| 91 | + if(zbuffer)
|
| 92 | + {
|
| 93 | + zbuffer->Release();
|
| 94 | + zbuffer = NULL;
|
| 95 | + }
|
90 | 96 | if(ddclipper)
|
91 | 97 | {
|
92 | 98 | ddclipper->Release();
|
— | — | @@ -283,6 +289,7 @@ |
284 | 290 | }
|
285 | 291 | error = ddinterface->QueryInterface(IID_IDirect3D7,(VOID**)&d3d7);
|
286 | 292 | error = d3d7->EnumZBufferFormats(IID_IDirect3DHALDevice,zcallback,&ddpfz);
|
| 293 | + error = ddsrender->GetSurfaceDesc(&ddsd);
|
287 | 294 | ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
|
288 | 295 | ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER|DDSCAPS_VIDEOMEMORY;
|
289 | 296 | memcpy(&ddsd.ddpfPixelFormat,&ddpfz,sizeof(DDPIXELFORMAT));
|
— | — | @@ -340,14 +347,14 @@ |
341 | 348 |
|
342 | 349 | void MakeCube3D(D3DVECTOR *points, D3DVECTOR *normals, D3DVERTEX *vertices)
|
343 | 350 | {
|
344 | | - points[0] = D3DVECTOR(0.0f,0.0f,0.0f);
|
345 | | - points[1] = D3DVECTOR(0.0f,3.0f,0.0f);
|
346 | | - points[2] = D3DVECTOR(3.0f,0.0f,0.0f);
|
347 | | - points[3] = D3DVECTOR(3.0f,3.0f,0.0f);
|
348 | | - points[4] = D3DVECTOR(3.0f,0.0f,3.0f);
|
349 | | - points[5] = D3DVECTOR(3.0f,3.0f,3.0f);
|
350 | | - points[6] = D3DVECTOR(0.0f,0.0f,3.0f);
|
351 | | - points[7] = D3DVECTOR(0.0f,3.0f,3.0f);
|
| 351 | + points[0] = D3DVECTOR(-2.5f,-2.5f,-2.5f);
|
| 352 | + points[1] = D3DVECTOR(-2.5f,2.5f,-2.5f);
|
| 353 | + points[2] = D3DVECTOR(2.5f,-2.5f,-2.5f);
|
| 354 | + points[3] = D3DVECTOR(2.5f,2.5f,-2.5f);
|
| 355 | + points[4] = D3DVECTOR(2.5f,-2.5f,2.5f);
|
| 356 | + points[5] = D3DVECTOR(2.5f,2.5f,2.5f);
|
| 357 | + points[6] = D3DVECTOR(-2.5f,-2.5f,2.5f);
|
| 358 | + points[7] = D3DVECTOR(-2.5f,2.5f,2.5f);
|
352 | 359 | normals[0] = D3DVECTOR(0.0f,0.0f,-1.0f);
|
353 | 360 | normals[1] = D3DVECTOR(1.0f,0.0f,0.0f);
|
354 | 361 | normals[2] = D3DVECTOR(0.0f,0.0f,1.0f);
|
— | — | @@ -393,11 +400,16 @@ |
394 | 401 | MakeCube3D(points,normals,vertices);
|
395 | 402 | D3DMATERIAL7 material;
|
396 | 403 | ZeroMemory(&material,sizeof(D3DMATERIAL7));
|
397 | | - material.ambient.r = 1.0f;
|
398 | | - material.ambient.g = 1.0f;
|
| 404 | + material.ambient.r = 0.5f;
|
| 405 | + material.ambient.g = 0.5f;
|
399 | 406 | material.ambient.b = 0.0f;
|
| 407 | + material.diffuse.r = 1.0f;
|
| 408 | + material.diffuse.g = 1.0f;
|
| 409 | + material.diffuse.b = 1.0f;
|
400 | 410 | error = d3d7dev->SetMaterial(&material);
|
401 | | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT,0xffffffff);
|
| 411 | + error = d3d7dev->LightEnable(0,TRUE);
|
| 412 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
|
| 413 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0x7f7f7f7f);
|
402 | 414 | mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
403 | 415 | mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
404 | 416 | mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
— | — | @@ -414,7 +426,15 @@ |
415 | 427 | matProj._43 = -1.0f;
|
416 | 428 | matProj._44 = 0.0f;
|
417 | 429 | error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_PROJECTION,&matProj);
|
418 | | -
|
| 430 | + ZeroMemory(&lights[0],sizeof(D3DLIGHT7));
|
| 431 | + lights[0].dltType = D3DLIGHT_DIRECTIONAL;
|
| 432 | + lights[0].dcvDiffuse.r = 1;
|
| 433 | + lights[0].dcvDiffuse.g = 0;
|
| 434 | + lights[0].dcvDiffuse.b = 1;
|
| 435 | + lights[0].dvDirection = D3DVECTOR(5,5,5);
|
| 436 | + lights[0].dvRange = D3DLIGHT_RANGE_MAX;
|
| 437 | + lights[0].dvAttenuation1 = 0.4f;
|
| 438 | + error = d3d7dev->SetLight(0,&lights[0]);
|
419 | 439 | break;
|
420 | 440 | default:
|
421 | 441 | break;
|
— | — | @@ -447,11 +467,15 @@ |
448 | 468 | error = d3d7dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &mat);
|
449 | 469 | error = d3d7dev->BeginScene();
|
450 | 470 | error = d3d7dev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,D3DFVF_VERTEX,vertices,24,cube_mesh,36,0);
|
| 471 | + error = d3d7dev->EndScene();
|
451 | 472 | break;
|
452 | 473 | default:
|
453 | 474 | break;
|
454 | 475 | }
|
455 | | - if(fullscreen) ddsurface->Flip(NULL,DDFLIP_WAIT);
|
| 476 | + if(fullscreen)
|
| 477 | + {
|
| 478 | + if(backbuffers) ddsurface->Flip(NULL,DDFLIP_WAIT);
|
| 479 | + }
|
456 | 480 | else
|
457 | 481 | {
|
458 | 482 | p.x = 0;
|
Index: dxgltest/dxgltest.cpp |
— | — | @@ -251,7 +251,7 @@ |
252 | 252 | const int START_3D = __LINE__;
|
253 | 253 | const TEST_ITEM Tests3D[] =
|
254 | 254 | { // minver maxver buffermin max usesfps defaultfps usestexture usesfsaa name
|
255 | | - {7, 7, 0, 2, true, 60.0, false, true, _T("Basic polygons (DX7)")}
|
| 255 | + {7, 7, 0, 2, true, 60.0, false, true, _T("DrawIndexedPrimitives cube with one light (DX7)")}
|
256 | 256 | };
|
257 | 257 | const int END_3D = __LINE__ - 4;
|
258 | 258 | const int numtests3d = END_3D - START_3D;
|