DXGL r262 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r261‎ | r262 | r263 >
Date:01:07, 14 September 2012
Author:admin
Status:new
Tags:
Comment:
Update DDSURFACEDESC when setting color keys.
Add constants for special DX5 mask blend shaders.
Add vertex shader dialog resource.
Add color keys to texture shader demo.
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/shadergen.h (modified) (history)
  • /dxgltest/Resource.h (modified) (history)
  • /dxgltest/Tests3D.cpp (modified) (history)
  • /dxgltest/dxgltest.rc (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -962,10 +962,26 @@
963963 if(dwFlags & DDCKEY_COLORSPACE) key.colorspace = true;
964964 else key.colorspace = false;
965965 key.key = *lpDDColorKey;
966 - if(dwFlags & DDCKEY_SRCBLT) colorkey[0] = key;
967 - if(dwFlags & DDCKEY_DESTBLT) colorkey[1] = key;
968 - if(dwFlags & DDCKEY_SRCOVERLAY) colorkey[2] = key;
969 - if(dwFlags & DDCKEY_DESTOVERLAY) colorkey[3] = key;
 966+ if(dwFlags & DDCKEY_SRCBLT)
 967+ {
 968+ ddsd.dwFlags |= DDSD_CKSRCBLT;
 969+ colorkey[0] = key;
 970+ }
 971+ if(dwFlags & DDCKEY_DESTBLT)
 972+ {
 973+ ddsd.dwFlags |= DDSD_CKDESTBLT;
 974+ colorkey[1] = key;
 975+ }
 976+ if(dwFlags & DDCKEY_SRCOVERLAY)
 977+ {
 978+ ddsd.dwFlags |= DDSD_CKSRCOVERLAY;
 979+ colorkey[2] = key;
 980+ }
 981+ if(dwFlags & DDCKEY_DESTOVERLAY)
 982+ {
 983+ ddsd.dwFlags |= DDSD_CKDESTOVERLAY;
 984+ colorkey[3] = key;
 985+ }
970986 return DD_OK;
971987 }
972988 HRESULT WINAPI glDirectDrawSurface7::SetOverlayPosition(LONG lX, LONG lY)
Index: ddraw/shadergen.h
@@ -37,6 +37,9 @@
3838 int texcoords[8];
3939 };
4040
 41+#define D3DTOP_DXGL_DECALMASK 0x101;
 42+#define D3DTOP_DXGL_MODULATEMASK 0x102;
 43+
4144 void ClearShaders();
4245 void SetShader(__int64 id, TEXTURESTAGE *texstate, int *texcoords, bool builtin);
4346 GLuint GetProgram();
Index: dxgltest/Resource.h
@@ -27,6 +27,7 @@
2828 #define IDB_DXGLINV 118
2929 #define IDB_DXGLINV64 119
3030 #define IDD_TEXSHADER 121
 31+#define IDD_VERTEXSHADER 123
3132 #define IDC_DXDIAG 1000
3233 #define IDC_SPINSTAGE 1000
3334 #define IDC_VIDMODES 1000
@@ -39,13 +40,20 @@
4041 #define IDC_TEXTUREPREVIEW 1003
4142 #define IDC_DISPLAY 1004
4243 #define IDC_TESTLIST 1004
 44+#define IDC_FILLMODE 1005
4345 #define IDC_ALPHABLEND 1006
4446 #define IDC_BGCOLOR 1007
 47+#define IDC_SHADEMODE 1008
4548 #define IDC_WINDOWED 1008
4649 #define IDC_FULLSCREEN 1009
 50+#define IDC_CULLMODE 1010
 51+#define IDC_FOGENABLE 1011
4752 #define IDC_APIVER 1012
4853 #define IDC_SPINAPI 1013
 54+#define IDC_ENABLELIGHT 1014
 55+#define IDC_ENABLESPECULAR 1015
4956 #define IDC_VSYNC 1015
 57+#define IDC_AMBIENT 1017
5058 #define IDC_BUFFERS 1017
5159 #define IDC_SPINBACK 1019
5260 #define IDC_FRAMERATE 1023
@@ -114,3 +122,27 @@
115123 #define IDC_RANGEBASEDFOG 1101
116124 #define IDC_BGCOLORSELECT 1102
117125 #define IDC_ALPHATEST 1103
 126+#define IDC_AMBIENTSELECT 1104
 127+#define IDC_VERTEXCOLOR 1106
 128+#define IDC_LOCALVIEWER 1108
 129+#define IDC_EMISSIVE 1111
 130+#define IDC_EMISSIVESELECT 1112
 131+#define IDC_MATAMBIENT 1114
 132+#define IDC_MATAMBIENTSELECT 1116
 133+#define IDC_POWER 1118
 134+#define IDC_LIGHTNUMBER 1120
 135+#define IDC_SPIN1 1121
 136+#define IDC_LIGHTTYPE 1123
 137+#define IDC_LIGHTDIFFUSE 1126
 138+#define IDC_LIGHTDIFFUSESELECT 1127
 139+#define IDC_LIGHTSPECULAR 1129
 140+#define IDC_LIGHTSPECULARSELECT 1131
 141+#define IDC_LIGHTAMBIENT 1134
 142+#define IDC_LIGHTAMBIENTSELECT 1135
 143+#define IDC_LIGHTRANGE 1137
 144+#define IDC_LIGHTFALLOFF 1139
 145+#define IDC_LIGHTATTEN0 1143
 146+#define IDC_LIGHTATTEN1 1144
 147+#define IDC_LIGHTATTEN2 1145
 148+#define IDC_LIGHTTHETA 1147
 149+#define IDC_LIGHTPHI 1149
Index: dxgltest/Tests3D.cpp
@@ -679,7 +679,7 @@
680680 material.ambient.b = 1.0f;
681681 material.ambient.a = 1.0f;
682682 error = d3d7dev->SetMaterial(&material);
683 - error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, TRUE);
 683+ error = d3d7dev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
684684 error = d3d7dev->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xffffffff);
685685 mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
686686 mat._12 = mat._13 = mat._14 = mat._41 = 0.0f;
@@ -924,7 +924,7 @@
925925 }
926926 }
927927
928 -void SelectTexture(MultiDirectDrawSurface **surface, int type, DWORD colorkey, LPCTSTR file)
 928+void SelectTexture(MultiDirectDrawSurface **surface, int type, DWORD colorkey, bool haskey, LPCTSTR file)
929929 {
930930 DDSURFACEDESC2 ddsd;
931931 ZeroMemory(&ddsd,sizeof(DDSURFACEDESC2));
@@ -948,6 +948,9 @@
949949 d3d7dev->EnumTextureFormats(SelectTextureFormatCallback,&ddsd.ddpfPixelFormat);
950950 ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
951951 ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT|DDSD_TEXTURESTAGE;
 952+ DDCOLORKEY ckey;
 953+ ckey.dwColorSpaceHighValue = ckey.dwColorSpaceLowValue = colorkey;
 954+ if(haskey) ddsd.dwFlags |= DDSD_CKSRCBLT;
952955 if(*surface)
953956 {
954957 d3d7dev->SetTexture(texshaderstate.currentstage,NULL);
@@ -974,6 +977,7 @@
975978 SelectObject(hmemdc,holdbmp);
976979 DeleteDC(hmemdc);
977980 DeleteObject(bitmap);
 981+ if(*surface && haskey) (*surface)->SetColorKey(DDCKEY_SRCBLT,&ckey);
978982 if(*surface) d3d7dev->SetTexture(texshaderstate.currentstage,(LPDIRECTDRAWSURFACE7)(*surface)->GetSurface());
979983 break;
980984 case 3:
@@ -989,6 +993,7 @@
990994 SelectObject(hmemdc,holdbmp);
991995 DeleteDC(hmemdc);
992996 DeleteObject(bitmap);
 997+ if(*surface && haskey) (*surface)->SetColorKey(DDCKEY_SRCBLT,&ckey);
993998 if(*surface) d3d7dev->SetTexture(texshaderstate.currentstage,(LPDIRECTDRAWSURFACE7)(*surface)->GetSurface());
994999 break;
9951000 case 4:
@@ -1067,7 +1072,7 @@
10681073 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("DXGL logo (large)"));
10691074 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_ADDSTRING,0,(LPARAM)_T("Texture file"));
10701075 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_SETCURSEL,0,0);
1071 - SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_SETTEXT,0,(LPARAM)_T("00000000"));
 1076+ SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_SETTEXT,0,(LPARAM)_T(""));
10721077 PopulateArgCombo(GetDlgItem(hWnd,IDC_CARG1));
10731078 PopulateArgCombo(GetDlgItem(hWnd,IDC_CARG2));
10741079 PopulateArgCombo(GetDlgItem(hWnd,IDC_AARG1));
@@ -1116,6 +1121,7 @@
11171122 _itot(texshaderstate.texstages[number].keycolor,tmpstring,16);
11181123 strupper(tmpstring);
11191124 paddwordzeroes(tmpstring);
 1125+ if(texshaderstate.texstages[number].colorkey == FALSE) tmpstring[0] = 0;
11201126 SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_SETTEXT,0,(LPARAM)tmpstring);
11211127 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_SETCURSEL,texshaderstate.texstages[number].texturetype,0);
11221128 SendDlgItemMessage(hWnd,IDC_TEXTUREFILE,WM_SETTEXT,0,(LPARAM)texshaderstate.texstages[number].texturefile);
@@ -1158,7 +1164,8 @@
11591165 texshaderstate.texstages[number].texturetype =
11601166 SendDlgItemMessage(hWnd,IDC_TEXTURE,CB_GETCURSEL,0,0);
11611167 SelectTexture(&texshaderstate.texstages[number].texture,texshaderstate.texstages[number].texturetype,
1162 - texshaderstate.texstages[number].colorkey,texshaderstate.texstages[number].texturefile);
 1168+ texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
 1169+ texshaderstate.texstages[number].texturefile);
11631170 }
11641171 break;
11651172 case IDC_TEXTUREFILE:
@@ -1168,7 +1175,8 @@
11691176 SendDlgItemMessage(hWnd,IDC_TEXTUREFILE,WM_GETTEXT,MAX_PATH+1,
11701177 (LPARAM)texshaderstate.texstages[number].texturefile);
11711178 SelectTexture(&texshaderstate.texstages[number].texture,texshaderstate.texstages[number].texturetype,
1172 - texshaderstate.texstages[number].colorkey,texshaderstate.texstages[number].texturefile);
 1179+ texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
 1180+ texshaderstate.texstages[number].texturefile);
11731181 }
11741182 break;
11751183 case IDC_CARG1:
@@ -1286,6 +1294,25 @@
12871295 d3d7dev->SetRenderState(D3DRENDERSTATE_TEXTUREFACTOR,number);
12881296 }
12891297 break;
 1298+ case IDC_TEXCOLORKEY:
 1299+ if(HIWORD(wParam) == EN_CHANGE)
 1300+ {
 1301+ SendDlgItemMessage(hWnd,IDC_TEXCOLORKEY,WM_GETTEXT,MAX_PATH,(LPARAM)tmpstring);
 1302+ number = texshaderstate.currentstage;
 1303+ if(tmpstring[0] == 0)
 1304+ {
 1305+ texshaderstate.texstages[number].colorkey = FALSE;
 1306+ texshaderstate.texstages[number].keycolor = 0;
 1307+ }
 1308+ else
 1309+ {
 1310+ texshaderstate.texstages[number].colorkey = TRUE;
 1311+ _stscanf(tmpstring,_T("%x"),&texshaderstate.texstages[number].keycolor);
 1312+ }
 1313+ SelectTexture(&texshaderstate.texstages[number].texture,texshaderstate.texstages[number].texturetype,
 1314+ texshaderstate.texstages[number].keycolor, texshaderstate.texstages[number].colorkey,
 1315+ texshaderstate.texstages[number].texturefile);
 1316+ }
12901317 case IDC_ALPHABLEND:
12911318 if(HIWORD(wParam) == BN_CLICKED)
12921319 {
@@ -1307,7 +1334,13 @@
13081335 IDC_DESTBLEND,CB_GETCURSEL,0,0)+1);
13091336 }
13101337 break;
1311 -
 1338+ case IDC_COLORKEY:
 1339+ if(HIWORD(wParam) == BN_CLICKED)
 1340+ {
 1341+ if(SendDlgItemMessage(hWnd,IDC_COLORKEY,BM_GETCHECK,0,0) == BST_CHECKED)
 1342+ d3d7dev->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE,TRUE);
 1343+ else d3d7dev->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE,FALSE);
 1344+ }
13121345 }
13131346 break;
13141347 case WM_CLOSE:
Index: dxgltest/dxgltest.rc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream