DXGL r225 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r224‎ | r225 | r226 >
Date:01:19, 5 August 2012
Author:admin
Status:new
Tags:
Comment:
Handle message for texture stage selection control.
Disable fullscreen and video mode controls when selecting the Texture Shader test.
Modified paths:
  • /dxgltest/Tests3D.cpp (modified) (history)
  • /dxgltest/common.h (modified) (history)
  • /dxgltest/dxgltest.cpp (modified) (history)
  • /dxgltest/dxgltest.rc (modified) (history)

Diff [purge]

Index: dxgltest/Tests3D.cpp
@@ -838,11 +838,37 @@
839839 SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM)_T("Linear"));
840840 }
841841
 842+void strupper(TCHAR *str)
 843+{
 844+ TCHAR *ptr = str;
 845+ while(*ptr != 0)
 846+ {
 847+ *ptr = _totupper(*ptr);
 848+ ptr++;
 849+ }
 850+}
 851+
 852+void paddwordzeroes(TCHAR *str)
 853+{
 854+ TCHAR str2[16];
 855+ str2[0] = 0;
 856+ int len = _tcslen(str);
 857+ if(len < 8)
 858+ {
 859+ for(int i = 0; i < 8-len; i++)
 860+ _tcscat(str2,_T("0"));
 861+ _tcscat(str2,str);
 862+ _tcscpy(str,str2);
 863+ }
 864+}
 865+
842866 INT_PTR CALLBACK TexShader7Proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
843867 {
844868 HRESULT error;
845869 D3DVIEWPORT7 vp;
846870 HWND hDisplay;
 871+ int number;
 872+ TCHAR tmpstring[MAX_PATH+1];
847873 switch(Msg)
848874 {
849875 case WM_INITDIALOG:
@@ -891,14 +917,11 @@
892918 error = d3d7dev->SetViewport(&vp);
893919 error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
894920 InitTest3D(2);
895 - SendDlgItemMessage(hWnd,IDC_SPINSTAGE,UDM_SETRANGE32,0,7);
896 - SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_SETTEXT,0,(LPARAM)_T("FFFFFFFF"));
897921 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("None"));
898922 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Gradients"));
899923 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (small)"));
900924 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (large)"));
901925 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Texture file"));
902 - SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_SETCURSEL,0,0);
903926 PopulateArgCombo(GetDlgItem(hWnd,IDC_CARG1));
904927 PopulateArgCombo(GetDlgItem(hWnd,IDC_CARG2));
905928 PopulateArgCombo(GetDlgItem(hWnd,IDC_AARG1));
@@ -928,10 +951,61 @@
929952 SendDlgItemMessage(hWnd,IDC_FOGSTART,WM_SETTEXT,0,(LPARAM)_T("0.0"));
930953 SendDlgItemMessage(hWnd,IDC_FOGEND,WM_SETTEXT,0,(LPARAM)_T("1.0"));
931954 SendDlgItemMessage(hWnd,IDC_FOGDENSITY,WM_SETTEXT,0,(LPARAM)_T("1.0"));
 955+ SendDlgItemMessage(hWnd,IDC_SPINSTAGE,UDM_SETRANGE32,0,7);
