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.

173 lines
5.3 KiB

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include "hugetest.h"
  5. #include "resource.h"
  6. #include "ui_huge.h"
  7. #include "macros.h"
  8. void InitFD(FOGDATA *pfd)
  9. {
  10. bzero(pfd,sizeof(FOGDATA));
  11. BEGINstring(pfd, "fog");
  12. ENDstring(pfd, "fog");
  13. pfd->fColor[0] = 0.0;
  14. pfd->fColor[1] = 0.0;
  15. pfd->fColor[2] = 0.0;
  16. pfd->fColor[3] = 1.0;
  17. pfd->fDensity = 0.5;
  18. pfd->fLinearStart = 1.0;
  19. pfd->fLinearEnd = 0.0;
  20. pfd->bEnable = FALSE;
  21. pfd->iMode = FOG_EXP; // == Exp
  22. pfd->iQuality = DONT_CARE; // == Don't Care
  23. }
  24. void fog_init(const FOGDATA fd)
  25. {
  26. if (!fd.bEnable) {
  27. glDisable(GL_FOG);
  28. return;
  29. }
  30. glEnable(GL_FOG);
  31. switch(fd.iMode) {
  32. case 0: glFogi (GL_FOG_MODE, GL_EXP); break;
  33. case 1: glFogi (GL_FOG_MODE, GL_EXP2); break;
  34. case 2: glFogi (GL_FOG_MODE, GL_LINEAR); break;
  35. }
  36. glFogf (GL_FOG_START, fd.fLinearStart);
  37. glFogf (GL_FOG_END, fd.fLinearEnd);
  38. glFogfv(GL_FOG_COLOR, fd.fColor);
  39. glFogf (GL_FOG_DENSITY, fd.fDensity);
  40. switch (fd.iQuality) {
  41. case FASTEST: glHint(GL_FOG_HINT, GL_FASTEST); break;
  42. case DONT_CARE: glHint(GL_FOG_HINT, GL_DONT_CARE); break;
  43. case NICEST: glHint(GL_FOG_HINT, GL_NICEST); break;
  44. }
  45. }
  46. #ifndef NO_UI_IN_CNFG
  47. void fog_SetDisplayFromData(HWND hDlg, const FOGDATA *pfd)
  48. {
  49. SetDlgFloatString(hDlg, F_IDC_COLOR1, pfd->fColor[0]);
  50. SetDlgFloatString(hDlg, F_IDC_COLOR2, pfd->fColor[1]);
  51. SetDlgFloatString(hDlg, F_IDC_COLOR3, pfd->fColor[2]);
  52. SetDlgFloatString(hDlg, F_IDC_COLOR4, pfd->fColor[3]);
  53. SetDlgFloatString(hDlg, F_IDC_DENSITY, pfd->fDensity);
  54. SetDlgFloatString(hDlg, F_IDC_LINEARSTART,pfd->fLinearStart);
  55. SetDlgFloatString(hDlg, F_IDC_LINEAREND, pfd->fLinearEnd);
  56. CheckDlgButton(hDlg, IDC_ENABLE, pfd->bEnable?1:0);
  57. CB_DlgSetSelect(hDlg, F_IDC_MODE, pfd->iMode);
  58. CB_DlgSetSelect(hDlg, F_IDC_QUALITY, pfd->iQuality);
  59. }
  60. void fog_GetDataFromDisplay(HWND hDlg, FOGDATA *pfd)
  61. {
  62. pfd->fColor[0] = GetDlgFloatString(hDlg, F_IDC_COLOR1);
  63. pfd->fColor[1] = GetDlgFloatString(hDlg, F_IDC_COLOR2);
  64. pfd->fColor[2] = GetDlgFloatString(hDlg, F_IDC_COLOR3);
  65. pfd->fColor[3] = GetDlgFloatString(hDlg, F_IDC_COLOR4);
  66. pfd->fDensity = GetDlgFloatString(hDlg, F_IDC_DENSITY);
  67. pfd->fLinearStart = GetDlgFloatString(hDlg, F_IDC_LINEARSTART);
  68. pfd->fLinearEnd = GetDlgFloatString(hDlg, F_IDC_LINEAREND);
  69. pfd->bEnable = IsDlgButtonChecked(hDlg,IDC_ENABLE);
  70. pfd->iMode = CB_DlgGetSelect(hDlg, F_IDC_MODE);
  71. pfd->iQuality = CB_DlgGetSelect(hDlg, F_IDC_QUALITY);
  72. }
  73. void fog_EnableOrDisableWindows(HWND hDlg)
  74. {
  75. static int aiCommands[] =
  76. { F_IDC_COLOR1, F_IDC_COLOR2, F_IDC_COLOR3, F_IDC_COLOR4,
  77. F_IDC_DENSITY, F_IDC_LINEAREND, F_IDC_LINEARSTART, F_IDC_MODE,
  78. F_IDC_QUALITY };
  79. const int iNumCommands = 9;
  80. BOOL b;
  81. int i;
  82. b = (BOOL) IsDlgButtonChecked(hDlg, IDC_ENABLE);
  83. for (i = 0 ; i < iNumCommands ; i++) {
  84. EnableWindow(GetDlgItem(hDlg,aiCommands[i]),b);
  85. }
  86. }
  87. BOOL CALLBACK hugeFogDlgProc(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
  88. {
  89. static FOGDATA *pfd = NULL;
  90. switch (msg)
  91. {
  92. case WM_INITDIALOG:
  93. pfd = (FOGDATA*) (((PROPSHEETPAGE*)lParam)->lParam);
  94. CB_DlgAddString(hDlg, F_IDC_MODE, "Exp");
  95. CB_DlgAddString(hDlg, F_IDC_MODE, "Exp2");
  96. CB_DlgAddString(hDlg, F_IDC_MODE, "Linear");
  97. CB_DlgAddString(hDlg, F_IDC_QUALITY, "Fastest");
  98. CB_DlgAddString(hDlg, F_IDC_QUALITY, "Don't Care");
  99. CB_DlgAddString(hDlg, F_IDC_QUALITY, "Nicest");
  100. fog_SetDisplayFromData(hDlg,pfd);
  101. fog_EnableOrDisableWindows(hDlg);
  102. return TRUE;
  103. case WM_COMMAND:
  104. {
  105. int iControl, iNote;
  106. iControl = LOWORD(wParam);
  107. iNote = HIWORD(wParam); // notification code for edit boxes
  108. switch (iControl)
  109. {
  110. case IDC_ENABLE:
  111. PropSheet_Changed(GetParent(hDlg),hDlg);
  112. fog_EnableOrDisableWindows(hDlg);
  113. break;
  114. case F_IDC_COLOR1:
  115. case F_IDC_COLOR2:
  116. case F_IDC_COLOR3:
  117. case F_IDC_COLOR4:
  118. case F_IDC_DENSITY:
  119. case F_IDC_LINEAREND:
  120. case F_IDC_LINEARSTART:
  121. case F_IDC_MODE:
  122. if (EN_KILLFOCUS == iNote) {
  123. PropSheet_Changed(GetParent(hDlg),hDlg);
  124. VerifyEditboxFloat(hDlg,iControl);
  125. }
  126. break;
  127. default:
  128. PropSheet_Changed(GetParent(hDlg),hDlg);
  129. break;
  130. }
  131. }
  132. break;
  133. case WM_NOTIFY:
  134. {
  135. LPNMHDR pnmh = (LPNMHDR) lParam;
  136. switch (pnmh->code)
  137. {
  138. case PSN_APPLY: // user clicked on OK or Apply
  139. fog_GetDataFromDisplay(hDlg, pfd);
  140. break;
  141. case PSN_RESET: // user clicked on Cancel
  142. break;
  143. case PSN_HELP: // user clicked help
  144. break;
  145. }
  146. }
  147. break;
  148. default:
  149. return FALSE;
  150. }
  151. return TRUE;
  152. }
  153. #else
  154. #endif // NO_UI_IN_CNFG