DXGL r264 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r263‎ | r264 | r265 >
Date:01:04, 22 September 2012
Author:admin
Status:new
Tags:
Comment:
Create Vertex Shader demo dialog.
Modified paths:
  • /dxgltest/Tests3D.cpp (modified) (history)

Diff [purge]

Index: dxgltest/Tests3D.cpp
@@ -273,6 +273,7 @@
274274 }
275275
276276 INT_PTR CALLBACK TexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
 277+INT_PTR CALLBACK VertexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
277278
278279 void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
279280 int filter, int msaa, double fps, bool fullscreen, bool resizable)
@@ -282,6 +283,11 @@
283284 DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_TEXSHADER),NULL,TexShader7Proc);
284285 return;
285286 }
 287+ if(testnum == 3)
 288+ {
 289+ DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_TEXSHADER),NULL,VertexShader7Proc);
 290+ return;
 291+ }
286292 DDSCAPS2 caps;
287293 DDSURFACEDESC2 ddsd;
288294 DDPIXELFORMAT ddpfz;
@@ -672,6 +678,7 @@
673679 error = d3d7dev->SetLight(0,&lights[0]);
674680 break;
675681 case 2:
 682+ case 3:
676683 MakeCube3D();
677684 ZeroMemory(&material,sizeof(D3DMATERIAL7));
678685 material.ambient.r = 1.0f;
@@ -1089,6 +1096,7 @@
10901097 SendDlgItemMessage(hWnd,IDC_SPECULAR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
10911098 SendDlgItemMessage(hWnd,IDC_FACTOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
10921099 SendDlgItemMessage(hWnd,IDC_FOGCOLOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
 1100+ SendDlgItemMessage(hWnd,IDC_BGCOLOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
10931101 PopulateBlendCombo(GetDlgItem(hWnd,IDC_SRCBLEND),true);
10941102 PopulateBlendCombo(GetDlgItem(hWnd,IDC_DESTBLEND),true);
10951103 SendDlgItemMessage(hWnd,IDC_SRCBLEND,CB_SETCURSEL,D3DBLEND_ONE-1,0);
@@ -1357,3 +1365,89 @@
13581366
13591367
13601368 }
 1369+
 1370+INT_PTR CALLBACK VertexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 1371+{
 1372+ HRESULT error;
 1373+ D3DVIEWPORT7 vp;
 1374+ HWND hDisplay;
 1375+ int number;
 1376+ TCHAR tmpstring[MAX_PATH+1];
 1377+ switch(Msg)
 1378+ {
 1379+ case WM_INITDIALOG:
 1380+ RECT r;
 1381+ DDSCAPS2 caps;
 1382+ DDSURFACEDESC2 ddsd;
 1383+ DDPIXELFORMAT ddpfz;
 1384+ testnum = 3;
 1385+ ddinterface = new MultiDirectDraw(7,&error,NULL);
 1386+ hDisplay = GetDlgItem(hWnd,IDC_DISPLAY);
 1387+ ::hWnd = hDisplay;
 1388+ error = ddinterface->SetCooperativeLevel(hDisplay,DDSCL_NORMAL);
 1389+ ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
 1390+ ddsd.dwSize = sizeof(DDSURFACEDESC2);
 1391+ ddsd.dwFlags = DDSD_CAPS;
 1392+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 1393+ error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
 1394+ error = ddinterface->CreateClipper(0,&ddclipper,NULL);
 1395+ error = ddclipper->SetHWnd(0,hDisplay);
 1396+ error = ddsurface->SetClipper(ddclipper);
 1397+ ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
 1398+ ddsd.dwSize = sizeof(DDSURFACEDESC2);
 1399+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
 1400+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE;
 1401+ GetClientRect(hDisplay,&r);
 1402+ ddsd.dwWidth = r.right;
 1403+ ddsd.dwHeight = r.bottom;
 1404+ error = ddinterface->CreateSurface(&ddsd,&ddsrender,NULL);
 1405+ error = ddinterface->QueryInterface(IID_IDirect3D7,(VOID**)&d3d7);
 1406+ error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice,zcallback,&ddpfz);
 1407+ error = ddsrender->GetSurfaceDesc(&ddsd);
 1408+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
 1409+ ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER|DDSCAPS_VIDEOMEMORY;
 1410+ memcpy(&ddsd.ddpfPixelFormat,&ddpfz,sizeof(DDPIXELFORMAT));
 1411+ error = ddinterface->CreateSurface(&ddsd,&zbuffer,NULL);
 1412+ error = ddsrender->AddAttachedSurface(zbuffer);
 1413+ error = d3d7->CreateDevice(IID_IDirect3DHALDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
 1414+ if(error != D3D_OK)
 1415+ error = d3d7->CreateDevice(IID_IDirect3DRGBDevice,(LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(),&d3d7dev);
 1416+ ddsrender->GetSurfaceDesc(&ddsd);
 1417+ vp.dvMaxZ = 1.0f;
 1418+ vp.dvMinZ = 0.0f;
 1419+ vp.dwX = vp.dwY = 0;
 1420+ vp.dwWidth = ddsd.dwWidth;
 1421+ vp.dwHeight = ddsd.dwHeight;
 1422+ error = d3d7dev->SetViewport(&vp);
 1423+ error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
 1424+ InitTest3D(3);
 1425+ SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("None"));
 1426+ SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Gradients"));
 1427+ SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (small)"));
 1428+ SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (large)"));
 1429+ SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Texture file"));
 1430+ SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_SETCURSEL,0,0);
 1431+ SendDlgItemMessage(hWnd,IDC_DIFFUSE,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
 1432+ SendDlgItemMessage(hWnd,IDC_SPECULAR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
 1433+ SendDlgItemMessage(hWnd,IDC_FACTOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
 1434+ SendDlgItemMessage(hWnd,IDC_FOGCOLOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
 1435+ SendDlgItemMessage(hWnd,IDC_BGCOLOR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
 1436+ SendDlgItemMessage(hWnd,IDC_AMBIENT,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
 1437+ SendDlgItemMessage(hWnd,IDC_EMISSIVE,WM_SETTEXT,0,(LPARAM)_T("00000000"));
 1438+ SendDlgItemMessage(hWnd,IDC_MATAMBIENT,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
 1439+ ::width = ddsd.dwWidth;
 1440+ ::height = ddsd.dwHeight;
 1441+ StartTimer(hWnd,WM_APP,60);
 1442+ break;
 1443+ case WM_CLOSE:
 1444+ ddinterface->Release();
 1445+ EndDialog(hWnd,IDCANCEL);
 1446+ break;
 1447+ case WM_APP:
 1448+ RunTestTimed3D(testnum);
 1449+ break;
 1450+ default:
 1451+ return FALSE;
 1452+ }
 1453+ return TRUE;
 1454+}