932956 ::width = ddsd.dwWidth;
933957 ::height = ddsd.dwHeight;
934958 StartTimer(hWnd,WM_APP,60);
935959 break;
 960+ case WM_COMMAND:
 961+ switch(LOWORD(wParam))
 962+ {
 963+ case IDC_TEXSTAGE:
 964+ if(HIWORD(wParam) == EN_CHANGE)
 965+ {
 966+ SendDlgItemMessage(hWnd,IDC_TEXSTAGE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
 967+ number = _ttoi(tmpstring);
 968+ if(number < 0) SendDlgItemMessage(hWnd,IDC_TEXSTAGE,WM_SETTEXT,0,(LPARAM)_T("0"));
 969+ if(number > 7) SendDlgItemMessage(hWnd,IDC_TEXSTAGE,WM_SETTEXT,0,(LPARAM)_T("7"));
 970+ texshaderstate.currentstage = number;
 971+ _itot(texshaderstate.texstages[number].keycolor,tmpstring,16);
 972+ strupper(tmpstring);
 973+ paddwordzeroes(tmpstring);
 974+ SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_SETTEXT,0,(LPARAM)tmpstring);
 975+ SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_SETCURSEL,texshaderstate.texstages[number].texturetype,0);
 976+ SendDlgItemMessage(hWnd,IDC_TEXTUREFILE,WM_SETTEXT,0,(LPARAM)texshaderstate.texstages[number].texturefile);
 977+ SendDlgItemMessage(hWnd,IDC_CARG1,CB_SETCURSEL,texshaderstate.texstages[number].colorarg1 & D3DTA_SELECTMASK,0);
 978+ SendDlgItemMessage(hWnd,IDC_CARG2,CB_SETCURSEL,texshaderstate.texstages[number].colorarg2 & D3DTA_SELECTMASK,0);
 979+ SendDlgItemMessage(hWnd,IDC_AARG1,CB_SETCURSEL,texshaderstate.texstages[number].alphaarg1 & D3DTA_SELECTMASK,0);
 980+ SendDlgItemMessage(hWnd,IDC_AARG2,CB_SETCURSEL,texshaderstate.texstages[number].alphaarg2 & D3DTA_SELECTMASK,0);
 981+ if(texshaderstate.texstages[number].colorarg1 & D3DTA_ALPHAREPLICATE)
 982+ SendDlgItemMessage(hWnd,IDC_CARG1A,BM_SETCHECK,BST_CHECKED,0);
 983+ else SendDlgItemMessage(hWnd,IDC_CARG1A,BM_SETCHECK,BST_UNCHECKED,0);
 984+ if(texshaderstate.texstages[number].colorarg2 & D3DTA_ALPHAREPLICATE)
 985+ SendDlgItemMessage(hWnd,IDC_CARG2A,BM_SETCHECK,BST_CHECKED,0);
 986+ else SendDlgItemMessage(hWnd,IDC_CARG2A,BM_SETCHECK,BST_UNCHECKED,0);
 987+ if(texshaderstate.texstages[number].alphaarg1 & D3DTA_ALPHAREPLICATE)
 988+ SendDlgItemMessage(hWnd,IDC_AARG1A,BM_SETCHECK,BST_CHECKED,0);
 989+ else SendDlgItemMessage(hWnd,IDC_AARG1A,BM_SETCHECK,BST_UNCHECKED,0);
 990+ if(texshaderstate.texstages[number].alphaarg2 & D3DTA_ALPHAREPLICATE)
 991+ SendDlgItemMessage(hWnd,IDC_AARG2A,BM_SETCHECK,BST_CHECKED,0);
 992+ else SendDlgItemMessage(hWnd,IDC_AARG2A,BM_SETCHECK,BST_UNCHECKED,0);
 993+ if(texshaderstate.texstages[number].colorarg1 & D3DTA_COMPLEMENT)
 994+ SendDlgItemMessage(hWnd,IDC_CARG1INV,BM_SETCHECK,BST_CHECKED,0);
 995+ else SendDlgItemMessage(hWnd,IDC_CARG1INV,BM_SETCHECK,BST_UNCHECKED,0);
 996+ if(texshaderstate.texstages[number].colorarg2 & D3DTA_COMPLEMENT)
 997+ SendDlgItemMessage(hWnd,IDC_CARG2INV,BM_SETCHECK,BST_CHECKED,0);
 998+ else SendDlgItemMessage(hWnd,IDC_CARG2INV,BM_SETCHECK,BST_UNCHECKED,0);
 999+ if(texshaderstate.texstages[number].alphaarg1 & D3DTA_COMPLEMENT)
 1000+ SendDlgItemMessage(hWnd,IDC_AARG1INV,BM_SETCHECK,BST_CHECKED,0);
 1001+ else SendDlgItemMessage(hWnd,IDC_AARG1INV,BM_SETCHECK,BST_UNCHECKED,0);
 1002+ if(texshaderstate.texstages[number].alphaarg2 & D3DTA_COMPLEMENT)
 1003+ SendDlgItemMessage(hWnd,IDC_AARG2INV,BM_SETCHECK,BST_CHECKED,0);
 1004+ else SendDlgItemMessage(hWnd,IDC_AARG2INV,BM_SETCHECK,BST_UNCHECKED,0);
 1005+ SendDlgItemMessage(hWnd,IDC_COLOROP,CB_SETCURSEL,texshaderstate.texstages[number].colorop-1,0);
 1006+ SendDlgItemMessage(hWnd,IDC_ALPHAOP,CB_SETCURSEL,texshaderstate.texstages[number].alphaop-1,0);
 1007+ }
 1008+ }
 1009+ break;
