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.

219 lines
8.9 KiB

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include "hugetest.h"
  5. #include "raster.h"
  6. #include "resource.h"
  7. #include "ui_huge.h"
  8. #include "macros.h"
  9. void InitRD(RASTERDATA *prd)
  10. {
  11. bzero(prd,sizeof(RASTERDATA));
  12. BEGINstring(prd, "raster");
  13. ENDstring(prd, "raster");
  14. prd->fPointSize = 1.0;
  15. prd->bPointSmooth = FALSE;
  16. prd->fLineWidth = 1.0;
  17. prd->bLineSmooth = FALSE;
  18. prd->usLineStipple = ~0;
  19. prd->iLineStippleRepeat = 1;
  20. prd->bLineStippleEnable = FALSE;
  21. prd->bPolyCullFaceEnable = FALSE;
  22. prd->iPolyCullMode = CULL_BACK;
  23. prd->iPolyDir = GL_CCW;
  24. prd->bPolySmooth = FALSE;
  25. prd->iPolyFrontMode = POLY_FILL;
  26. prd->iPolyBackMode = POLY_FILL;
  27. prd->bPolyStippleEnable = FALSE;
  28. prd->uiPolyStipple = ~0;
  29. prd->iPointQuality = DONT_CARE;
  30. prd->iLineQuality = DONT_CARE;
  31. prd->iPolyQuality = DONT_CARE;
  32. }
  33. void raster_init(const RASTERDATA rd)
  34. {
  35. glPointSize(rd.fPointSize);
  36. GL_EnableOrDisable(rd.bPointSmooth, GL_POINT_SMOOTH);
  37. glLineWidth(rd.fLineWidth);
  38. GL_EnableOrDisable(rd.bPointSmooth, GL_LINE_SMOOTH);
  39. glLineStipple(rd.iLineStippleRepeat, rd.usLineStipple);
  40. GL_EnableOrDisable(rd.bLineStippleEnable, GL_LINE_STIPPLE);
  41. GL_EnableOrDisable(rd.bPolyCullFaceEnable, GL_CULL_FACE);
  42. switch(rd.iPolyCullMode) {
  43. case CULL_FRONT: glCullFace(GL_FRONT); break;
  44. case CULL_BACK: glCullFace(GL_BACK); break;
  45. case CULL_FRONT_AND_BACK: glCullFace(GL_FRONT_AND_BACK); break;
  46. }
  47. switch (rd.iPolyFrontMode) {
  48. case POLY_POINT: glPolygonMode(GL_FRONT, GL_POINT); break;
  49. case POLY_LINE: glPolygonMode(GL_FRONT, GL_LINE); break;
  50. case POLY_FILL: glPolygonMode(GL_FRONT, GL_FILL); break;
  51. }
  52. switch (rd.iPolyBackMode) {
  53. case POLY_POINT: glPolygonMode(GL_BACK, GL_POINT); break;
  54. case POLY_LINE: glPolygonMode(GL_BACK, GL_LINE); break;
  55. case POLY_FILL: glPolygonMode(GL_BACK, GL_FILL); break;
  56. }
  57. GL_EnableOrDisable(rd.bPolySmooth, GL_POLYGON_SMOOTH);
  58. GL_EnableOrDisable(rd.bPolyStippleEnable, GL_POLYGON_STIPPLE);
  59. glFrontFace(rd.iPolyDir);
  60. switch (rd.iPointQuality) {
  61. case FASTEST: glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); break;
  62. case DONT_CARE: glHint(GL_POINT_SMOOTH_HINT, GL_DONT_CARE); break;
  63. case NICEST: glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); break;
  64. }
  65. switch (rd.iLineQuality) {
  66. case FASTEST: glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST); break;
  67. case DONT_CARE: glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); break;
  68. case NICEST: glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); break;
  69. }
  70. switch (rd.iPolyQuality) {
  71. case FASTEST: glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); break;
  72. case DONT_CARE: glHint(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE); break;
  73. case NICEST: glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); break;
  74. }
  75. }
  76. #ifndef NO_UI_IN_CNFG
  77. #define SetDlgIntString(hDlg,iCntl,iVal) SetDlgItemInt(hDlg,iCntl,iVal,FALSE)
  78. #define GetDlgIntString(hDlg,iCntl) GetDlgItemInt(hDlg,iCntl,NULL,TRUE)
  79. void raster_SetDisplayFromData(HWND hDlg, const RASTERDATA *prd)
  80. {
  81. SetDlgFloatString(hDlg, R_IDC_POINT_SIZE, prd->fPointSize);
  82. CheckDlgButton( hDlg, R_IDC_POINT_SMOOTH, prd->bPointSmooth);
  83. SetDlgFloatString(hDlg, R_IDC_LINE_WIDTH, prd->fLineWidth);
  84. CheckDlgButton( hDlg, R_IDC_LINE_SMOOTH, prd->bLineSmooth);
  85. SetDlgHexString( hDlg, R_IDC_LINE_STIPPLE_PATTERN,prd->usLineStipple);
  86. SetDlgIntString( hDlg, R_IDC_LINE_STIPPLE_REPEAT, prd->iLineStippleRepeat);
  87. CheckDlgButton( hDlg, R_IDC_LINE_SMOOTH, prd->bLineStippleEnable);
  88. CheckDlgButton( hDlg, R_IDC_CULL_FACE_ENABLE, prd->bPolyCullFaceEnable);
  89. CheckDlgButton( hDlg, R_IDC_POLY_SMOOTH, prd->bPolySmooth);
  90. CheckDlgButton( hDlg, R_IDC_POLY_STIPPLE_ENABLE, prd->bPolyStippleEnable);
  91. SetDlgHexString( hDlg, R_IDC_POLY_STIPPLE_PATTERN,prd->uiPolyStipple);
  92. CB_DlgSetSelect( hDlg, R_IDC_CULL_FACE_MODE, prd->iPolyCullMode);
  93. CB_DlgSetSelect( hDlg, R_IDC_FRONT_FACE, prd->iPolyDir==GL_CCW?1:0);
  94. CB_DlgSetSelect( hDlg, R_IDC_POLY_FRONT_MODE, prd->iPolyFrontMode);
  95. CB_DlgSetSelect( hDlg, R_IDC_POLY_BACK_MODE, prd->iPolyBackMode);
  96. CB_DlgSetSelect( hDlg, R_IDC_POINT_QUALITY, prd->iPointQuality);
  97. CB_DlgSetSelect( hDlg, R_IDC_LINE_QUALITY, prd->iLineQuality);
  98. CB_DlgSetSelect( hDlg, R_IDC_POLY_QUALITY, prd->iPolyQuality);
  99. }
  100. void raster_GetDataFromDisplay(HWND hDlg, RASTERDATA *prd)
  101. {
  102. prd->fPointSize =GetDlgFloatString( hDlg,R_IDC_POINT_SIZE);
  103. prd->bPointSmooth =IsDlgButtonChecked(hDlg,R_IDC_POINT_SMOOTH);
  104. prd->fLineWidth =GetDlgFloatString( hDlg,R_IDC_LINE_WIDTH);
  105. prd->bLineSmooth =IsDlgButtonChecked(hDlg,R_IDC_LINE_SMOOTH);
  106. prd->usLineStipple =GetDlgHexString( hDlg, R_IDC_LINE_STIPPLE_PATTERN);
  107. prd->iLineStippleRepeat =GetDlgIntString( hDlg, R_IDC_LINE_STIPPLE_REPEAT);
  108. prd->bLineStippleEnable =IsDlgButtonChecked(hDlg,R_IDC_LINE_SMOOTH);
  109. prd->bPolyCullFaceEnable=IsDlgButtonChecked(hDlg,R_IDC_CULL_FACE_ENABLE);
  110. prd->bPolySmooth =IsDlgButtonChecked(hDlg,R_IDC_POLY_SMOOTH);
  111. prd->bPolyStippleEnable =IsDlgButtonChecked(hDlg,R_IDC_POLY_STIPPLE_ENABLE);
  112. prd->uiPolyStipple =GetDlgHexString( hDlg, R_IDC_POLY_STIPPLE_PATTERN);
  113. prd->iPolyCullMode =CB_DlgGetSelect(hDlg, R_IDC_CULL_FACE_MODE);
  114. prd->iPolyDir = CB_DlgGetSelect(hDlg, R_IDC_FRONT_FACE) ? GL_CCW : GL_CW;
  115. prd->iPolyFrontMode =CB_DlgGetSelect(hDlg, R_IDC_POLY_FRONT_MODE);
  116. prd->iPolyBackMode =CB_DlgGetSelect(hDlg, R_IDC_POLY_BACK_MODE);
  117. prd->iPointQuality =CB_DlgGetSelect(hDlg, R_IDC_POINT_QUALITY);
  118. prd->iLineQuality =CB_DlgGetSelect(hDlg, R_IDC_LINE_QUALITY);
  119. prd->iPolyQuality =CB_DlgGetSelect(hDlg, R_IDC_POLY_QUALITY);
  120. }
  121. BOOL CALLBACK hugeRasterDlgProc(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
  122. {
  123. static RASTERDATA *prd = NULL;
  124. switch (msg)
  125. {
  126. case WM_INITDIALOG:
  127. prd = (RASTERDATA*) (((PROPSHEETPAGE*)lParam)->lParam);
  128. CB_DlgAddString(hDlg, R_IDC_CULL_FACE_MODE, "front-facing polygons");
  129. CB_DlgAddString(hDlg, R_IDC_CULL_FACE_MODE, "back-facing polygons");
  130. CB_DlgAddString(hDlg, R_IDC_CULL_FACE_MODE, "cull all polygons");
  131. CB_DlgAddString(hDlg, R_IDC_POLY_FRONT_MODE,"Point");
  132. CB_DlgAddString(hDlg, R_IDC_POLY_FRONT_MODE,"Line");
  133. CB_DlgAddString(hDlg, R_IDC_POLY_FRONT_MODE,"Fill");
  134. CB_DlgAddString(hDlg, R_IDC_POLY_BACK_MODE, "Point");
  135. CB_DlgAddString(hDlg, R_IDC_POLY_BACK_MODE, "Line");
  136. CB_DlgAddString(hDlg, R_IDC_POLY_BACK_MODE, "Fill");
  137. CB_DlgAddString(hDlg, R_IDC_FRONT_FACE, "CW polygons");
  138. CB_DlgAddString(hDlg, R_IDC_FRONT_FACE, "CCW polygons");
  139. CB_DlgAddString(hDlg, R_IDC_POINT_QUALITY, "Fastest");
  140. CB_DlgAddString(hDlg, R_IDC_POINT_QUALITY, "Don't Care");
  141. CB_DlgAddString(hDlg, R_IDC_POINT_QUALITY, "Nicest");
  142. CB_DlgAddString(hDlg, R_IDC_LINE_QUALITY, "Fastest");
  143. CB_DlgAddString(hDlg, R_IDC_LINE_QUALITY, "Don't Care");
  144. CB_DlgAddString(hDlg, R_IDC_LINE_QUALITY, "Nicest");
  145. CB_DlgAddString(hDlg, R_IDC_POLY_QUALITY, "Fastest");
  146. CB_DlgAddString(hDlg, R_IDC_POLY_QUALITY, "Don't Care");
  147. CB_DlgAddString(hDlg, R_IDC_POLY_QUALITY, "Nicest");
  148. raster_SetDisplayFromData(hDlg,prd);
  149. return TRUE;
  150. case WM_COMMAND:
  151. {
  152. int iControl, iNote;
  153. iControl = LOWORD(wParam);
  154. iNote = HIWORD(wParam); // notification code for edit boxes
  155. switch (iControl)
  156. {
  157. case R_IDC_POINT_SIZE:
  158. case R_IDC_LINE_WIDTH:
  159. if (EN_KILLFOCUS == iNote) {
  160. PropSheet_Changed(GetParent(hDlg),hDlg);
  161. VerifyEditboxFloat(hDlg,iControl);
  162. }
  163. break;
  164. case R_IDC_LINE_STIPPLE_PATTERN:
  165. case R_IDC_POLY_STIPPLE_PATTERN:
  166. if (EN_KILLFOCUS == iNote) {
  167. PropSheet_Changed(GetParent(hDlg),hDlg);
  168. VerifyEditboxHex(hDlg,iControl);
  169. }
  170. break;
  171. default:
  172. PropSheet_Changed(GetParent(hDlg),hDlg);
  173. break;
  174. }
  175. }
  176. break;
  177. case WM_NOTIFY:
  178. {
  179. LPNMHDR pnmh = (LPNMHDR) lParam;
  180. switch (pnmh->code)
  181. {
  182. case PSN_APPLY: // user clicked on OK or Apply
  183. raster_GetDataFromDisplay(hDlg, prd);
  184. break;
  185. case PSN_RESET: // user clicked on Cancel
  186. break;
  187. case PSN_HELP: // user clicked help
  188. break;
  189. }
  190. }
  191. break;
  192. default:
  193. return FALSE;
  194. }
  195. return TRUE;
  196. }
  197. #else
  198. #endif // NO_UI_IN_CNFG