Index: dxgltest/Tests3D.cpp |
— | — | @@ -85,6 +85,14 @@ |
86 | 86 |
|
87 | 87 | typedef struct
|
88 | 88 | {
|
| 89 | + DWORD ambient;
|
| 90 | + DWORD diffuse;
|
| 91 | + DWORD specular;
|
| 92 | +} HEXLIGHTCOLOR;
|
| 93 | +HEXLIGHTCOLOR hexlightcolor[8];
|
| 94 | +
|
| 95 | +typedef struct
|
| 96 | +{
|
89 | 97 | D3DTEXTUREOP colorop;
|
90 | 98 | DWORD colorarg1;
|
91 | 99 | DWORD colorarg2;
|
— | — | @@ -166,6 +174,7 @@ |
167 | 175 | DWORD texturetype;
|
168 | 176 | TCHAR texturefile[MAX_PATH+1];
|
169 | 177 | MultiDirectDrawSurface* texture;
|
| 178 | + int currentlight;
|
170 | 179 | } VERTEXSHADERSTATE;
|
171 | 180 | static VERTEXSHADERSTATE vertexshaderstate;
|
172 | 181 |
|
— | — | @@ -741,6 +750,7 @@ |
742 | 751 | ZeroMemory(&lights[i],sizeof(D3DLIGHT7));
|
743 | 752 | lights[i].dcvDiffuse.r = lights[i].dcvDiffuse.g = lights[i].dcvDiffuse.b = 1;
|
744 | 753 | lights[i].dltType = D3DLIGHT_DIRECTIONAL;
|
| 754 | + hexlightcolor[i].diffuse = 0xFFFFFF;
|
745 | 755 | }
|
746 | 756 | lightenable[0] = TRUE;
|
747 | 757 | lights[0].dvPosition = D3DVECTOR(-10,-10,-10);
|
— | — | @@ -1780,6 +1790,7 @@ |
1781 | 1791 | SendDlgItemMessage(hWnd,IDC_CULLMODE,CB_ADDSTRING,0,(LPARAM)_T("CW"));
|
1782 | 1792 | SendDlgItemMessage(hWnd,IDC_CULLMODE,CB_ADDSTRING,0,(LPARAM)_T("CCW"));
|
1783 | 1793 | SendDlgItemMessage(hWnd,IDC_CULLMODE,CB_SETCURSEL,2,0);
|
| 1794 | + SendDlgItemMessage(hWnd,IDC_VERTEXCOLOR,BM_SETCHECK,BST_CHECKED,0);
|
1784 | 1795 | PopulateSourceCombo(GetDlgItem(hWnd,IDC_DIFFUSESOURCE));
|
1785 | 1796 | PopulateSourceCombo(GetDlgItem(hWnd,IDC_SPECULARSOURCE));
|
1786 | 1797 | PopulateSourceCombo(GetDlgItem(hWnd,IDC_AMBIENTSOURCE));
|
— | — | @@ -1786,15 +1797,34 @@ |
1787 | 1798 | PopulateSourceCombo(GetDlgItem(hWnd,IDC_EMISSIVESOURCE));
|
1788 | 1799 | SendDlgItemMessage(hWnd,IDC_DIFFUSESOURCE,CB_SETCURSEL,D3DMCS_COLOR1,0);
|
1789 | 1800 | SendDlgItemMessage(hWnd,IDC_SPECULARSOURCE,CB_SETCURSEL,D3DMCS_COLOR2,0);
|
1790 | | - SendDlgItemMessage(hWnd,IDC_AMBIENTSOURCE,CB_SETCURSEL,D3DMCS_COLOR2,0);
|
| 1801 | + SendDlgItemMessage(hWnd,IDC_AMBIENTSOURCE,CB_SETCURSEL,D3DMCS_MATERIAL,0);
|
1791 | 1802 | SendDlgItemMessage(hWnd,IDC_EMISSIVESOURCE,CB_SETCURSEL,D3DMCS_MATERIAL,0);
|
1792 | 1803 | SendDlgItemMessage(hWnd,IDC_SPINDETAIL,UDM_SETRANGE32,2,64);
|
1793 | 1804 | SendDlgItemMessage(hWnd,IDC_SPINDETAIL,UDM_SETPOS32,0,8);
|
| 1805 | + SendDlgItemMessage(hWnd,IDC_SPINLIGHT,UDM_SETRANGE32,0,7);
|
| 1806 | + SendDlgItemMessage(hWnd,IDC_LIGHTDIFFUSE,WM_SETTEXT,0,(LPARAM)_T("00FFFFFF"));
|
| 1807 | + SendDlgItemMessage(hWnd,IDC_LIGHTAMBIENT,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
| 1808 | + SendDlgItemMessage(hWnd,IDC_LIGHTSPECULAR,WM_SETTEXT,0,(LPARAM)_T("00000000"));
|
| 1809 | + SendDlgItemMessage(hWnd,IDC_LIGHTRANGE,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 1810 | + SendDlgItemMessage(hWnd,IDC_LIGHTFALLOFF,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 1811 | + SendDlgItemMessage(hWnd,IDC_LIGHTTHETA,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 1812 | + SendDlgItemMessage(hWnd,IDC_LIGHTPHI,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 1813 | + SendDlgItemMessage(hWnd,IDC_LIGHTATTEN0,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 1814 | + SendDlgItemMessage(hWnd,IDC_LIGHTATTEN1,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 1815 | + SendDlgItemMessage(hWnd,IDC_LIGHTATTEN2,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 1816 | + SendDlgItemMessage(hWnd,IDC_POWER,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 1817 | + SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("Point"));
|
| 1818 | + SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("Spot"));
|
| 1819 | + SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("Directional"));
|
| 1820 | + SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("Parallel Point"));
|
| 1821 | + SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_ADDSTRING,0,(LPARAM)_T("GL Spot"));
|
| 1822 | + SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_SETCURSEL,D3DLIGHT_DIRECTIONAL-1,0);
|
1794 | 1823 | ::width = ddsd.dwWidth;
|
1795 | 1824 | ::height = ddsd.dwHeight;
|
1796 | 1825 | vertexshaderstate.texture = NULL;
|
1797 | 1826 | vertexshaderstate.texturefile[0] = 0;
|
1798 | 1827 | vertexshaderstate.texturetype = 0;
|
| 1828 | + vertexshaderstate.currentlight = 0;
|
1799 | 1829 | StartTimer(hWnd,WM_APP,60);
|
1800 | 1830 | break;
|
1801 | 1831 | case WM_COMMAND:
|
— | — | @@ -1937,6 +1967,7 @@ |
1938 | 1968 | }
|
1939 | 1969 | break;
|
1940 | 1970 | case IDC_EMISSIVE:
|
| 1971 | + if(HIWORD(wParam) == EN_CHANGE)
|
1941 | 1972 | {
|
1942 | 1973 | SendDlgItemMessage(hWnd,IDC_EMISSIVE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1943 | 1974 | _stscanf(tmpstring,_T("%x"),&number);
|
— | — | @@ -1948,6 +1979,7 @@ |
1949 | 1980 | }
|
1950 | 1981 | break;
|
1951 | 1982 | case IDC_MATAMBIENT:
|
| 1983 | + if(HIWORD(wParam) == EN_CHANGE)
|
1952 | 1984 | {
|
1953 | 1985 | SendDlgItemMessage(hWnd,IDC_MATAMBIENT,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1954 | 1986 | _stscanf(tmpstring,_T("%x"),&number);
|
— | — | @@ -1959,6 +1991,7 @@ |
1960 | 1992 | }
|
1961 | 1993 | break;
|
1962 | 1994 | case IDC_MATDIFFUSE:
|
| 1995 | + if(HIWORD(wParam) == EN_CHANGE)
|
1963 | 1996 | {
|
1964 | 1997 | SendDlgItemMessage(hWnd,IDC_MATDIFFUSE,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1965 | 1998 | _stscanf(tmpstring,_T("%x"),&number);
|
— | — | @@ -1970,6 +2003,7 @@ |
1971 | 2004 | }
|
1972 | 2005 | break;
|
1973 | 2006 | case IDC_MATSPECULAR:
|
| 2007 | + if(HIWORD(wParam) == EN_CHANGE)
|
1974 | 2008 | {
|
1975 | 2009 | SendDlgItemMessage(hWnd,IDC_MATSPECULAR,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
1976 | 2010 | _stscanf(tmpstring,_T("%x"),&number);
|
— | — | @@ -1980,6 +2014,14 @@ |
1981 | 2015 | d3d7dev->SetMaterial(&material);
|
1982 | 2016 | }
|
1983 | 2017 | break;
|
| 2018 | + case IDC_POWER:
|
| 2019 | + if(HIWORD(wParam) == EN_CHANGE)
|
| 2020 | + {
|
| 2021 | + SendDlgItemMessage(hWnd,IDC_POWER,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
| 2022 | + material.power = (float)_ttof(tmpstring);
|
| 2023 | + d3d7dev->SetMaterial(&material);
|
| 2024 | + }
|
| 2025 | + break;
|
1984 | 2026 | case IDC_ENABLELIGHT:
|
1985 | 2027 | if(HIWORD(wParam) == BN_CLICKED)
|
1986 | 2028 | {
|
— | — | @@ -2013,6 +2055,53 @@ |
2014 | 2056 | MakeCube3D(5,number);
|
2015 | 2057 | }
|
2016 | 2058 | break;
|
| 2059 | + case IDC_DIFFUSESOURCE:
|
| 2060 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 2061 | + {
|
| 2062 | + d3d7dev->SetRenderState(D3DRENDERSTATE_DIFFUSEMATERIALSOURCE,SendDlgItemMessage(hWnd,
|
| 2063 | + IDC_DIFFUSESOURCE,CB_GETCURSEL,0,0));
|
| 2064 | + }
|
| 2065 | + break;
|
| 2066 | + case IDC_SPECULARSOURCE:
|
| 2067 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 2068 | + {
|
| 2069 | + d3d7dev->SetRenderState(D3DRENDERSTATE_SPECULARMATERIALSOURCE,SendDlgItemMessage(hWnd,
|
| 2070 | + IDC_SPECULARSOURCE,CB_GETCURSEL,0,0));
|
| 2071 | + }
|
| 2072 | + break;
|
| 2073 | + case IDC_AMBIENTSOURCE:
|
| 2074 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 2075 | + {
|
| 2076 | + d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENTMATERIALSOURCE,SendDlgItemMessage(hWnd,
|
| 2077 | + IDC_AMBIENTSOURCE,CB_GETCURSEL,0,0));
|
| 2078 | + }
|
| 2079 | + break;
|
| 2080 | + case IDC_EMISSIVESOURCE:
|
| 2081 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 2082 | + {
|
| 2083 | + d3d7dev->SetRenderState(D3DRENDERSTATE_EMISSIVEMATERIALSOURCE,SendDlgItemMessage(hWnd,
|
| 2084 | + IDC_EMISSIVESOURCE,CB_GETCURSEL,0,0));
|
| 2085 | + }
|
| 2086 | + break;
|
| 2087 | + case IDC_LIGHTNUMBER:
|
| 2088 | + if(HIWORD(wParam) == EN_CHANGE)
|
| 2089 | + {
|
| 2090 | + SendDlgItemMessage(hWnd,IDC_LIGHTNUMBER,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
|
| 2091 | + number = _ttoi(tmpstring);
|
| 2092 | + if(number < 0) SendDlgItemMessage(hWnd,IDC_LIGHTNUMBER,WM_SETTEXT,0,(LPARAM)_T("0"));
|
| 2093 | + if(number > 7) SendDlgItemMessage(hWnd,IDC_LIGHTNUMBER,WM_SETTEXT,0,(LPARAM)_T("7"));
|
| 2094 | + vertexshaderstate.currentlight = number;
|
| 2095 | + _itot(hexlightcolor[vertexshaderstate.currentlight].ambient,tmpstring,16);
|
| 2096 | + strupper(tmpstring); paddwordzeroes(tmpstring);
|
| 2097 | + SendDlgItemMessage(hWnd,IDC_LIGHTAMBIENT,WM_SETTEXT,0,(LPARAM)tmpstring);
|
| 2098 | + _itot(hexlightcolor[vertexshaderstate.currentlight].diffuse,tmpstring,16);
|
| 2099 | + strupper(tmpstring); paddwordzeroes(tmpstring);
|
| 2100 | + SendDlgItemMessage(hWnd,IDC_LIGHTDIFFUSE,WM_SETTEXT,0,(LPARAM)tmpstring);
|
| 2101 | + _itot(hexlightcolor[vertexshaderstate.currentlight].specular,tmpstring,16);
|
| 2102 | + strupper(tmpstring); paddwordzeroes(tmpstring);
|
| 2103 | + SendDlgItemMessage(hWnd,IDC_LIGHTSPECULAR,WM_SETTEXT,0,(LPARAM)tmpstring);
|
| 2104 | + SendDlgItemMessage(hWnd,IDC_LIGHTTYPE,CB_SETCURSEL,lights[vertexshaderstate.currentlight].dltType-1,0);
|
| 2105 | + }
|
2017 | 2106 | default:
|
2018 | 2107 | return FALSE;
|
2019 | 2108 | }
|