DXGL r53 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r52‎ | r53 | r54 >
Date:16:35, 28 December 2011
Author:admin
Status:new
Tags:
Comment:
add 3D Graphics tab to DXGLTest
Modified paths:
  • /dxgltest/Tests3D.cpp (modified) (history)
  • /dxgltest/dxgltest.cpp (modified) (history)
  • /dxgltest/tests.h (modified) (history)

Diff [purge]

Index: dxgltest/Tests3D.cpp
@@ -20,3 +20,8 @@
2121 #include "surfacegen.h"
2222 #include "timer.h"
2323 #include "misc.h"
 24+
 25+
 26+void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
 27+ int filter, int msaa, double fps, bool fullscreen, bool resizable)
 28+{}
\ No newline at end of file
Index: dxgltest/dxgltest.cpp
@@ -203,6 +203,7 @@
204204 };
205205 const int END_2D = __LINE__ - 4;
206206 const int numtests2d = END_2D - START_2D;
 207+
207208 int currenttest2d = 0;
208209 int minapi2d = 1;
209210 int maxapi2d = 7;
@@ -215,6 +216,32 @@
216217 bool resizable2d = false;
217218 double framerate2d = 1.00;
218219 TCHAR framerate2dstring[33];
 220+
 221+// Use EXACTLY one line per entry. Don't change layout of the list.
 222+const int START_3D = __LINE__;
 223+const TEST_ITEM Tests3D[] =
 224+{ // minver maxver buffermin max usesfps defaultfps usestexture usesfsaa name
 225+ {7, 7, 0, 2, true, 60.0, false, true, _T("Basic polygons (DX7)")}
 226+};
 227+const int END_3D = __LINE__ - 4;
 228+const int numtests3d = END_3D - START_3D;
 229+
 230+int currenttest3d = 0;
 231+int minapi3d = 7;
 232+int maxapi3d = 7;
 233+int minbuffer3d = 0;
 234+int maxbuffer3d = 2;
 235+int fps_enabled3d = true;
 236+int api3d = 7;
 237+int buffer3d = 1;
 238+int filter3d = 0;
 239+int msaa3d = 0;
 240+bool fullscreen3d = true;
 241+bool resizable3d = true;
 242+double framerate3d = 60.00;
 243+TCHAR framerate3dstring[33];
 244+
 245+
219246 TCHAR tmpstring[33];
220247 INT_PTR CALLBACK Test2DCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
221248 {
@@ -425,6 +452,212 @@
426453 return TRUE;
427454 }
428455
 456+INT_PTR CALLBACK Test3DCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 457+{
 458+ int i;
 459+ int pos;
 460+ double f;
 461+ LPDIRECTDRAW lpdd;
 462+ HRESULT error;
 463+ int width,height,bpp,refresh;
 464+ switch(Msg)
 465+ {
 466+ case WM_INITDIALOG:
 467+ SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,1,0);
 468+ SetDlgItemText(hWnd,IDC_TESTHEADER,_T("Test 3D graphics functionality in DXGL or Direct3D. Press ESC to quit any test."));
 469+ for(i = 0; i < numtests3d; i++)
 470+ SendDlgItemMessage(hWnd,IDC_TESTLIST,LB_ADDSTRING,0,(LPARAM)Tests3D[i].name);
 471+ error = DirectDrawCreate(NULL,&lpdd,NULL);
 472+ if(error == DD_OK)
 473+ {
 474+ error = lpdd->EnumDisplayModes(DDEDM_REFRESHRATES,NULL,GetDlgItem(hWnd,IDC_VIDMODES),EnumModesCallback);
 475+ lpdd->Release();
 476+ }
 477+ SendDlgItemMessage(hWnd,IDC_VIDMODES,LB_SETCURSEL,modenum,0);
 478+ break;
 479+ case WM_COMMAND:
 480+ switch(LOWORD(wParam))
 481+ {
 482+ case IDC_TESTLIST:
 483+ if(HIWORD(wParam) == LBN_SELCHANGE)
 484+ {
 485+ i = SendDlgItemMessage(hWnd,IDC_TESTLIST,LB_GETCURSEL,0,0);
 486+ if(i != -1)
 487+ {
 488+ currenttest3d = i;
 489+ minapi3d = Tests3D[i].minver;
 490+ maxapi3d = Tests3D[i].maxver;
 491+ minbuffer3d = Tests3D[i].buffermin;
 492+ maxbuffer3d = Tests3D[i].buffermax;
 493+ fps_enabled3d = Tests3D[i].usesfps;
 494+ if(Tests3D[i].usesfps) framerate3d = Tests3D[i].defaultfps;
 495+ EnableWindow(GetDlgItem(hWnd,IDC_BUFFERS),TRUE);
 496+ EnableWindow(GetDlgItem(hWnd,IDC_APIVER),TRUE);
 497+ EnableWindow(GetDlgItem(hWnd,IDC_FRAMERATE),fps_enabled3d);
 498+ EnableWindow(GetDlgItem(hWnd,IDC_TEST),TRUE);
 499+ SendDlgItemMessage(hWnd,IDC_BUFFERS,EM_SETLIMITTEXT,2,0);
 500+ SendDlgItemMessage(hWnd,IDC_APIVER,EM_SETLIMITTEXT,1,0);
 501+ SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_SETLIMITTEXT,5,0);
 502+ SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)_itot(buffer3d,tmpstring,10));
 503+ SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)_itot(api3d,tmpstring,10));
 504+ _stprintf(framerate3dstring,_T("%.2f"),framerate3d);
 505+ SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate3dstring);
 506+ }
 507+ }
 508+ break;
 509+ case IDC_FRAMERATE:
 510+ if(HIWORD(wParam) == EN_CHANGE)
 511+ {
 512+ SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_GETTEXT,6,(LPARAM)tmpstring);
 513+ if(_tcscmp(framerate3dstring,tmpstring))
 514+ {
 515+ pos = LOWORD(SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_GETSEL,NULL,NULL));
 516+ i = _tcslen(tmpstring);
 517+ f = _ttof(tmpstring);
 518+ if(errno != ERANGE) framerate3d = f;
 519+ if(framerate3d < 0.5) framerate3d = 0.5;
 520+ if(framerate3d > 99.99) framerate3d = 99.99;
 521+ _stprintf(framerate3dstring,_T("%.2f"),framerate3d);
 522+ SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate3dstring);
 523+ SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_SETSEL,pos,pos);
 524+ }
 525+ }
 526+ break;
 527+ case IDC_APIVER:
 528+ if(HIWORD(wParam) == EN_CHANGE)
 529+ {
 530+ SendDlgItemMessage(hWnd,IDC_APIVER,WM_GETTEXT,6,(LPARAM)tmpstring);
 531+ i = _ttoi(tmpstring);
 532+ if(i != api3d)
 533+ {
 534+ api3d = i;
 535+ if(api3d == 5) api3d = 4;
 536+ if(api3d == 6) api3d = 7;
 537+ if(api3d < minapi3d) api3d = minapi3d;
 538+ if(api3d > maxapi3d) api3d = maxapi3d;
 539+ _itot(api3d,tmpstring,10);
 540+ SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)tmpstring);
 541+ }
 542+ }
 543+ break;
 544+ case IDC_BUFFERS:
 545+ if(HIWORD(wParam) == EN_CHANGE)
 546+ {
 547+ SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_GETTEXT,6,(LPARAM)tmpstring);
 548+ i = _ttoi(tmpstring);
 549+ if(i != buffer3d)
 550+ {
 551+ buffer3d = i;
 552+ if(buffer3d < minbuffer3d) buffer3d = minbuffer3d;
 553+ if(buffer3d > maxbuffer3d) buffer3d = maxbuffer3d;
 554+ _itot(buffer3d,tmpstring,10);
 555+ SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)tmpstring);
 556+ }
 557+ }
 558+ break;
 559+ case IDC_TEST:
 560+ if(SendDlgItemMessage(hWnd,IDC_RESIZABLE,BM_GETCHECK,0,0)) resizable3d = true;
 561+ else resizable3d = false;
 562+ i = SendDlgItemMessage(hWnd,IDC_VIDMODES,LB_GETCURSEL,0,0);
 563+ SendDlgItemMessage(hWnd,IDC_VIDMODES,LB_GETTEXT,i,(LPARAM)tmpstring);
 564+ TranslateResolutionString(tmpstring,width,height,bpp,refresh);
 565+ RunTest3D(currenttest3d,width,height,bpp,refresh,buffer3d,api3d,filter3d,msaa3d,framerate3d,fullscreen3d,resizable3d);
 566+ break;
 567+ case IDC_WINDOWED:
 568+ SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,0,0);
 569+ SendDlgItemMessage(hWnd,IDC_WINDOWED,BM_SETCHECK,1,0);
 570+ fullscreen3d = false;
 571+ break;
 572+ case IDC_FULLSCREEN:
 573+ SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,1,0);
 574+ SendDlgItemMessage(hWnd,IDC_WINDOWED,BM_SETCHECK,0,0);
 575+ fullscreen3d = true;
 576+ break;
 577+ }
 578+ break;
 579+ case WM_NOTIFY:
 580+ switch(((LPNMHDR)lParam)->code)
 581+ {
 582+ case UDN_DELTAPOS:
 583+ switch(((LPNMHDR)lParam)->idFrom)
 584+ {
 585+ case IDC_SPINFRAME:
 586+ framerate3d -= ((LPNMUPDOWN)lParam)->iDelta;
 587+ if(framerate3d < 0.01) framerate3d = 0.01;
 588+ if(framerate3d > 99.99) framerate3d = 99.99;
 589+ _stprintf(framerate3dstring,_T("%.2f"),framerate3d);
 590+ SendDlgItemMessage(hWnd,IDC_FRAMERATE,WM_SETTEXT,0,(LPARAM)framerate3dstring);
 591+ break;
 592+ case IDC_SPINAPI:
 593+ if(api3d < 1) api3d = 1;
 594+ if(api3d > 7) api3d = 7;
 595+ if(((LPNMUPDOWN)lParam)->iDelta > 0)
 596+ {
 597+ switch(api3d)
 598+ {
 599+ case 1:
 600+ case 2:
 601+ default:
 602+ api3d = 1;
 603+ break;
 604+ case 3:
 605+ api3d = 2;
 606+ break;
 607+ case 4:
 608+ api3d = 3;
 609+ break;
 610+ case 7:
 611+ case 6:
 612+ case 5:
 613+ api3d = 4;
 614+ }
 615+ }
 616+ else
 617+ {
 618+ switch(api3d)
 619+ {
 620+ case 1:
 621+ default:
 622+ api3d = 2;
 623+ break;
 624+ case 2:
 625+ api3d = 3;
 626+ break;
 627+ case 3:
 628+ api3d = 4;
 629+ break;
 630+ case 4:
 631+ case 5:
 632+ case 6:
 633+ case 7:
 634+ api3d = 7;
 635+ }
 636+ }
 637+ if(api3d < minapi3d) api3d = minapi3d;
 638+ if(api3d > maxapi3d) api3d = maxapi3d;
 639+ SendDlgItemMessage(hWnd,IDC_APIVER,WM_SETTEXT,0,(LPARAM)_itot(api3d,tmpstring,10));
 640+ break;
 641+ case IDC_SPINBACK:
 642+ buffer3d -= ((LPNMUPDOWN)lParam)->iDelta;
 643+ if(buffer3d < minbuffer3d) buffer3d = minbuffer3d;
 644+ if(buffer3d > maxbuffer3d) buffer3d = maxbuffer3d;
 645+ SendDlgItemMessage(hWnd,IDC_BUFFERS,WM_SETTEXT,0,(LPARAM)_itot(buffer3d,tmpstring,10));
 646+ break;
 647+ default:
 648+ break;
 649+ }
 650+ break;
 651+ default:
 652+ break;
 653+ }
 654+ break;
 655+ default:
 656+ return FALSE;
 657+ }
 658+ return TRUE;
 659+}
 660+
 661+
