dlgconfigperformancetab.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/dlgconfigperformancetab.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/08/02 3:03p $*
  29. * *
  30. * $Revision:: 11 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgconfigperformancetab.h"
  36. #include "resource.h"
  37. #include "registry.h"
  38. #include "comboboxctrl.h"
  39. #include "sliderctrl.h"
  40. #include "rendobj.h"
  41. #include "phys.h"
  42. #include "ww3d.h"
  43. #include "pscene.h"
  44. #include "combat.h"
  45. #include "dx8wrapper.h"
  46. #include "dx8caps.h"
  47. #include "surfaceeffects.h"
  48. #include "_globals.h"
  49. #include "translatedb.h"
  50. #include "string_ids.h"
  51. /////////////////////////////////////////////////////////////////////////////
  52. // Structures and typedefs
  53. /////////////////////////////////////////////////////////////////////////////
  54. typedef struct _PERFORMANCE_SETTING
  55. {
  56. int ctrl_id;
  57. int value;
  58. } PERFORMANCE_SETTING;
  59. /////////////////////////////////////////////////////////////////////////////
  60. // Constants
  61. /////////////////////////////////////////////////////////////////////////////
  62. const int MAX_PERFORMANCE_LEVELS = 4;
  63. const int MAX_EXPERT_OPTIONS = 7;
  64. PERFORMANCE_SETTING _PerformanceLevels[MAX_PERFORMANCE_LEVELS][MAX_EXPERT_OPTIONS] =
  65. {
  66. //
  67. // Low detail
  68. //
  69. {
  70. {IDC_CHAR_SHADOWS_SLIDER, 0},
  71. {IDC_TEXTURE_DETAIL_SLIDER, 0},
  72. {IDC_PARTICLE_DETAIL_SLIDER, 0},
  73. {IDC_SURFACE_DETAIL_SLIDER, 0},
  74. {IDC_GEOMETRY_DETAIL_SLIDER, 0},
  75. {IDC_TERRAIN_SHADOW_CHECK, 0},
  76. {IDC_NPATCH_CHECK, 0}
  77. },
  78. {
  79. {IDC_CHAR_SHADOWS_SLIDER, 1},
  80. {IDC_TEXTURE_DETAIL_SLIDER, 1},
  81. {IDC_PARTICLE_DETAIL_SLIDER, 0},
  82. {IDC_SURFACE_DETAIL_SLIDER, 0},
  83. {IDC_GEOMETRY_DETAIL_SLIDER, 0},
  84. {IDC_TERRAIN_SHADOW_CHECK, 0},
  85. {IDC_NPATCH_CHECK, 0}
  86. },
  87. {
  88. {IDC_CHAR_SHADOWS_SLIDER, 2},
  89. {IDC_TEXTURE_DETAIL_SLIDER, 2},
  90. {IDC_PARTICLE_DETAIL_SLIDER, 1},
  91. {IDC_SURFACE_DETAIL_SLIDER, 1},
  92. {IDC_GEOMETRY_DETAIL_SLIDER, 1},
  93. {IDC_TERRAIN_SHADOW_CHECK, 1},
  94. {IDC_NPATCH_CHECK, 0}
  95. },
  96. //
  97. // High detail
  98. //
  99. {
  100. {IDC_CHAR_SHADOWS_SLIDER, 3},
  101. {IDC_TEXTURE_DETAIL_SLIDER, 2},
  102. {IDC_PARTICLE_DETAIL_SLIDER, 2},
  103. {IDC_SURFACE_DETAIL_SLIDER, 2},
  104. {IDC_GEOMETRY_DETAIL_SLIDER, 2},
  105. {IDC_TERRAIN_SHADOW_CHECK, 1},
  106. {IDC_NPATCH_CHECK, 0}
  107. },
  108. };
  109. const char *VALUE_NAME_DYN_LOD = "Dynamic_LOD_Budget";
  110. const char *VALUE_NAME_STATIC_LOD = "Static_LOD_Budget";
  111. const char *VALUE_NAME_DYN_SHADOWS = "Dynamic_Projectors";
  112. const char *VALUE_NAME_SHADOW_MODE = "Shadow_Mode";
  113. const char *VALUE_NAME_STATIC_SHADOWS = "Static_Projectors";
  114. const char *VALUE_NAME_TEXTURE_RES = "Texture_Resolution";
  115. const char *VALUE_NAME_PARTICLE_DETAIL = "Particle_Detail";
  116. const char *VALUE_NAME_NPATCHES = "NPatches";
  117. const int MAX_LOD_HIGH = 10000;
  118. const int MAX_LOD_MED = 5000;
  119. const int MAX_LOD_LOW = 0;
  120. ////////////////////////////////////////////////////////////////
  121. //
  122. // DlgConfigPerformanceTabClass
  123. //
  124. ////////////////////////////////////////////////////////////////
  125. DlgConfigPerformanceTabClass::DlgConfigPerformanceTabClass (void) :
  126. ChildDialogClass (IDD_CONFIG_PERFORMANCE)
  127. {
  128. return ;
  129. }
  130. ////////////////////////////////////////////////////////////////
  131. //
  132. // ~DlgConfigPerformanceTabClass
  133. //
  134. ////////////////////////////////////////////////////////////////
  135. DlgConfigPerformanceTabClass::~DlgConfigPerformanceTabClass (void)
  136. {
  137. return ;
  138. }
  139. ////////////////////////////////////////////////////////////////
  140. //
  141. // On_Init_Dialog
  142. //
  143. ////////////////////////////////////////////////////////////////
  144. void
  145. DlgConfigPerformanceTabClass::On_Init_Dialog (void)
  146. {
  147. //
  148. // Configure the dialog controls
  149. //
  150. Setup_Controls ();
  151. Load_Values ();
  152. Determine_Performance_Setting ();
  153. //
  154. // Set the visibility of the expert windows controls
  155. //
  156. Build_Expert_Window_List ();
  157. Display_Expert_Settings (false);
  158. ChildDialogClass::On_Init_Dialog ();
  159. return ;
  160. }
  161. /////////////////////////////////////////////////////////////////////////////
  162. //
  163. // Build_Expert_Window_List
  164. //
  165. /////////////////////////////////////////////////////////////////////////////
  166. void
  167. DlgConfigPerformanceTabClass::Build_Expert_Window_List (void)
  168. {
  169. ExpertWindowList.Delete_All ();
  170. //
  171. // Find the y-position of the expert mode checkbox
  172. //
  173. RectClass rect = Get_Dlg_Item (IDC_EXPERT_CHECK)->Get_Window_Rect ();
  174. float y_pos = rect.Top;
  175. //
  176. // Loop over all the controls of the dialog
  177. //
  178. for ( int index = 0; index < Get_Control_Count (); index ++) {
  179. DialogControlClass *control = Get_Control (index);
  180. //
  181. // If this control is below the expert checkbox then its
  182. // part of the expert settings
  183. //
  184. rect = control->Get_Window_Rect ();
  185. if (rect.Top > y_pos) {
  186. ExpertWindowList.Add (control);
  187. }
  188. }
  189. return ;
  190. }
  191. /////////////////////////////////////////////////////////////////////////////
  192. //
  193. // Display_Expert_Settings
  194. //
  195. /////////////////////////////////////////////////////////////////////////////
  196. void
  197. DlgConfigPerformanceTabClass::Display_Expert_Settings (bool onoff)
  198. {
  199. //
  200. // Loop over all the expert settings controls and either
  201. // show or hide them...
  202. //
  203. for (int index = 0; index < ExpertWindowList.Count (); index ++) {
  204. ExpertWindowList[index]->Show (onoff);
  205. }
  206. return ;
  207. }
  208. /////////////////////////////////////////////////////////////////////////////
  209. //
  210. // Setup_Controls
  211. //
  212. /////////////////////////////////////////////////////////////////////////////
  213. void
  214. DlgConfigPerformanceTabClass::Setup_Controls (void)
  215. {
  216. //
  217. // Configure the main performance slider
  218. //
  219. SliderCtrlClass *performance_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_PERFORMANCE_SLIDER);
  220. performance_slider->Set_Range (0, MAX_PERFORMANCE_LEVELS - 1);
  221. //
  222. // Configure the individual detail-setting sliders
  223. //
  224. ((SliderCtrlClass *)Get_Dlg_Item (IDC_GEOMETRY_DETAIL_SLIDER))->Set_Range (0, 2);
  225. ((SliderCtrlClass *)Get_Dlg_Item (IDC_CHAR_SHADOWS_SLIDER))->Set_Range (0, 3);
  226. ((SliderCtrlClass *)Get_Dlg_Item (IDC_TEXTURE_DETAIL_SLIDER))->Set_Range (0, 2);
  227. ((SliderCtrlClass *)Get_Dlg_Item (IDC_SURFACE_DETAIL_SLIDER))->Set_Range (0, 2);
  228. ((SliderCtrlClass *)Get_Dlg_Item (IDC_PARTICLE_DETAIL_SLIDER))->Set_Range (0, 2);
  229. const WCHAR *PRELIT_MODE_NAMES[] =
  230. {
  231. TRANSLATE (IDS_MENU_VERTEX),
  232. TRANSLATE (IDS_MENU_MP_LIGHTMAPS),
  233. TRANSLATE (IDS_MENU_MT_LIGHTMAPS)
  234. };
  235. Set_Dlg_Item_Text (IDC_LIGHTING_MODE, PRELIT_MODE_NAMES [WW3D::Get_Prelit_Mode()]);
  236. Enable_Dlg_Item (IDC_LIGHTING_MODE, false);
  237. const WCHAR *TEXTURE_FILTER_NAMES[] =
  238. {
  239. TRANSLATE (IDS_BILINEAR),
  240. TRANSLATE (IDS_TRILINEAR),
  241. TRANSLATE (IDS_ANISOTROPIC)
  242. };
  243. Set_Dlg_Item_Text (IDC_TEXTURE_FILTER, TEXTURE_FILTER_NAMES [WW3D::Get_Texture_Filter()]);
  244. Enable_Dlg_Item (IDC_TEXTURE_FILTER, false);
  245. //
  246. // Disable the checkbox if NPatches aren't supported
  247. //
  248. if (DX8Wrapper::Get_Current_Caps() && DX8Wrapper::Get_Current_Caps()->Support_NPatches () == false) {
  249. Check_Dlg_Button (IDC_NPATCH_CHECK, false);
  250. Enable_Dlg_Item (IDC_NPATCH_CHECK, false);
  251. }
  252. return ;
  253. }
  254. /////////////////////////////////////////////////////////////////////////////
  255. //
  256. // Load_Values
  257. //
  258. /////////////////////////////////////////////////////////////////////////////
  259. void
  260. DlgConfigPerformanceTabClass::Load_Values (void)
  261. {
  262. SliderCtrlClass *geometry_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_GEOMETRY_DETAIL_SLIDER);
  263. SliderCtrlClass *char_shadows_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_CHAR_SHADOWS_SLIDER);
  264. SliderCtrlClass *texture_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_TEXTURE_DETAIL_SLIDER);
  265. SliderCtrlClass *surface_effect_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_SURFACE_DETAIL_SLIDER);
  266. SliderCtrlClass *particle_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_PARTICLE_DETAIL_SLIDER);
  267. //
  268. // Attempt to open the registry key
  269. //
  270. RegistryClass registry (APPLICATION_SUB_KEY_NAME_SYSTEM_SETTINGS);
  271. if (registry.Is_Valid ()) {
  272. //
  273. // Read the values from the registry
  274. //
  275. int static_shadows = registry.Get_Int (VALUE_NAME_STATIC_SHADOWS, 1);
  276. int shadow_mode = registry.Get_Int (VALUE_NAME_SHADOW_MODE, PhysicsSceneClass::SHADOW_MODE_BLOBS_PLUS);
  277. int texture_red = registry.Get_Int (VALUE_NAME_TEXTURE_RES, 0);
  278. int particle_detail = registry.Get_Int (VALUE_NAME_PARTICLE_DETAIL, 1);
  279. int npatches = registry.Get_Int (VALUE_NAME_NPATCHES, 0);
  280. //
  281. // Get the surface effect mode
  282. //
  283. int surface_effect = SurfaceEffectsManager::Get_Mode ();
  284. //
  285. // Get the LOD settings
  286. //
  287. int dynamic_lod = 0;
  288. int static_lod = 0;
  289. PhysicsSceneClass::Get_Instance()->Get_Polygon_Budgets (&static_lod, &dynamic_lod);
  290. //
  291. // Set the slider's positions to reflect the loaded values
  292. //
  293. char_shadows_slider->Set_Pos (min (shadow_mode, 3));
  294. texture_slider->Set_Pos (max (2 - texture_red, 0));
  295. surface_effect_slider->Set_Pos (surface_effect);
  296. particle_slider->Set_Pos (particle_detail);
  297. //
  298. // Choose a setting for the geometry slider based on
  299. // the dynamic and static LOD budgets
  300. //
  301. if (dynamic_lod < (MAX_LOD_LOW + 1000)) {
  302. geometry_slider->Set_Pos (0);
  303. } else if (dynamic_lod <= MAX_LOD_MED) {
  304. geometry_slider->Set_Pos (1);
  305. } else {
  306. geometry_slider->Set_Pos (2);
  307. }
  308. //
  309. // Check the checkbox controls (if necessary)
  310. //
  311. Check_Dlg_Button (IDC_TERRAIN_SHADOW_CHECK, bool(static_shadows != 0));
  312. Check_Dlg_Button (IDC_NPATCH_CHECK, bool(npatches != 0));
  313. }
  314. return ;
  315. }
  316. /////////////////////////////////////////////////////////////////////////////
  317. //
  318. // Determine_Performance_Setting
  319. //
  320. /////////////////////////////////////////////////////////////////////////////
  321. void
  322. DlgConfigPerformanceTabClass::Determine_Performance_Setting (void)
  323. {
  324. float option_levels[MAX_EXPERT_OPTIONS] = { 0 };
  325. int count_per_option[MAX_EXPERT_OPTIONS] = { 0 };
  326. //
  327. // Get the current values of each setting
  328. //
  329. DynamicVectorClass<int> option_values;
  330. Get_Settings (option_values);
  331. //
  332. // Find out which level each option is currently set at
  333. //
  334. for (int level = MAX_PERFORMANCE_LEVELS - 1; level >= 0; level --) {
  335. for (int index = 0; index < MAX_EXPERT_OPTIONS; index ++) {
  336. //
  337. // If the values match, then record the current level for this option
  338. //
  339. if (option_values[index] == _PerformanceLevels[level][index].value) {
  340. option_levels[index] += level;
  341. count_per_option[index] ++;
  342. }
  343. }
  344. }
  345. //
  346. // Add up all the levels
  347. //
  348. float level_sum = 0;
  349. for (int index = 0; index < MAX_EXPERT_OPTIONS; index ++) {
  350. level_sum += (option_levels[index] / count_per_option[index]);
  351. }
  352. //
  353. // Take the average rating
  354. //
  355. float level_rating = level_sum / MAX_EXPERT_OPTIONS;
  356. //
  357. // Set the slider's position
  358. //
  359. SliderCtrlClass *slider_ctrl = (SliderCtrlClass *)Get_Dlg_Item (IDC_PERFORMANCE_SLIDER);
  360. slider_ctrl->Set_Pos (min (int(level_rating + 0.4F), MAX_EXPERT_OPTIONS - 1), false);
  361. return ;
  362. }
  363. //////////////////////////////////////////////////////////////////////
  364. //
  365. // On_Command
  366. //
  367. //////////////////////////////////////////////////////////////////////
  368. void
  369. DlgConfigPerformanceTabClass::On_Command (int ctrl_id, int message_id, DWORD param)
  370. {
  371. switch (ctrl_id)
  372. {
  373. case IDC_EXPERT_CHECK:
  374. {
  375. bool enabled = Is_Dlg_Button_Checked (IDC_EXPERT_CHECK);
  376. Display_Expert_Settings (enabled);
  377. break;
  378. }
  379. }
  380. ChildDialogClass::On_Command (ctrl_id, message_id, param);
  381. return ;
  382. }
  383. /////////////////////////////////////////////////////////////////////////////
  384. //
  385. // Get_Settings
  386. //
  387. /////////////////////////////////////////////////////////////////////////////
  388. void
  389. DlgConfigPerformanceTabClass::Get_Settings (DynamicVectorClass<int> &settings)
  390. {
  391. //
  392. // Determine what the value of each control is
  393. //
  394. for (int index = 0; index < MAX_EXPERT_OPTIONS; index ++) {
  395. //
  396. // Determine what the value of this control is
  397. //
  398. int curr_value = 0;
  399. int ctrl_id = _PerformanceLevels[0][index].ctrl_id;
  400. switch (ctrl_id) {
  401. //
  402. // Read any of the slider positions
  403. //
  404. case IDC_GEOMETRY_DETAIL_SLIDER:
  405. case IDC_CHAR_SHADOWS_SLIDER:
  406. case IDC_TEXTURE_DETAIL_SLIDER:
  407. case IDC_PARTICLE_DETAIL_SLIDER:
  408. case IDC_SURFACE_DETAIL_SLIDER:
  409. {
  410. SliderCtrlClass *slider_ctrl = (SliderCtrlClass *)Get_Dlg_Item (ctrl_id);
  411. curr_value = slider_ctrl->Get_Pos ();
  412. break;
  413. }
  414. //
  415. // Read the values from either checkbox
  416. //
  417. case IDC_TERRAIN_SHADOW_CHECK:
  418. case IDC_NPATCH_CHECK:
  419. curr_value = Is_Dlg_Button_Checked (ctrl_id);
  420. break;
  421. }
  422. //
  423. // Add this value to the list
  424. //
  425. settings.Add (curr_value);
  426. }
  427. return ;
  428. }
  429. /////////////////////////////////////////////////////////////////////////////
  430. //
  431. // Update_Expert_Controls
  432. //
  433. /////////////////////////////////////////////////////////////////////////////
  434. void
  435. DlgConfigPerformanceTabClass::Update_Expert_Controls (int level)
  436. {
  437. for (int index = 0; index < MAX_EXPERT_OPTIONS; index ++) {
  438. //
  439. // Determine which control we are updating
  440. //
  441. int ctrl_id = _PerformanceLevels[level][index].ctrl_id;
  442. switch (ctrl_id) {
  443. //
  444. // Update any of the sliders via the same mechanism
  445. //
  446. case IDC_GEOMETRY_DETAIL_SLIDER:
  447. case IDC_CHAR_SHADOWS_SLIDER:
  448. case IDC_TEXTURE_DETAIL_SLIDER:
  449. case IDC_PARTICLE_DETAIL_SLIDER:
  450. case IDC_SURFACE_DETAIL_SLIDER:
  451. {
  452. SliderCtrlClass *slider_ctrl = (SliderCtrlClass *)Get_Dlg_Item (ctrl_id);
  453. slider_ctrl->Set_Pos (_PerformanceLevels[level][index].value);
  454. break;
  455. }
  456. //
  457. // Update any of the check boxes via the same mechanism
  458. //
  459. case IDC_TERRAIN_SHADOW_CHECK:
  460. case IDC_NPATCH_CHECK:
  461. Check_Dlg_Button (ctrl_id, bool(_PerformanceLevels[level][index].value == 1));
  462. break;
  463. }
  464. }
  465. return ;
  466. }
  467. ////////////////////////////////////////////////////////////////
  468. //
  469. // On_SliderCtrl_Pos_Changed
  470. //
  471. ////////////////////////////////////////////////////////////////
  472. void
  473. DlgConfigPerformanceTabClass::On_SliderCtrl_Pos_Changed
  474. (
  475. SliderCtrlClass * slider_ctrl,
  476. int ctrl_id,
  477. int new_pos
  478. )
  479. {
  480. if (ctrl_id == IDC_PERFORMANCE_SLIDER) {
  481. Update_Expert_Controls (new_pos);
  482. }
  483. return ;
  484. }
  485. /////////////////////////////////////////////////////////////////////////////
  486. //
  487. // On_Apply
  488. //
  489. /////////////////////////////////////////////////////////////////////////////
  490. bool
  491. DlgConfigPerformanceTabClass::On_Apply (void)
  492. {
  493. SliderCtrlClass *geometry_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_GEOMETRY_DETAIL_SLIDER);
  494. SliderCtrlClass *char_shadows_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_CHAR_SHADOWS_SLIDER);
  495. SliderCtrlClass *texture_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_TEXTURE_DETAIL_SLIDER);
  496. SliderCtrlClass *surface_effect_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_SURFACE_DETAIL_SLIDER);
  497. SliderCtrlClass *particle_slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_PARTICLE_DETAIL_SLIDER);
  498. //
  499. // Attempt to open the registry key
  500. //
  501. RegistryClass registry (APPLICATION_SUB_KEY_NAME_SYSTEM_SETTINGS);
  502. if (registry.Is_Valid ()) {
  503. //
  504. // Get the current settings from the dialog
  505. //
  506. int geometry_detail = geometry_slider->Get_Pos ();
  507. int shadow_mode = char_shadows_slider->Get_Pos ();
  508. int texture_red = texture_slider->Get_Pos ();
  509. int surface_effect = surface_effect_slider->Get_Pos ();
  510. int particle_detail = particle_slider->Get_Pos ();
  511. int static_shadows = Is_Dlg_Button_Checked (IDC_TERRAIN_SHADOW_CHECK);
  512. int npatches = Is_Dlg_Button_Checked (IDC_NPATCH_CHECK);
  513. //
  514. // Determine a good LOD budget to use
  515. //
  516. int lod_budget = 0;
  517. if (geometry_detail == 0) {
  518. lod_budget = 0;
  519. } else if (geometry_detail == 1) {
  520. lod_budget = MAX_LOD_MED;
  521. } else if (geometry_detail == 2) {
  522. lod_budget = MAX_LOD_HIGH;
  523. }
  524. //
  525. // Store the values in the registry
  526. //
  527. registry.Set_Int (VALUE_NAME_DYN_LOD, lod_budget);
  528. registry.Set_Int (VALUE_NAME_STATIC_LOD, lod_budget);
  529. registry.Set_Int (VALUE_NAME_DYN_SHADOWS, (shadow_mode != PhysicsSceneClass::SHADOW_MODE_NONE));
  530. registry.Set_Int (VALUE_NAME_STATIC_SHADOWS, static_shadows);
  531. registry.Set_Int (VALUE_NAME_SHADOW_MODE, shadow_mode);
  532. registry.Set_Int (VALUE_NAME_TEXTURE_RES, max (2 - texture_red, 0));
  533. registry.Set_Int (VALUE_NAME_PARTICLE_DETAIL, particle_detail);
  534. if (DX8Wrapper::Get_Current_Caps() && DX8Wrapper::Get_Current_Caps()->Support_NPatches ()) {
  535. registry.Set_Int (VALUE_NAME_NPATCHES, npatches);
  536. }
  537. //
  538. // Pass the values onto the game
  539. //
  540. COMBAT_SCENE->Set_Polygon_Budgets (lod_budget, lod_budget);
  541. COMBAT_SCENE->Enable_Dynamic_Projectors ((shadow_mode != PhysicsSceneClass::SHADOW_MODE_NONE));
  542. COMBAT_SCENE->Enable_Static_Projectors ((static_shadows != 0));
  543. // Note! It is important to invalidate all textures when
  544. // changing the amount of render targets, as render target
  545. // creation may have problems if the card is running low on
  546. // texture memory!
  547. if (COMBAT_SCENE->Get_Shadow_Mode()!=(PhysicsSceneClass::ShadowEnum)shadow_mode) {
  548. WW3D::_Invalidate_Textures();
  549. COMBAT_SCENE->Set_Shadow_Mode ((PhysicsSceneClass::ShadowEnum)shadow_mode);
  550. }
  551. WW3D::Set_Texture_Reduction (max (2 - texture_red, 0));
  552. SurfaceEffectsManager::Set_Mode ((SurfaceEffectsManager::MODE)surface_effect);
  553. }
  554. return true;
  555. }