Index: dxgltest/Tests3D.cpp |
— | — | @@ -134,6 +134,15 @@ |
135 | 135 | {0,0}
|
136 | 136 | };
|
137 | 137 |
|
| 138 | +typedef struct
|
| 139 | +{
|
| 140 | + DWORD texturetype;
|
| 141 | + TCHAR texturefile[MAX_PATH+1];
|
| 142 | + MultiDirectDrawSurface* texture;
|
| 143 | +} VERTEXSHADERSTATE;
|
| 144 | +static VERTEXSHADERSTATE vertexshaderstate;
|
| 145 | +
|
| 146 | +
|
138 | 147 | LRESULT CALLBACK D3DWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
139 | 148 | {
|
140 | 149 | bool paintwnd = true;
|
— | — | @@ -285,7 +294,7 @@ |
286 | 295 | }
|
287 | 296 | if(testnum == 3)
|
288 | 297 | {
|
289 | | - DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_TEXSHADER),NULL,VertexShader7Proc);
|
| 298 | + DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_VERTEXSHADER),NULL,VertexShader7Proc);
|
290 | 299 | return;
|
291 | 300 | }
|
292 | 301 | DDSCAPS2 caps;
|
— | — | @@ -762,6 +771,7 @@ |
763 | 772 | error = d3d7dev->EndScene();
|
764 | 773 | break;
|
765 | 774 | case 2:
|
| 775 | + case 3:
|
766 | 776 | mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
|
767 | 777 | mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
|
768 | 778 | mat._21 = mat._23 = mat._24 = mat._42 = 0.0f;
|
— | — | @@ -1024,6 +1034,7 @@ |
1025 | 1035 | D3DVIEWPORT7 vp;
|
1026 | 1036 | HWND hDisplay;
|
1027 | 1037 | int number;
|
| 1038 | + float f;
|
1028 | 1039 | TCHAR tmpstring[MAX_PATH+1];
|
1029 | 1040 | switch(Msg)
|
1030 | 1041 | {
|
— | — | @@ -1349,6 +1360,52 @@ |
1350 | 1361 | d3d7dev->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE,TRUE);
|
1351 | 1362 | else d3d7dev->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE,FALSE);
|
1352 | 1363 | }
|
| 1364 | + break;
|
| 1365 | + case IDC_FOGENABLE:
|
| 1366 | + if(HIWORD(wParam) == BN_CLICKED)
|
| 1367 | + {
|
| 1368 | + if(SendDlgItemMessage(hWnd,IDC_FOGENABLE,BM_GETCHECK,0,0) == BST_CHECKED)
|
| 1369 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE,TRUE);
|
| 1370 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE,FALSE);
|
| 1371 | + }
|
| 1372 | + break;
|
| 1373 | + case IDC_VERTEXFOGMODE:
|
| 1374 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 1375 | + {
|
| 1376 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE,SendDlgItemMessage(hWnd,
|
| 1377 | + IDC_VERTEXFOGMODE,CB_GETCURSEL,0,0));
|
| 1378 | + }
|
| 1379 | + break;
|
| 1380 | + case IDC_PIXELFOGMODE:
|
| 1381 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 1382 | + {
|
| 1383 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE,SendDlgItemMessage(hWnd,
|
| 1384 | + IDC_PIXELFOGMODE,CB_GETCURSEL,0,0));
|
| 1385 | + }
|
| 1386 | + break;
|
| 1387 | + case IDC_FOGSTART:
|
| 1388 | + if(HIWORD(wParam) == EN_CHANGE)
|
| 1389 | + {
|
| 1390 | + SendDlgItemMessage(hWnd,IDC_FOGSTART,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
| 1391 | + f = (float)_ttof(tmpstring);
|
| 1392 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGSTART, *((LPDWORD)(&f)));
|
| 1393 | + }
|
| 1394 | + case IDC_FOGEND:
|
| 1395 | + if(HIWORD(wParam) == EN_CHANGE)
|
| 1396 | + {
|
| 1397 | + SendDlgItemMessage(hWnd,IDC_FOGEND,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
| 1398 | + f = (float)_ttof(tmpstring);
|
| 1399 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGEND, *((LPDWORD)(&f)));
|
| 1400 | + }
|
| 1401 | + case IDC_FOGDENSITY:
|
| 1402 | + if(HIWORD(wParam) == EN_CHANGE)
|
| 1403 | + {
|
| 1404 | + SendDlgItemMessage(hWnd,IDC_FOGDENSITY,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
| 1405 | + f = (float)_ttof(tmpstring);
|
| 1406 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGDENSITY, *((LPDWORD)(&f)));
|
| 1407 | + }
|
| 1408 | + default:
|
| 1409 | + return FALSE;
|
1353 | 1410 | }
|
1354 | 1411 | break;
|
1355 | 1412 | case WM_CLOSE:
|
— | — | @@ -1372,6 +1429,7 @@ |
1373 | 1430 | D3DVIEWPORT7 vp;
|
1374 | 1431 | HWND hDisplay;
|
1375 | 1432 | int number;
|
| 1433 | + float f;
|
1376 | 1434 | TCHAR tmpstring[MAX_PATH+1];
|
1377 | 1435 | switch(Msg)
|
1378 | 1436 | {
|
— | — | @@ -1435,10 +1493,91 @@ |
1436 | 1494 | SendDlgItemMessage(hWnd,IDC_AMBIENT,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
|
1437 | 1495 | SendDlgItemMessage(hWnd,IDC_EMISSIVE,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
1438 | 1496 | SendDlgItemMessage(hWnd,IDC_MATAMBIENT,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
|
| 1497 | + PopulateFogCombo(GetDlgItem(hWnd,IDC_VERTEXFOGMODE));
|
| 1498 | + PopulateFogCombo(GetDlgItem(hWnd,IDC_PIXELFOGMODE));
|
| 1499 | + SendDlgItemMessage(hWnd,IDC_FOGSTART,WM_SETTEXT,0,(LPARAM)_T("0.0"));
|
| 1500 | + SendDlgItemMessage(hWnd,IDC_FOGEND,WM_SETTEXT,0,(LPARAM)_T("1.0"));
|
| 1501 | + SendDlgItemMessage(hWnd,IDC_FOGDENSITY,WM_SETTEXT,0,(LPARAM)_T("1.0"));
|
1439 | 1502 | ::width = ddsd.dwWidth;
|
1440 | 1503 | ::height = ddsd.dwHeight;
|
| 1504 | + vertexshaderstate.texture = NULL;
|
| 1505 | + vertexshaderstate.texturefile[0] = 0;
|
| 1506 | + vertexshaderstate.texturetype = 0;
|
1441 | 1507 | StartTimer(hWnd,WM_APP,60);
|
1442 | 1508 | break;
|
| 1509 | + case WM_COMMAND:
|
| 1510 | + switch(LOWORD(wParam))
|
| 1511 | + {
|
| 1512 | + case IDC_TEXTURE:
|
| 1513 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 1514 | + {
|
| 1515 | + number = texshaderstate.currentstage;
|
| 1516 | + vertexshaderstate.texturetype =
|
| 1517 | + SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_GETCURSEL,0,0);
|
| 1518 | + SelectTexture(&vertexshaderstate.texture,vertexshaderstate.texturetype,
|
| 1519 | + 0, FALSE,vertexshaderstate.texturefile);
|
| 1520 | + if((vertexshaderstate.texturetype == 2) || (vertexshaderstate.texturetype == 3))
|
| 1521 | + d3d7dev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_BLENDTEXTUREALPHAPM);
|
| 1522 | + else d3d7dev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
| 1523 | + }
|
| 1524 | + break;
|
| 1525 | + case IDC_TEXTUREFILE:
|
| 1526 | + if(HIWORD(wParam) == EN_KILLFOCUS)
|
| 1527 | + {
|
| 1528 | + number = texshaderstate.currentstage;
|
| 1529 | + SendDlgItemMessage(hWnd,IDC_TEXTUREFILE,WM_GETTEXT,MAX_PATH+1,
|
| 1530 | + (LPARAM)vertexshaderstate.texturefile);
|
| 1531 | + SelectTexture(&vertexshaderstate.texture,vertexshaderstate.texturetype,
|
| 1532 | + 0, FALSE,vertexshaderstate.texturefile);
|
| 1533 | + }
|
| 1534 | + break;
|
| 1535 | + case IDC_FOGENABLE:
|
| 1536 | + if(HIWORD(wParam) == BN_CLICKED)
|
| 1537 | + {
|
| 1538 | + if(SendDlgItemMessage(hWnd,IDC_FOGENABLE,BM_GETCHECK,0,0) == BST_CHECKED)
|
| 1539 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE,TRUE);
|
| 1540 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_FOGENABLE,FALSE);
|
| 1541 | + }
|
| 1542 | + break;
|
| 1543 | + case IDC_VERTEXFOGMODE:
|
| 1544 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 1545 | + {
|
| 1546 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGVERTEXMODE,SendDlgItemMessage(hWnd,
|
| 1547 | + IDC_VERTEXFOGMODE,CB_GETCURSEL,0,0));
|
| 1548 | + }
|
| 1549 | + break;
|
| 1550 | + case IDC_PIXELFOGMODE:
|
| 1551 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 1552 | + {
|
| 1553 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE,SendDlgItemMessage(hWnd,
|
| 1554 | + IDC_PIXELFOGMODE,CB_GETCURSEL,0,0));
|
| 1555 | + }
|
| 1556 | + break;
|
| 1557 | + case IDC_FOGSTART:
|
| 1558 | + if(HIWORD(wParam) == EN_CHANGE)
|
| 1559 | + {
|
| 1560 | + SendDlgItemMessage(hWnd,IDC_FOGSTART,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
| 1561 | + f = (float)_ttof(tmpstring);
|
| 1562 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGSTART, *((LPDWORD)(&f)));
|
| 1563 | + }
|
| 1564 | + case IDC_FOGEND:
|
| 1565 | + if(HIWORD(wParam) == EN_CHANGE)
|
| 1566 | + {
|
| 1567 | + SendDlgItemMessage(hWnd,IDC_FOGEND,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
| 1568 | + f = (float)_ttof(tmpstring);
|
| 1569 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGEND, *((LPDWORD)(&f)));
|
| 1570 | + }
|
| 1571 | + case IDC_FOGDENSITY:
|
| 1572 | + if(HIWORD(wParam) == EN_CHANGE)
|
| 1573 | + {
|
| 1574 | + SendDlgItemMessage(hWnd,IDC_FOGDENSITY,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
| 1575 | + f = (float)_ttof(tmpstring);
|
| 1576 | + d3d7dev->SetRenderState(D3DRENDERSTATE_FOGDENSITY, *((LPDWORD)(&f)));
|
| 1577 | + }
|
| 1578 | + default:
|
| 1579 | + return FALSE;
|
| 1580 | + }
|
| 1581 | + break;
|
1443 | 1582 | case WM_CLOSE:
|
1444 | 1583 | ddinterface->Release();
|
1445 | 1584 | EndDialog(hWnd,IDCANCEL);
|