429662 HWND tabwnd[3];
430663 int tabopen;
431664 INT_PTR CALLBACK DXGLTestCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
@@ -450,11 +683,15 @@
451684 tab.pszText = _T("2D Graphics");
452685 hTab = GetDlgItem(hWnd,IDC_TABS);
453686 SendDlgItemMessage(hWnd,IDC_TABS,TCM_INSERTITEM,1,(LPARAM)&tab);
454 - tabwnd[0] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SYSINFO),hTab,SysTabCallback);
 687+ tab.pszText = _T("3D Graphics");
 688+ SendDlgItemMessage(hWnd,IDC_TABS,TCM_INSERTITEM,2,(LPARAM)&tab);
 689+ tabwnd[0] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SYSINFO),hTab,SysTabCallback);
455690 tabwnd[1] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_TESTGFX),hTab,Test2DCallback);
 691+ tabwnd[2] = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_TESTGFX),hTab,Test3DCallback);
456692 SendDlgItemMessage(hWnd,IDC_TABS,TCM_GETITEMRECT,0,(LPARAM)&tabrect);
457693 SetWindowPos(tabwnd[0],NULL,tabrect.left,tabrect.bottom+3,0,0,SWP_SHOWWINDOW|SWP_NOSIZE);
458 - ShowWindow(tabwnd[1],SWP_HIDEWINDOW);
 694+ ShowWindow(tabwnd[1],SW_HIDE);
 695+ ShowWindow(tabwnd[2],SW_HIDE);
459696 tabopen = 0;
460697 ShowWindow(hWnd,SW_SHOWNORMAL);
461698 return TRUE;
Index: dxgltest/tests.h
@@ -23,7 +23,7 @@
2424 void RunTest2D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
2525 double fps, bool fullscreen, bool resizable);
2626
27 -void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int filter,
28 - int msaa, double fps, bool fullscreen, bool resizable);
 27+void RunTest3D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
 28+ int filter, int msaa, double fps, bool fullscreen, bool resizable);
2929
3030 #endif //_TESTS_H