9361010 case WM_CLOSE:
9371011 ddinterface->Release();
9381012 EndDialog(hWnd,IDCANCEL);
Index: dxgltest/common.h
@@ -60,4 +60,11 @@
6161 // DirectX/DXGL headers
6262 #include <ddraw.h>
6363 extern const unsigned char DefaultPalette[1024];
 64+
 65+#ifdef _UNICODE
 66+#define _ttof _wtof
 67+#else
 68+#define _ttof atof
 69+#endif
 70+
6471 #endif //_COMMON_H
Index: dxgltest/dxgltest.cpp
@@ -18,11 +18,6 @@
1919 #include "common.h"
2020 #include "dxgltest.h"
2121 #include "tests.h"
22 -#ifdef _UNICODE
23 -#define _ttof _wtof
24 -#else
25 -#define _ttof atof
26 -#endif
2722
2823 HINSTANCE hinstance;
2924 bool gradientavailable;
@@ -523,10 +518,33 @@
524519 maxbuffer3d = Tests3D[i].buffermax;
525520 fps_enabled3d = Tests3D[i].usesfps;
526521 if(Tests3D[i].usesfps) framerate3d = Tests3D[i].defaultfps;
527 - EnableWindow(GetDlgItem(hWnd,IDC_BUFFERS),TRUE);
528 - EnableWindow(GetDlgItem(hWnd,IDC_APIVER),TRUE);
529 - EnableWindow(GetDlgItem(hWnd,IDC_FRAMERATE),fps_enabled3d);
530 - EnableWindow(GetDlgItem(hWnd,IDC_TEST),TRUE);
 522+ if(i != 2)
 523+ {
 524+ EnableWindow(GetDlgItem(hWnd,IDC_BUFFERS),TRUE);
 525+ EnableWindow(GetDlgItem(hWnd,IDC_APIVER),TRUE);
 526+ EnableWindow(GetDlgItem(hWnd,IDC_FRAMERATE),fps_enabled3d);
 527+ EnableWindow(GetDlgItem(hWnd,IDC_TEST),TRUE);
 528+ EnableWindow(GetDlgItem(hWnd,IDC_WINDOWED),TRUE);
 529+ EnableWindow(GetDlgItem(hWnd,IDC_FULLSCREEN),TRUE);
 530+ EnableWindow(GetDlgItem(hWnd,IDC_RESIZABLE),TRUE);
 531+ EnableWindow(GetDlgItem(hWnd,IDC_VSYNC),TRUE);
 532+ EnableWindow(GetDlgItem(hWnd,IDC_VIDMODES),TRUE);
 533+ }
 534+ else
 535+ {
 536+ EnableWindow(GetDlgItem(hWnd,IDC_BUFFERS),FALSE);
 537+ EnableWindow(GetDlgItem(hWnd,IDC_APIVER),TRUE);
 538+ EnableWindow(GetDlgItem(hWnd,IDC_FRAMERATE),FALSE);
 539+ EnableWindow(GetDlgItem(hWnd,IDC_TEST),TRUE);
 540+ EnableWindow(GetDlgItem(hWnd,IDC_WINDOWED),FALSE);
 541+ EnableWindow(GetDlgItem(hWnd,IDC_FULLSCREEN),FALSE);
 542+ EnableWindow(GetDlgItem(hWnd,IDC_RESIZABLE),FALSE);
 543+ EnableWindow(GetDlgItem(hWnd,IDC_VSYNC),FALSE);
 544+ EnableWindow(GetDlgItem(hWnd,IDC_VIDMODES),FALSE);
 545+ SendDlgItemMessage(hWnd,IDC_WINDOWED,BM_SETCHECK,BST_CHECKED,0);
 546+ SendDlgItemMessage(hWnd,IDC_FULLSCREEN,BM_SETCHECK,BST_UNCHECKED,0);
 547+ fullscreen3d = false;
 548+ }
531549 SendDlgItemMessage(hWnd,IDC_BUFFERS,EM_SETLIMITTEXT,2,0);
532550 SendDlgItemMessage(hWnd,IDC_APIVER,EM_SETLIMITTEXT,1,0);
533551 SendDlgItemMessage(hWnd,IDC_FRAMERATE,EM_SETLIMITTEXT,5,0);
Index: dxgltest/dxgltest.rc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream