Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

592 lines
20 KiB

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include <commdlg.h>
  5. #include <math.h>
  6. #include <gl/gl.h>
  7. #include <gl/glu.h>
  8. #include <gl/glaux.h>
  9. #include "hugetest.h"
  10. #include "texture.h"
  11. #include "resource.h"
  12. #include "ui_huge.h"
  13. #include "macros.h"
  14. extern HINSTANCE hInstance;
  15. BOOL PreviewImage(HWND hDlg, ImageType cWhichImage, char *szFileName);
  16. BOOL LoadImage(TEXTUREDATA *pxd);
  17. #define COLOR_STRING "Color Pattern"
  18. #define MONO_STRING "Monochrome Checkers"
  19. #define CHECKERWIDTH 64
  20. #define CHECKERHEIGHT 64
  21. GLubyte acMonoCheckerImage[3 * CHECKERWIDTH * CHECKERHEIGHT];
  22. GLubyte acColorImage[3 * CHECKERWIDTH * CHECKERHEIGHT];
  23. AUX_RGBImageRec MonoImageRec;
  24. AUX_RGBImageRec ColorImageRec;
  25. void MakeMonoCheckerImage()
  26. {
  27. int i, j, c;
  28. static BOOL done = FALSE;
  29. if (done) return;
  30. done = TRUE;
  31. MonoImageRec.sizeX = CHECKERWIDTH;
  32. MonoImageRec.sizeY = CHECKERHEIGHT;
  33. MonoImageRec.data = acMonoCheckerImage;
  34. for (i = 0 ; i < CHECKERWIDTH ; i++) {
  35. for (j = 0 ; j < CHECKERHEIGHT ; j++) {
  36. c = ((((i&0x8)==0)^((j&0x8))==0))*255;
  37. acMonoCheckerImage[3 * (CHECKERHEIGHT * i + j) + 0] = (GLubyte) c;
  38. acMonoCheckerImage[3 * (CHECKERHEIGHT * i + j) + 1] = (GLubyte) c;
  39. acMonoCheckerImage[3 * (CHECKERHEIGHT * i + j) + 2] = (GLubyte) c;
  40. }
  41. }
  42. }
  43. void MakeColorImage(void)
  44. {
  45. int i, j;
  46. float ti, tj;
  47. static BOOL done = FALSE;
  48. if (done) return;
  49. done = TRUE;
  50. ColorImageRec.sizeX = CHECKERWIDTH;
  51. ColorImageRec.sizeY = CHECKERHEIGHT;
  52. ColorImageRec.data = acColorImage;
  53. for (i = 0; i < CHECKERWIDTH; i++) {
  54. ti = 2.0f*3.14159265f*i/CHECKERWIDTH;
  55. for (j = 0; j < CHECKERHEIGHT; j++) {
  56. tj = 2.0f*3.14159265f*j/CHECKERHEIGHT;
  57. acColorImage[3*(CHECKERHEIGHT*i+j)+0]=(GLubyte)(127*(1.0+sin(ti)));
  58. acColorImage[3*(CHECKERHEIGHT*i+j)+1]=(GLubyte)(127*(1.0+cos(2*tj)));
  59. acColorImage[3*(CHECKERHEIGHT*i+j)+2]=(GLubyte)(127*(1.0+cos(ti+tj)));
  60. }
  61. }
  62. }
  63. void InitXD(TEXTUREDATA *pxd)
  64. {
  65. MakeMonoCheckerImage();
  66. MakeColorImage();
  67. bzero(pxd,sizeof(TEXTUREDATA));
  68. BEGINstring(pxd, "texture");
  69. ENDstring(pxd, "texture");
  70. sprintf(pxd->szFileName, MONO_STRING);
  71. pxd->cWhichImage = MONO_CHECKERS;
  72. pxd->iHeight = CHECKERHEIGHT;
  73. pxd->iWidth = CHECKERWIDTH;
  74. pxd->iBorder = 0;
  75. pxd->iQuality = DONT_CARE;
  76. pxd->bEnable1D = FALSE;
  77. pxd->bEnable2D = FALSE;
  78. pxd->bBuildMipmap = TRUE;
  79. pxd->aiFilter[0] = NEAREST_MIPMAP_LINEAR;
  80. pxd->aiFilter[1] = LINEAR;
  81. pxd->aiFilter[2] = NEAREST_MIPMAP_LINEAR;
  82. pxd->aiFilter[3] = LINEAR;
  83. pxd->iEnvMode = MODULATE;
  84. pxd->iGenModeS = EYE_LINEAR;
  85. pxd->iGenModeT = EYE_LINEAR;
  86. pxd->iGenModeR = EYE_LINEAR;
  87. pxd->iGenModeQ = EYE_LINEAR;
  88. pxd->bAutoGenS = TRUE;
  89. pxd->bAutoGenT = TRUE;
  90. pxd->bAutoGenR = FALSE;
  91. pxd->bAutoGenQ = FALSE;
  92. pxd->iWrapS = REPEAT;
  93. pxd->iWrapT = REPEAT;
  94. LoadImage(pxd);
  95. } // void InitXD(TEXTUREDATA *pxd);
  96. void texture_init(const TEXTUREDATA xd)
  97. {
  98. byte *Image = NULL;
  99. int iWidth, iHeight;
  100. byte Image64[64][64][3];
  101. int iErr;
  102. float Debug_S[] = { 1.0, 1.0, 1.0, 0.0 };
  103. float Debug_T[] = { 0.0, 1.0, 0.0, 0.0 };
  104. Image = xd.acImage;
  105. iWidth = xd.iWidth;
  106. iHeight = xd.iHeight;
  107. switch (xd.iQuality) {
  108. case FASTEST: glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST); break;
  109. case DONT_CARE: glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_DONT_CARE); break;
  110. case NICEST: glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); break;
  111. }
  112. if (xd.bEnable1D || xd.bEnable2D) {
  113. switch (xd.iEnvMode) {
  114. case 0: glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); break;
  115. case 1: glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); break;
  116. case 2: glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_BLEND); break;
  117. }
  118. } // if (xd.bEnable1D || xd.bEnable2D)
  119. switch (xd.iWrapS) {
  120. case CLAMP: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  121. break;
  122. case REPEAT: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  123. break;
  124. }
  125. switch (xd.iWrapT) {
  126. case CLAMP: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  127. break;
  128. case REPEAT: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  129. break;
  130. }
  131. if (xd.bEnable2D) {
  132. if (!Image) {
  133. MessageBox(NULL, "ERROR: No texture image found, using default!",
  134. NULL, MB_OK | MB_ICONERROR);
  135. Image = MonoImageRec.data;
  136. iWidth = MonoImageRec.sizeX;
  137. iHeight = MonoImageRec.sizeY;
  138. }
  139. glTexImage2D(GL_TEXTURE_2D, 0, 3, iWidth, iHeight, xd.iBorder,
  140. GL_RGB, GL_UNSIGNED_BYTE, Image);
  141. if (xd.bBuildMipmap) {
  142. glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  143. iErr = gluScaleImage(GL_RGB, iWidth, iHeight, GL_UNSIGNED_BYTE,
  144. Image, 64, 64, GL_UNSIGNED_BYTE, Image64);
  145. iErr = gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 64, 64, GL_RGB,
  146. GL_UNSIGNED_BYTE, Image64);
  147. }
  148. switch (xd.aiFilter[2]) {
  149. case 0:
  150. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  151. break;
  152. case 1:
  153. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  154. break;
  155. case 2:
  156. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
  157. break;
  158. case 3:
  159. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
  160. break;
  161. case 4:
  162. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
  163. break;
  164. case 5:
  165. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  166. break;
  167. } // switch (xd.aiFilter[2])
  168. switch (xd.aiFilter[3]) {
  169. case 0:glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  170. break;
  171. case 1:glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  172. break;
  173. } // switch (xd.aiFilter[3])
  174. glEnable(GL_TEXTURE_2D);
  175. } else { // if (xd.bEnable2D)
  176. glDisable(GL_TEXTURE_2D);
  177. } // if (xd.bEnable2D) (else)
  178. switch (xd.iGenModeS)
  179. {
  180. case DISABLE: break;
  181. case OBJECT_LINEAR:
  182. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); break;
  183. case EYE_LINEAR:
  184. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); break;
  185. case SPHERE_MAP:
  186. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); break;
  187. }
  188. switch (xd.iGenModeT)
  189. {
  190. case DISABLE: break;
  191. case OBJECT_LINEAR:
  192. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); break;
  193. case EYE_LINEAR:
  194. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); break;
  195. case SPHERE_MAP:
  196. glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); break;
  197. }
  198. switch (xd.iGenModeR)
  199. {
  200. case DISABLE: break;
  201. case OBJECT_LINEAR:
  202. glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); break;
  203. case EYE_LINEAR:
  204. glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); break;
  205. case SPHERE_MAP:
  206. glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); break;
  207. }
  208. switch (xd.iGenModeQ)
  209. {
  210. case DISABLE: break;
  211. case OBJECT_LINEAR:
  212. glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); break;
  213. case EYE_LINEAR:
  214. glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); break;
  215. case SPHERE_MAP:
  216. glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); break;
  217. }
  218. GL_EnableOrDisable(xd.bAutoGenS, GL_TEXTURE_GEN_S);
  219. GL_EnableOrDisable(xd.bAutoGenT, GL_TEXTURE_GEN_T);
  220. GL_EnableOrDisable(xd.bAutoGenR, GL_TEXTURE_GEN_R);
  221. GL_EnableOrDisable(xd.bAutoGenQ, GL_TEXTURE_GEN_Q);
  222. }
  223. BOOL PreviewImage(HWND hDlg, ImageType cWhichImage, char *szFileName)
  224. {
  225. HBITMAP hBitmap;
  226. AUX_RGBImageRec *pImageRec;
  227. switch (cWhichImage)
  228. {
  229. case COLOR_CHECKERS:
  230. hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COLOR_CHECKERS));
  231. szFileName = COLOR_STRING;
  232. pImageRec = &ColorImageRec;
  233. break;
  234. case MONO_CHECKERS:
  235. hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MONO_CHECKERS));
  236. szFileName = MONO_STRING;
  237. pImageRec = &MonoImageRec;
  238. break;
  239. case EXTERNAL:
  240. pImageRec = auxDIBImageLoadA(szFileName);
  241. break;
  242. default:
  243. return FALSE;
  244. }
  245. if (!pImageRec)
  246. return FALSE;
  247. SetDlgItemText(hDlg, X_IDC_FILENAME, szFileName);
  248. SetDlgItemInt(hDlg, X_IDC_WIDTH, pImageRec->sizeX, TRUE);
  249. SetDlgItemInt(hDlg, X_IDC_HEIGHT, pImageRec->sizeY, TRUE);
  250. if (cWhichImage == EXTERNAL) {
  251. free(pImageRec->data);
  252. free(pImageRec);
  253. }
  254. return TRUE;
  255. }
  256. BOOL UnloadImage(TEXTUREDATA *pxd)
  257. {
  258. if (pxd->cWhichImage == EXTERNAL) {
  259. free(pxd->acImage);
  260. }
  261. pxd->cWhichImage = NONE;
  262. pxd->acImage = NULL;
  263. return TRUE;
  264. }
  265. // loads the appropriate image file into pxd->acImage
  266. BOOL LoadImage(TEXTUREDATA *pxd)
  267. {
  268. HBITMAP hBitmap;
  269. AUX_RGBImageRec *pImageRec;
  270. if (pxd->cWhichImage == EXTERNAL) {
  271. pImageRec = auxDIBImageLoadA(pxd->szFileName);
  272. if (pImageRec) {
  273. pxd->acImage = pImageRec->data;
  274. pxd->iWidth = pImageRec->sizeX;
  275. pxd->iHeight = pImageRec->sizeY;
  276. free(pImageRec);
  277. } else {
  278. pxd->cWhichImage = MONO_CHECKERS;
  279. }
  280. }
  281. switch (pxd->cWhichImage)
  282. {
  283. case COLOR_CHECKERS:
  284. hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_COLOR_CHECKERS));
  285. pxd->acImage = (byte*) acColorImage;
  286. pxd->iWidth = CHECKERWIDTH;
  287. pxd->iHeight = CHECKERHEIGHT;
  288. break;
  289. case MONO_CHECKERS:
  290. hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MONO_CHECKERS));
  291. pxd->acImage = (byte*) acMonoCheckerImage;
  292. pxd->iWidth = CHECKERWIDTH;
  293. pxd->iHeight = CHECKERHEIGHT;
  294. break;
  295. case EXTERNAL:
  296. break;
  297. default:
  298. return FALSE;
  299. }
  300. return TRUE;
  301. }
  302. #ifndef NO_UI_IN_CNFG
  303. void texture_SetDisplayFromData(HWND hDlg, const TEXTUREDATA *pxd)
  304. {
  305. CB_DlgSetSelect(hDlg, X_IDC_ENV_MODE, pxd->iEnvMode);
  306. CB_DlgSetSelect(hDlg, X_IDC_FILTER1, pxd->aiFilter[0]);
  307. CB_DlgSetSelect(hDlg, X_IDC_FILTER2, pxd->aiFilter[1]);
  308. CB_DlgSetSelect(hDlg, X_IDC_FILTER3, pxd->aiFilter[2]);
  309. CB_DlgSetSelect(hDlg, X_IDC_FILTER4, pxd->aiFilter[3]);
  310. CB_DlgSetSelect(hDlg, X_IDC_GEN_MODE_S, pxd->iGenModeS);
  311. CB_DlgSetSelect(hDlg, X_IDC_PERSPECTIVE_QUALITY, pxd->iQuality);
  312. CB_DlgSetSelect(hDlg, X_IDC_WRAP_S, pxd->iWrapS);
  313. CB_DlgSetSelect(hDlg, X_IDC_WRAP_T, pxd->iWrapT);
  314. CheckDlgButton(hDlg, X_IDC_1D_ENABLE, pxd->bEnable1D?1:0);
  315. CheckDlgButton(hDlg, X_IDC_2D_ENABLE, pxd->bEnable2D?1:0);
  316. CheckDlgButton(hDlg, X_IDC_AUTOMATIC_Q, pxd->bAutoGenQ?1:0);
  317. CheckDlgButton(hDlg, X_IDC_AUTOMATIC_R, pxd->bAutoGenR?1:0);
  318. CheckDlgButton(hDlg, X_IDC_AUTOMATIC_S, pxd->bAutoGenS?1:0);
  319. CheckDlgButton(hDlg, X_IDC_AUTOMATIC_T, pxd->bAutoGenT?1:0);
  320. CheckDlgButton(hDlg, X_IDC_BUILD_MIPMAP, pxd->bBuildMipmap?1:0);
  321. SetDlgFloatString(hDlg, X_IDC_BORDER_COLOR1, pxd->afBorderColor[0]);
  322. SetDlgFloatString(hDlg, X_IDC_BORDER_COLOR2, pxd->afBorderColor[1]);
  323. SetDlgFloatString(hDlg, X_IDC_BORDER_COLOR3, pxd->afBorderColor[2]);
  324. SetDlgFloatString(hDlg, X_IDC_BORDER_COLOR4, pxd->afBorderColor[3]);
  325. SetDlgItemInt(hDlg, X_IDC_BORDER, pxd->iBorder, TRUE);
  326. SetDlgItemInt(hDlg, X_IDC_HEIGHT, pxd->iHeight, TRUE);
  327. SetDlgItemInt(hDlg, X_IDC_WIDTH, pxd->iWidth, TRUE);
  328. SetDlgItemText(hDlg, X_IDC_FILENAME, pxd->szFileName);
  329. } // void texture_SetDisplayFromData(HWND hDlg, const TEXTUREDATA *pxd);
  330. void texture_GetDataFromDisplay(HWND hDlg, TEXTUREDATA *pxd)
  331. {
  332. UnloadImage(pxd);
  333. GetDlgItemText(hDlg,X_IDC_FILENAME,pxd->szFileName,sizeof(pxd->szFileName));
  334. pxd->afBorderColor[0] = GetDlgFloatString(hDlg, X_IDC_BORDER_COLOR1);
  335. pxd->afBorderColor[1] = GetDlgFloatString(hDlg, X_IDC_BORDER_COLOR2);
  336. pxd->afBorderColor[2] = GetDlgFloatString(hDlg, X_IDC_BORDER_COLOR3);
  337. pxd->afBorderColor[3] = GetDlgFloatString(hDlg, X_IDC_BORDER_COLOR4);
  338. pxd->aiFilter[0] = CB_DlgGetSelect(hDlg, X_IDC_FILTER1);
  339. pxd->aiFilter[1] = CB_DlgGetSelect(hDlg, X_IDC_FILTER2);
  340. pxd->aiFilter[2] = CB_DlgGetSelect(hDlg, X_IDC_FILTER3);
  341. pxd->aiFilter[3] = CB_DlgGetSelect(hDlg, X_IDC_FILTER4);
  342. pxd->bAutoGenQ = IsDlgButtonChecked(hDlg, X_IDC_AUTOMATIC_Q);
  343. pxd->bAutoGenR = IsDlgButtonChecked(hDlg, X_IDC_AUTOMATIC_R);
  344. pxd->bAutoGenS = IsDlgButtonChecked(hDlg, X_IDC_AUTOMATIC_S);
  345. pxd->bAutoGenT = IsDlgButtonChecked(hDlg, X_IDC_AUTOMATIC_T);
  346. pxd->bBuildMipmap = IsDlgButtonChecked(hDlg, X_IDC_BUILD_MIPMAP);
  347. pxd->bEnable1D = IsDlgButtonChecked(hDlg, X_IDC_1D_ENABLE);
  348. pxd->bEnable2D = IsDlgButtonChecked(hDlg, X_IDC_2D_ENABLE);
  349. pxd->iBorder = GetDlgItemInt(hDlg, X_IDC_BORDER, NULL, TRUE);
  350. pxd->iEnvMode = CB_DlgGetSelect(hDlg, X_IDC_ENV_MODE);
  351. pxd->iEnvMode = CB_DlgGetSelect(hDlg, X_IDC_ENV_MODE);
  352. pxd->iGenModeS = CB_DlgGetSelect(hDlg, X_IDC_GEN_MODE_S);
  353. pxd->iGenModeT = pxd->iGenModeR = pxd->iGenModeQ = pxd->iGenModeS;
  354. pxd->iHeight = GetDlgItemInt(hDlg, X_IDC_HEIGHT, NULL, TRUE);
  355. pxd->iQuality = CB_DlgGetSelect(hDlg, X_IDC_PERSPECTIVE_QUALITY);
  356. pxd->iWidth = GetDlgItemInt(hDlg, X_IDC_WIDTH, NULL, TRUE);
  357. pxd->iWrapS = CB_DlgGetSelect(hDlg, X_IDC_WRAP_S);
  358. pxd->iWrapT = CB_DlgGetSelect(hDlg, X_IDC_WRAP_T);
  359. pxd->cWhichImage = EXTERNAL;
  360. /* This switch statement is setup and use for speed, because it's much
  361. * faster than using several if statements which all call strcmp.
  362. * It is likely that szFileName begins with "C:\" so we check for "C:", not
  363. * just "C".
  364. */
  365. switch (pxd->szFileName[0])
  366. {
  367. case 'c':
  368. case 'C':
  369. if (pxd->szFileName[1] != ':')
  370. if (0 == strcmp(pxd->szFileName, COLOR_STRING))
  371. pxd->cWhichImage = COLOR_CHECKERS;
  372. break;
  373. case 'm':
  374. case 'M':
  375. if (0 == strcmp(pxd->szFileName, MONO_STRING))
  376. pxd->cWhichImage = MONO_CHECKERS;
  377. break;
  378. }
  379. LoadImage(pxd);
  380. } // void texture_GetDataFromDisplay(HWND hDlg, TEXTUREDATA *pxd);
  381. void ShowOrHideFilter(HWND hDlg)
  382. {
  383. int iIDs[] = { X_IDC_FILTER1, X_IDC_FILTER2, X_IDC_FILTER3, X_IDC_FILTER4 };
  384. int i, iShow;
  385. iShow = IsDlgButtonChecked(hDlg,X_IDC_FILTER_MAG);
  386. iShow += IsDlgButtonChecked(hDlg,X_IDC_FILTER_2D) ? 2 : 0;
  387. for (i = 0 ; i < 4 ; i++) {
  388. ShowWindow(GetDlgItem(hDlg, iIDs[i]), iShow==i ? SW_SHOWNORMAL: SW_HIDE);
  389. }
  390. } // void ShowOrHideFilter(HWND hDlg)
  391. BOOL CALLBACK hugeTextureDlgProc(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
  392. {
  393. static TEXTUREDATA *pxd = NULL;
  394. static OPENFILENAME ofn;
  395. static char szFileName[_MAX_PATH];
  396. static char szTitleName[_MAX_FNAME + _MAX_EXT];
  397. static char szFilter[] = "Bitmap Files (*.bmp)\0*.bmp\0" \
  398. "All Files (*.*)\0*.*\0\0" ;
  399. switch (msg)
  400. {
  401. case WM_INITDIALOG:
  402. pxd = (TEXTUREDATA*) (((PROPSHEETPAGE*)lParam)->lParam);
  403. CB_DlgAddString(hDlg, X_IDC_PERSPECTIVE_QUALITY, "Fastest");
  404. CB_DlgAddString(hDlg, X_IDC_PERSPECTIVE_QUALITY, "Don't Care");
  405. CB_DlgAddString(hDlg, X_IDC_PERSPECTIVE_QUALITY, "Nicest");
  406. CB_DlgAddString(hDlg, X_IDC_ENV_MODE, "Decal");
  407. CB_DlgAddString(hDlg, X_IDC_ENV_MODE, "Modulate");
  408. CB_DlgAddString(hDlg, X_IDC_ENV_MODE, "Blend");
  409. // CB_DlgAddString(hDlg, X_IDC_GEN_MODE_S, "<disabled>");
  410. CB_DlgAddString(hDlg, X_IDC_GEN_MODE_S, "Object Linear");
  411. CB_DlgAddString(hDlg, X_IDC_GEN_MODE_S, "Eye Linear");
  412. CB_DlgAddString(hDlg, X_IDC_GEN_MODE_S, "Sphere Map");
  413. CheckDlgButton(hDlg, X_IDC_FILTER_2D, 1);
  414. CheckDlgButton(hDlg, X_IDC_FILTER_MAG, 1);
  415. CB_DlgAddString(hDlg, X_IDC_FILTER1, "Nearest");
  416. CB_DlgAddString(hDlg, X_IDC_FILTER1, "Linear");
  417. CB_DlgAddString(hDlg, X_IDC_FILTER1, "Nearest Mipmap Nearest");
  418. CB_DlgAddString(hDlg, X_IDC_FILTER1, "Nearest Mipmap Linear");
  419. CB_DlgAddString(hDlg, X_IDC_FILTER1, "Linear Mipmap Nearest");
  420. CB_DlgAddString(hDlg, X_IDC_FILTER1, "Linear Mipmap Linear");
  421. CB_DlgAddString(hDlg, X_IDC_FILTER2, "Nearest");
  422. CB_DlgAddString(hDlg, X_IDC_FILTER2, "Linear");
  423. CB_DlgAddString(hDlg, X_IDC_FILTER3, "Nearest");
  424. CB_DlgAddString(hDlg, X_IDC_FILTER3, "Linear");
  425. CB_DlgAddString(hDlg, X_IDC_FILTER3, "Nearest Mipmap Nearest");
  426. CB_DlgAddString(hDlg, X_IDC_FILTER3, "Nearest Mipmap Linear");
  427. CB_DlgAddString(hDlg, X_IDC_FILTER3, "Linear Mipmap Nearest");
  428. CB_DlgAddString(hDlg, X_IDC_FILTER3, "Linear Mipmap Linear");
  429. CB_DlgAddString(hDlg, X_IDC_FILTER4, "Nearest");
  430. CB_DlgAddString(hDlg, X_IDC_FILTER4, "Linear");
  431. CB_DlgAddString(hDlg, X_IDC_WRAP_S, "Clamp S");
  432. CB_DlgAddString(hDlg, X_IDC_WRAP_S, "Repeat S");
  433. CB_DlgAddString(hDlg, X_IDC_WRAP_T, "Clamp T");
  434. CB_DlgAddString(hDlg, X_IDC_WRAP_T, "Repeat T");
  435. ShowOrHideFilter(hDlg);
  436. texture_SetDisplayFromData(hDlg, pxd);
  437. ofn.lStructSize = sizeof (OPENFILENAME);
  438. ofn.hwndOwner = hDlg;
  439. ofn.hInstance = NULL;
  440. ofn.lpstrFilter = szFilter;
  441. ofn.lpstrCustomFilter = NULL;
  442. ofn.nMaxCustFilter = 0;
  443. ofn.nFilterIndex = 0;
  444. ofn.lpstrFile = szFileName;
  445. ofn.nMaxFile = _MAX_PATH;
  446. ofn.lpstrFileTitle = szTitleName;
  447. ofn.nMaxFileTitle = _MAX_FNAME + _MAX_EXT;
  448. ofn.lpstrInitialDir = NULL;
  449. ofn.lpstrTitle = NULL;
  450. ofn.Flags = OFN_FILEMUSTEXIST;
  451. ofn.nFileOffset = 0;
  452. ofn.nFileExtension = 0;
  453. ofn.lpstrDefExt = "bmp";
  454. ofn.lCustData = 0L;
  455. ofn.lpfnHook = NULL;
  456. ofn.lpTemplateName = NULL;
  457. break;
  458. case WM_COMMAND:
  459. {
  460. int iControl, iNote;
  461. iControl = LOWORD(wParam);
  462. iNote = HIWORD(wParam); // notification code for edit boxes
  463. switch (iControl)
  464. {
  465. case X_IDC_BORDER_COLOR1:
  466. case X_IDC_BORDER_COLOR2:
  467. case X_IDC_BORDER_COLOR3:
  468. case X_IDC_BORDER_COLOR4:
  469. if (EN_KILLFOCUS == iNote) {
  470. PropSheet_Changed(GetParent(hDlg),hDlg);
  471. VerifyEditboxFloat(hDlg,iControl);
  472. }
  473. break;
  474. case X_IDC_PICKFILE:
  475. ofn.hwndOwner = hDlg;
  476. if (GetOpenFileName (&ofn)) {
  477. PreviewImage(hDlg, EXTERNAL, szFileName);
  478. };
  479. break;
  480. case X_IDC_PICKFILE_C:
  481. PreviewImage(hDlg, COLOR_CHECKERS, NULL);
  482. break;
  483. case X_IDC_PICKFILE_M:
  484. PreviewImage(hDlg, MONO_CHECKERS, NULL);
  485. break;
  486. case X_IDC_FILTER_1D:
  487. case X_IDC_FILTER_2D:
  488. case X_IDC_FILTER_MAG:
  489. case X_IDC_FILTER_MIN:
  490. ShowOrHideFilter(hDlg);
  491. break;
  492. default:
  493. PropSheet_Changed(GetParent(hDlg),hDlg);
  494. break;
  495. }
  496. }
  497. break;
  498. case WM_NOTIFY:
  499. {
  500. LPNMHDR pnmh = (LPNMHDR) lParam;
  501. switch (pnmh->code)
  502. {
  503. case PSN_APPLY: // user clicked on OK or Apply
  504. texture_GetDataFromDisplay(hDlg, pxd);
  505. break;
  506. case PSN_RESET: // user clicked on Cancel
  507. break;
  508. case PSN_HELP: // user clicked help
  509. break;
  510. }
  511. }
  512. break;
  513. default:
  514. return FALSE;
  515. }
  516. return TRUE;
  517. }
  518. #else
  519. #endif // NO_UI_IN_CNFG