PerformanceConfigDialog.cpp 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  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. // PerformanceConfigDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "wwconfig.h"
  22. #include "performanceconfigdialog.h"
  23. #include "registry.h"
  24. #include "ww3d.h"
  25. #include "pscene.h"
  26. #include "rendobj.h"
  27. #include "phys.h"
  28. #include "videoconfigdialog.h"
  29. #include "dx8caps.h"
  30. #include "cpudetect.h"
  31. #include "formconv.h"
  32. #include "dx8wrapper.h"
  33. #include "locale_api.h"
  34. #include "wwconfig_ids.h"
  35. #include "..\..\combat\specialbuilds.h"
  36. #ifdef _DEBUG
  37. #define new DEBUG_NEW
  38. #undef THIS_FILE
  39. static char THIS_FILE[] = __FILE__;
  40. #endif
  41. static bool CanDoMultiPass=true;
  42. /////////////////////////////////////////////////////////////////////////////
  43. // Structures and typedefs
  44. /////////////////////////////////////////////////////////////////////////////
  45. typedef struct _PERFORMANCE_SETTING
  46. {
  47. int ctrl_id;
  48. int value;
  49. } PERFORMANCE_SETTING;
  50. /////////////////////////////////////////////////////////////////////////////
  51. // Constants
  52. /////////////////////////////////////////////////////////////////////////////
  53. const int MAX_PERFORMANCE_LEVELS = 4;
  54. const int MAX_EXPERT_OPTIONS = 8;
  55. PERFORMANCE_SETTING _PerformanceLevels[MAX_PERFORMANCE_LEVELS][MAX_EXPERT_OPTIONS] =
  56. {
  57. //
  58. // Low detail
  59. //
  60. {
  61. {IDC_CHAR_SHADOWS_SLIDER, 0},
  62. {IDC_TEXTURE_DETAIL_SLIDER, 0},
  63. {IDC_PARTICLE_DETAIL_SLIDER, 0},
  64. {IDC_SURFACE_DETAIL_SLIDER, 0},
  65. {IDC_GEOMETRY_DETAIL_SLIDER, 0},
  66. {IDC_TEXTURE_FILTER_COMBO, TextureClass::TEXTURE_FILTER_BILINEAR},
  67. {IDC_LIGHTING_MODE_COMBO, WW3D::PRELIT_MODE_VERTEX},
  68. {IDC_TERRAIN_SHADOW_CHECK, 0}
  69. },
  70. {
  71. {IDC_CHAR_SHADOWS_SLIDER, 1},
  72. {IDC_TEXTURE_DETAIL_SLIDER, 1},
  73. {IDC_PARTICLE_DETAIL_SLIDER, 0},
  74. {IDC_SURFACE_DETAIL_SLIDER, 0},
  75. {IDC_GEOMETRY_DETAIL_SLIDER, 0},
  76. {IDC_TEXTURE_FILTER_COMBO, TextureClass::TEXTURE_FILTER_BILINEAR},
  77. {IDC_LIGHTING_MODE_COMBO, WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE},
  78. {IDC_TERRAIN_SHADOW_CHECK, 0}
  79. },
  80. {
  81. {IDC_CHAR_SHADOWS_SLIDER, 2},
  82. {IDC_TEXTURE_DETAIL_SLIDER, 2},
  83. {IDC_PARTICLE_DETAIL_SLIDER, 1},
  84. {IDC_SURFACE_DETAIL_SLIDER, 1},
  85. {IDC_GEOMETRY_DETAIL_SLIDER, 1},
  86. {IDC_TEXTURE_FILTER_COMBO, TextureClass::TEXTURE_FILTER_TRILINEAR},
  87. {IDC_LIGHTING_MODE_COMBO, WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE},
  88. {IDC_TERRAIN_SHADOW_CHECK, 1}
  89. },
  90. //
  91. // High detail
  92. //
  93. {
  94. {IDC_CHAR_SHADOWS_SLIDER, 3},
  95. {IDC_TEXTURE_DETAIL_SLIDER, 2},
  96. {IDC_PARTICLE_DETAIL_SLIDER, 2},
  97. {IDC_SURFACE_DETAIL_SLIDER, 2},
  98. {IDC_GEOMETRY_DETAIL_SLIDER, 2},
  99. {IDC_TEXTURE_FILTER_COMBO, TextureClass::TEXTURE_FILTER_TRILINEAR},
  100. {IDC_LIGHTING_MODE_COMBO, WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE},
  101. {IDC_TERRAIN_SHADOW_CHECK, 1}
  102. },
  103. };
  104. /////////////////////////////////////////////////////////////////////////////
  105. // Registry Values
  106. /////////////////////////////////////////////////////////////////////////////
  107. /*
  108. #ifdef MULTIPLAYERDEMO
  109. const char *KEY_NAME_SETTINGS = "Software\\Westwood\\RenegadeMPDemo\\System Settings";
  110. const char *KEY_NAME_OPTIONS = "Software\\Westwood\\RenegadeMPDemo\\Options";
  111. #else
  112. const char *KEY_NAME_SETTINGS = "Software\\Westwood\\Renegade\\System Settings";
  113. const char *KEY_NAME_OPTIONS = "Software\\Westwood\\Renegade\\Options";
  114. #endif // MULTIPLAYERDEMO
  115. */
  116. #if defined(FREEDEDICATEDSERVER)
  117. const char *KEY_NAME_SETTINGS = "Software\\Westwood\\RenegadeFDS\\System Settings";
  118. const char *KEY_NAME_OPTIONS = "Software\\Westwood\\RenegadeFDS\\Options";
  119. #elif defined(MULTIPLAYERDEMO)
  120. const char *KEY_NAME_SETTINGS = "Software\\Westwood\\RenegadeMPDemo\\System Settings";
  121. const char *KEY_NAME_OPTIONS = "Software\\Westwood\\RenegadeMPDemo\\Options";
  122. #elif defined(BETACLIENT)
  123. const char *KEY_NAME_SETTINGS = "Software\\Westwood\\RenegadeBeta\\System Settings";
  124. const char *KEY_NAME_OPTIONS = "Software\\Westwood\\RenegadeBeta\\Options";
  125. #else
  126. const char *KEY_NAME_SETTINGS = "Software\\Westwood\\Renegade\\System Settings";
  127. const char *KEY_NAME_OPTIONS = "Software\\Westwood\\Renegade\\Options";
  128. #endif
  129. const char *VALUE_NAME_DYN_LOD = "Dynamic_LOD_Budget";
  130. const char *VALUE_NAME_STATIC_LOD = "Static_LOD_Budget";
  131. const char *VALUE_NAME_DYN_SHADOWS = "Dynamic_Projectors";
  132. const char *VALUE_NAME_TEXTURE_FILTER = "Texture_Filter_Mode";
  133. const char *VALUE_NAME_PRELIT_MODE = "Prelit_Mode";
  134. const char *VALUE_NAME_SHADOW_MODE = "Shadow_Mode";
  135. const char *VALUE_NAME_STATIC_SHADOWS = "Static_Projectors";
  136. const char *VALUE_NAME_TEXTURE_RES = "Texture_Resolution";
  137. const char *VALUE_NAME_SURFACE_EFFECT = "Surface_Effect_Detail";
  138. const char *VALUE_NAME_PARTICLE_DETAIL = "Particle_Detail";
  139. /////////////////////////////////////////////////////////////////////////////
  140. //
  141. // PerformanceConfigDialogClass
  142. //
  143. /////////////////////////////////////////////////////////////////////////////
  144. PerformanceConfigDialogClass::PerformanceConfigDialogClass(CWnd* pParent /*=NULL*/)
  145. : CDialog (PerformanceConfigDialogClass::IDD, pParent)
  146. {
  147. //{{AFX_DATA_INIT(PerformanceConfigDialogClass)
  148. // NOTE: the ClassWizard will add member initialization here
  149. //}}AFX_DATA_INIT
  150. CDialog::Create (PerformanceConfigDialogClass::IDD, pParent);
  151. return ;
  152. }
  153. /////////////////////////////////////////////////////////////////////////////
  154. //
  155. // DoDataExchange
  156. //
  157. /////////////////////////////////////////////////////////////////////////////
  158. void
  159. PerformanceConfigDialogClass::DoDataExchange (CDataExchange *pDX)
  160. {
  161. CDialog::DoDataExchange(pDX);
  162. //{{AFX_DATA_MAP(PerformanceConfigDialogClass)
  163. DDX_Control(pDX, IDC_GEOMETRY_DETAIL_SLIDER, m_GeometrySlider);
  164. DDX_Control(pDX, IDC_CHAR_SHADOWS_SLIDER, m_CharShadowsSlider);
  165. DDX_Control(pDX, IDC_TEXTURE_DETAIL_SLIDER, m_TextureDetailSlider);
  166. DDX_Control(pDX, IDC_SURFACE_DETAIL_SLIDER, m_SurfaceEffectsSlider);
  167. DDX_Control(pDX, IDC_PERFORMANCE_SLIDER, m_PerformanceSlider);
  168. DDX_Control(pDX, IDC_PARTICLE_DETAIL_SLIDER, m_ParticleSlider);
  169. //}}AFX_DATA_MAP
  170. return ;
  171. }
  172. BEGIN_MESSAGE_MAP(PerformanceConfigDialogClass, CDialog)
  173. //{{AFX_MSG_MAP(PerformanceConfigDialogClass)
  174. ON_BN_CLICKED(IDC_EXPERT_CHECK, OnExpertCheck)
  175. ON_WM_HSCROLL()
  176. ON_BN_CLICKED(IDC_AUTO_CONFIG_BUTTON, OnGraphicsAutoSetup)
  177. ON_WM_SHOWWINDOW()
  178. //}}AFX_MSG_MAP
  179. END_MESSAGE_MAP()
  180. /////////////////////////////////////////////////////////////////////////////
  181. //
  182. // OnInitDialog
  183. //
  184. // Modified: 12/06/2001 by MML - Retrieving strings from Locomoto file.
  185. //
  186. /////////////////////////////////////////////////////////////////////////////
  187. BOOL
  188. PerformanceConfigDialogClass::OnInitDialog (void)
  189. {
  190. char string [_MAX_PATH];
  191. CDialog::OnInitDialog ();
  192. //
  193. // Set all the static strings for this dialog.
  194. //
  195. SetDlgItemText( IDC_DETAIL, Locale_GetString( IDS_DETAIL, string ));
  196. SetDlgItemText( IDC_LOW_DESC, Locale_GetString( IDS_LOW_DESC, string ));
  197. SetDlgItemText( IDC_HIGH_DESC, Locale_GetString( IDS_HIGH_DESC, string ));
  198. SetDlgItemText( IDC_EXPERT_CHECK, Locale_GetString( IDS_EXPERT_MODE, string ));
  199. SetDlgItemText( IDC_EXPERT_SETTINGS, Locale_GetString( IDS_EXPERT_SETTINGS, string ));
  200. SetDlgItemText( IDC_AUTO_CONFIG_BUTTON, Locale_GetString( IDS_AUTOCONFIG, string ));
  201. SetDlgItemText( IDC_GEOMETRY_DETAIL, Locale_GetString( IDS_GEOMETRY_DETAIL, string ));
  202. SetDlgItemText( IDC_CHARACTER_SHADOWS, Locale_GetString( IDS_CHARACTER_SHADOWS, string ));
  203. SetDlgItemText( IDC_TEXTURE_DETAIL, Locale_GetString( IDS_TEXTURE_DETAIL, string ));
  204. SetDlgItemText( IDC_PARTICLE_DETAIL, Locale_GetString( IDS_PARTICLE_DETAIL, string ));
  205. SetDlgItemText( IDC_SURFACE_EFFECT_DETAIL, Locale_GetString( IDS_SURFACE_EFFECT_DETAIL, string ));
  206. Locale_GetString( IDS_LOW, string );
  207. SetDlgItemText( IDC_LOW1, string );
  208. SetDlgItemText( IDC_LOW2, string );
  209. SetDlgItemText( IDC_LOW3, string );
  210. SetDlgItemText( IDC_LOW4, string );
  211. SetDlgItemText( IDC_LOW5, string );
  212. Locale_GetString( IDS_HIGH, string );
  213. SetDlgItemText( IDC_HIGH1, string );
  214. SetDlgItemText( IDC_HIGH2, string );
  215. SetDlgItemText( IDC_HIGH3, string );
  216. SetDlgItemText( IDC_HIGH4, string );
  217. SetDlgItemText( IDC_HIGH5, string );
  218. SetDlgItemText( IDC_LIGHTING_MODE, Locale_GetString( IDS_LIGHTING_MODE, string ));
  219. SetDlgItemText( IDC_TEXTURE_FILTER, Locale_GetString( IDS_TEXTURE_FILTER, string ));
  220. SetDlgItemText( IDC_TERRAIN_SHADOW_CHECK, Locale_GetString( IDS_TERRAIN_SHADOWS, string ));
  221. //
  222. // Configure the dialog controls
  223. //
  224. Setup_Controls ();
  225. Load_Values ();
  226. // Determine_Performance_Setting ();
  227. //
  228. // Set the visibility of the expert windows controls
  229. //
  230. Build_Expert_Window_List ();
  231. Display_Expert_Settings (false);
  232. return TRUE;
  233. }
  234. /////////////////////////////////////////////////////////////////////////////
  235. //
  236. // Build_Expert_Window_List
  237. //
  238. /////////////////////////////////////////////////////////////////////////////
  239. void
  240. PerformanceConfigDialogClass::Build_Expert_Window_List (void)
  241. {
  242. ExpertWindowList.Delete_All ();
  243. //
  244. // Find the y-position of the expert mode checkbox
  245. //
  246. CRect rect;
  247. ::GetWindowRect (::GetDlgItem (m_hWnd, IDC_EXPERT_CHECK), &rect);
  248. float y_pos = rect.top;
  249. //
  250. // Loop over all the child windows of the dialog
  251. //
  252. for ( HWND child_wnd = ::GetWindow (m_hWnd, GW_CHILD);
  253. child_wnd != NULL;
  254. child_wnd = ::GetWindow (child_wnd, GW_HWNDNEXT))
  255. {
  256. //
  257. // If this child window is below the expert checkbox then its
  258. // part of the expert settings
  259. //
  260. ::GetWindowRect (child_wnd, &rect);
  261. if (rect.top > y_pos) {
  262. ExpertWindowList.Add (child_wnd);
  263. }
  264. }
  265. return ;
  266. }
  267. /////////////////////////////////////////////////////////////////////////////
  268. //
  269. // Display_Expert_Settings
  270. //
  271. /////////////////////////////////////////////////////////////////////////////
  272. void
  273. PerformanceConfigDialogClass::Display_Expert_Settings (bool onoff)
  274. {
  275. //
  276. // Loop over all the expert settings windows and either
  277. // show or hide them...
  278. //
  279. for (int index = 0; index < ExpertWindowList.Count (); index ++) {
  280. ::ShowWindow (ExpertWindowList[index], onoff ? SW_SHOW : SW_HIDE);
  281. }
  282. return ;
  283. }
  284. /////////////////////////////////////////////////////////////////////////////
  285. //
  286. // OnExpertCheck
  287. //
  288. /////////////////////////////////////////////////////////////////////////////
  289. void
  290. PerformanceConfigDialogClass::OnExpertCheck (void)
  291. {
  292. bool enabled = bool(SendDlgItemMessage (IDC_EXPERT_CHECK, BM_GETCHECK) == 1);
  293. Display_Expert_Settings (enabled);
  294. return ;
  295. }
  296. /////////////////////////////////////////////////////////////////////////////
  297. //
  298. // Setup_Controls
  299. //
  300. /////////////////////////////////////////////////////////////////////////////
  301. void
  302. PerformanceConfigDialogClass::Setup_Controls (void)
  303. {
  304. //
  305. // Configure the main performance slider
  306. //
  307. m_PerformanceSlider.SetRange (0, MAX_PERFORMANCE_LEVELS - 1);
  308. //
  309. // Configure the individual detail-setting sliders
  310. //
  311. m_CharShadowsSlider.SetRange (0, 3);
  312. m_GeometrySlider.SetRange (0, 2);
  313. m_TextureDetailSlider.SetRange (0, 2);
  314. m_SurfaceEffectsSlider.SetRange (0, 2);
  315. m_ParticleSlider.SetRange (0, 2);
  316. return ;
  317. }
  318. /////////////////////////////////////////////////////////////////////////////
  319. //
  320. // Load_Values
  321. //
  322. /////////////////////////////////////////////////////////////////////////////
  323. void
  324. PerformanceConfigDialogClass::Load_Values (void)
  325. {
  326. //
  327. // Attempt to open the registry key
  328. //
  329. RegistryClass registry (KEY_NAME_SETTINGS);
  330. if (registry.Is_Valid ()) {
  331. //
  332. // Read the values from the registry
  333. //
  334. int dynamic_lod = registry.Get_Int (VALUE_NAME_DYN_LOD, 3000);
  335. int static_lod = registry.Get_Int (VALUE_NAME_STATIC_LOD, 3000);
  336. int dynamic_shadows = registry.Get_Int (VALUE_NAME_DYN_SHADOWS, 1);
  337. int static_shadows = registry.Get_Int (VALUE_NAME_STATIC_SHADOWS, 1);
  338. int prelit_mode = registry.Get_Int (VALUE_NAME_PRELIT_MODE, WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE);
  339. int texture_filter = registry.Get_Int (VALUE_NAME_TEXTURE_FILTER, TextureClass::TEXTURE_FILTER_BILINEAR);
  340. int shadow_mode = registry.Get_Int (VALUE_NAME_SHADOW_MODE, PhysicsSceneClass::SHADOW_MODE_BLOBS_PLUS);
  341. int texture_red = registry.Get_Int (VALUE_NAME_TEXTURE_RES, 0);
  342. int surface_effect = registry.Get_Int (VALUE_NAME_SURFACE_EFFECT, 1);
  343. int particle_detail = registry.Get_Int (VALUE_NAME_PARTICLE_DETAIL, 1);
  344. //
  345. // Set the slider's positions to reflect the loaded values
  346. //
  347. m_CharShadowsSlider.SetPos (min (shadow_mode, 3));
  348. m_TextureDetailSlider.SetPos (max (2 - texture_red, 0));
  349. m_SurfaceEffectsSlider.SetPos (surface_effect);
  350. m_ParticleSlider.SetPos (particle_detail);
  351. //
  352. // Choose a setting for the geometry slider based on
  353. // the dynamic and static LOD budgets
  354. //
  355. if (dynamic_lod < 1000 && static_lod < 1000) {
  356. m_GeometrySlider.SetPos (0);
  357. } else if (dynamic_lod <= 5000 && static_lod <= 5000) {
  358. m_GeometrySlider.SetPos (1);
  359. } else {
  360. m_GeometrySlider.SetPos (2);
  361. }
  362. //
  363. // Check the checkbox controls (if necessary)
  364. //
  365. SendDlgItemMessage (IDC_TERRAIN_SHADOW_CHECK, BM_SETCHECK, (WPARAM)(static_shadows != 0));
  366. //
  367. // Select the correct setting from the lighting mode combo box
  368. //
  369. SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_SETCURSEL, prelit_mode);
  370. //
  371. // Select the correct setting from the texture filtering mode combo box
  372. //
  373. SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_SETCURSEL, texture_filter);
  374. }
  375. return ;
  376. }
  377. /////////////////////////////////////////////////////////////////////////////
  378. //
  379. // Determine_Performance_Setting
  380. //
  381. /////////////////////////////////////////////////////////////////////////////
  382. void
  383. PerformanceConfigDialogClass::Determine_Performance_Setting (void)
  384. {
  385. float option_levels[MAX_EXPERT_OPTIONS] = { 0 };
  386. int count_per_option[MAX_EXPERT_OPTIONS] = { 0 };
  387. //
  388. // Get the current values of each setting
  389. //
  390. DynamicVectorClass<int> option_values;
  391. Get_Settings (option_values);
  392. //
  393. // Find out which level each option is currently set at
  394. //
  395. for (int level = MAX_PERFORMANCE_LEVELS - 1; level >= 0; level --) {
  396. for (int index = 0; index < MAX_EXPERT_OPTIONS; index ++) {
  397. //
  398. // If the values match, then record the current level for this option
  399. //
  400. if (option_values[index] == _PerformanceLevels[level][index].value) {
  401. option_levels[index] += level;
  402. count_per_option[index] ++;
  403. }
  404. }
  405. }
  406. //
  407. // Add up all the levels
  408. //
  409. float level_sum = 0;
  410. for (int index = 0; index < MAX_EXPERT_OPTIONS; index ++) {
  411. level_sum += (option_levels[index] / count_per_option[index]);
  412. }
  413. //
  414. // Take the average rating
  415. //
  416. float level_rating = level_sum / MAX_EXPERT_OPTIONS;
  417. //
  418. // Set the slider's position
  419. //
  420. m_PerformanceSlider.SetPos (min (int(level_rating + 0.5F), MAX_EXPERT_OPTIONS - 1));
  421. return ;
  422. }
  423. /////////////////////////////////////////////////////////////////////////////
  424. //
  425. // Get_Settings
  426. //
  427. /////////////////////////////////////////////////////////////////////////////
  428. void
  429. PerformanceConfigDialogClass::Get_Settings (DynamicVectorClass<int> &settings)
  430. {
  431. //
  432. // Determine what the value of each control is
  433. //
  434. for (int index = 0; index < MAX_EXPERT_OPTIONS; index ++) {
  435. //
  436. // Determine what the value of this control is
  437. //
  438. int curr_value = 0;
  439. int ctrl_id = _PerformanceLevels[0][index].ctrl_id;
  440. switch (ctrl_id) {
  441. //
  442. // Read any of the slider positions
  443. //
  444. case IDC_GEOMETRY_DETAIL_SLIDER:
  445. case IDC_CHAR_SHADOWS_SLIDER:
  446. case IDC_TEXTURE_DETAIL_SLIDER:
  447. case IDC_PARTICLE_DETAIL_SLIDER:
  448. case IDC_SURFACE_DETAIL_SLIDER:
  449. curr_value = SendDlgItemMessage (ctrl_id, TBM_GETPOS);
  450. break;
  451. //
  452. // Read the values from the checkbox
  453. //
  454. case IDC_TERRAIN_SHADOW_CHECK:
  455. curr_value = SendDlgItemMessage (ctrl_id, BM_GETCHECK);
  456. break;
  457. //
  458. // Read a value from a combo box.
  459. //
  460. case IDC_LIGHTING_MODE_COMBO:
  461. case IDC_TEXTURE_FILTER_COMBO:
  462. curr_value = SendDlgItemMessage (ctrl_id, CB_GETCURSEL);
  463. break;
  464. }
  465. //
  466. // Add this value to the list
  467. //
  468. settings.Add (curr_value);
  469. }
  470. return ;
  471. }
  472. /////////////////////////////////////////////////////////////////////////////
  473. //
  474. // Update_Expert_Controls
  475. //
  476. /////////////////////////////////////////////////////////////////////////////
  477. void
  478. PerformanceConfigDialogClass::Update_Expert_Controls (int level)
  479. {
  480. for (int index = 0; index < MAX_EXPERT_OPTIONS; index ++) {
  481. //
  482. // Determine which control we are updating
  483. //
  484. int ctrl_id = _PerformanceLevels[level][index].ctrl_id;
  485. switch (ctrl_id) {
  486. //
  487. // Update any of the sliders via the same mechanism
  488. //
  489. case IDC_GEOMETRY_DETAIL_SLIDER:
  490. case IDC_CHAR_SHADOWS_SLIDER:
  491. case IDC_TEXTURE_DETAIL_SLIDER:
  492. case IDC_PARTICLE_DETAIL_SLIDER:
  493. case IDC_SURFACE_DETAIL_SLIDER:
  494. SendDlgItemMessage (ctrl_id, TBM_SETPOS, TRUE, _PerformanceLevels[level][index].value);
  495. break;
  496. //
  497. // Update any of the check boxes via the same mechanism
  498. //
  499. case IDC_TERRAIN_SHADOW_CHECK:
  500. SendDlgItemMessage (ctrl_id, BM_SETCHECK, _PerformanceLevels[level][index].value);
  501. break;
  502. //
  503. // Update any of the combo boxes.
  504. //
  505. case IDC_LIGHTING_MODE_COMBO:
  506. case IDC_TEXTURE_FILTER_COMBO:
  507. SendDlgItemMessage (ctrl_id, CB_SETCURSEL, _PerformanceLevels[level][index].value);
  508. break;
  509. }
  510. }
  511. return ;
  512. }
  513. /////////////////////////////////////////////////////////////////////////////
  514. //
  515. // OnHScroll
  516. //
  517. /////////////////////////////////////////////////////////////////////////////
  518. void
  519. PerformanceConfigDialogClass::OnHScroll
  520. (
  521. UINT nSBCode,
  522. UINT nPos,
  523. CScrollBar * pScrollBar
  524. )
  525. {
  526. int ctrl_id = ::GetWindowLong (pScrollBar->m_hWnd, GWL_ID);
  527. //
  528. // If this is the overall performance slider, then
  529. // update the expert controls to reflect the new setting
  530. //
  531. if (ctrl_id == IDC_PERFORMANCE_SLIDER) {
  532. int new_level = m_PerformanceSlider.GetPos ();
  533. Update_Expert_Controls (new_level);
  534. }
  535. CDialog::OnHScroll (nSBCode, nPos, pScrollBar);
  536. return ;
  537. }
  538. /////////////////////////////////////////////////////////////////////////////
  539. //
  540. // Apply_Changes
  541. //
  542. /////////////////////////////////////////////////////////////////////////////
  543. void
  544. PerformanceConfigDialogClass::Apply_Changes (void)
  545. {
  546. //
  547. // Attempt to open the registry key
  548. //
  549. RegistryClass registry (KEY_NAME_SETTINGS);
  550. if (registry.Is_Valid ()) {
  551. //
  552. // Get the current settings from the dialog
  553. //
  554. int geometry_detail = m_GeometrySlider.GetPos ();
  555. int shadow_mode = m_CharShadowsSlider.GetPos ();
  556. int texture_red = m_TextureDetailSlider.GetPos ();
  557. int surface_effect = m_SurfaceEffectsSlider.GetPos ();
  558. int particle_detail = m_ParticleSlider.GetPos ();
  559. int static_shadows = SendDlgItemMessage (IDC_TERRAIN_SHADOW_CHECK, BM_GETCHECK);
  560. int prelit_mode = SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_GETCURSEL);
  561. // If card can't do multi-pass, value 1 means multi-texture (multi-pass selection is missing from the combo box)
  562. if (!CanDoMultiPass) {
  563. if (prelit_mode==1) prelit_mode=WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE;
  564. }
  565. int texture_filter = SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_GETCURSEL);
  566. //
  567. // Determine a good LOD budget to use
  568. //
  569. int lod_budget = 0;
  570. if (geometry_detail == 0) {
  571. lod_budget = 0;
  572. } else if (geometry_detail == 1) {
  573. lod_budget = 5000;
  574. } else if (geometry_detail == 2) {
  575. lod_budget = 10000;
  576. }
  577. //
  578. // Store the values in the registry
  579. //
  580. registry.Set_Int (VALUE_NAME_DYN_LOD, lod_budget);
  581. registry.Set_Int (VALUE_NAME_STATIC_LOD, lod_budget);
  582. registry.Set_Int (VALUE_NAME_DYN_SHADOWS, (shadow_mode != PhysicsSceneClass::SHADOW_MODE_NONE));
  583. registry.Set_Int (VALUE_NAME_STATIC_SHADOWS, static_shadows);
  584. registry.Set_Int (VALUE_NAME_PRELIT_MODE, prelit_mode);
  585. registry.Set_Int (VALUE_NAME_TEXTURE_FILTER, texture_filter);
  586. registry.Set_Int (VALUE_NAME_SHADOW_MODE, shadow_mode);
  587. registry.Set_Int (VALUE_NAME_TEXTURE_RES, max (2 - texture_red, 0));
  588. registry.Set_Int (VALUE_NAME_SURFACE_EFFECT, surface_effect);
  589. registry.Set_Int (VALUE_NAME_PARTICLE_DETAIL, particle_detail);
  590. }
  591. return ;
  592. }
  593. /////////////////////////////////////////////////////////////////////////////
  594. //
  595. // WindowProc
  596. //
  597. /////////////////////////////////////////////////////////////////////////////
  598. LRESULT
  599. PerformanceConfigDialogClass::WindowProc
  600. (
  601. UINT message,
  602. WPARAM wParam,
  603. LPARAM lParam
  604. )
  605. {
  606. if (message == (WM_USER + 101)) {
  607. Apply_Changes ();
  608. }
  609. return CDialog::WindowProc(message, wParam, lParam);
  610. }
  611. /*
  612. //If really low texture memory such as 4 Mb (if possible to detect) set level 2
  613. - If multtexturing available, default to multitextured lighting, otherwise multi pass
  614. - If a low end card, default to vertex solve
  615. - Default to 640x480, 800x600 or 1024x768 depending on video card
  616. - Default to 32 bit display on HW T&L cards, 16 bit otherwise
  617. - Default to fullscreen (do we even support windowed mode in the release?)
  618. - The same for particle detail
  619. */
  620. void AutoConfigSettings();
  621. void PerformanceConfigDialogClass::OnGraphicsAutoSetup()
  622. {
  623. // TODO: Add your control notification handler code here
  624. AutoConfigSettings();
  625. Load_Values();
  626. // Apply_Changes();
  627. };
  628. /*
  629. registry.Set_Int (VALUE_NAME_DYN_LOD, lod_budget);
  630. registry.Set_Int (VALUE_NAME_STATIC_LOD, lod_budget);
  631. registry.Set_Int (VALUE_NAME_DYN_SHADOWS, (shadow_mode != PhysicsSceneClass::SHADOW_MODE_NONE));
  632. registry.Set_Int (VALUE_NAME_STATIC_SHADOWS, static_shadows);
  633. registry.Set_Int (VALUE_NAME_PRELIT_MODE, prelit_mode);
  634. registry.Set_Int (VALUE_NAME_SHADOW_MODE, shadow_mode);
  635. registry.Set_Int (VALUE_NAME_TEXTURE_RES, max (2 - texture_red, 0));
  636. registry.Set_Int (VALUE_NAME_SURFACE_EFFECT, surface_effect);
  637. registry.Set_Int (VALUE_NAME_PARTICLE_DETAIL, particle_detail);
  638. */
  639. void AutoConfigSettings()
  640. {
  641. //
  642. // Attempt to open the registry key
  643. //
  644. RegistryClass registry (KEY_NAME_SETTINGS);
  645. if (!registry.Is_Valid()) return;
  646. // Access registry key "Render"
  647. RegistryClass render_registry(RENEGADE_SUB_KEY_NAME_RENDER);
  648. if ( !render_registry.Is_Valid() ) {
  649. return;
  650. }
  651. IDirect3D8* d3d=NULL;
  652. D3DCAPS8 tmp_caps;
  653. const D3DCAPS8* d3dcaps=NULL;
  654. D3DADAPTER_IDENTIFIER8 adapter_id;
  655. D3DFORMAT display_format;
  656. VideoConfigDialogClass* video=VideoConfigDialogClass::Get_Instance();
  657. if (video) {
  658. WW3D::Set_Texture_Bitdepth(16);
  659. render_registry.Set_Int( VALUE_NAME_RENDER_DEVICE_TEXTURE_DEPTH, 16 );
  660. d3d=DX8Wrapper::_Get_D3D8();
  661. d3d->AddRef();
  662. d3dcaps=&video->Get_Current_Caps();
  663. adapter_id=video->Get_Current_Adapter_Identifier();
  664. if (video->Get_Current_Bit_Depth()==32) {
  665. display_format=D3DFMT_X8R8G8B8;
  666. }
  667. else {
  668. display_format=D3DFMT_R5G6B5;
  669. }
  670. }
  671. else {
  672. // Init D3D
  673. Init_D3D_To_WW3_Conversion();
  674. d3d=Direct3DCreate8(D3D_SDK_VERSION); // TODO: handle failure cases...
  675. if (!d3d) {
  676. return;
  677. }
  678. // Select device. If there is already a device selected in the registry, use it.
  679. int current_adapter_index=D3DADAPTER_DEFAULT;
  680. //
  681. // Load the render device settings from the registry
  682. //
  683. char device_name[256] = { 0 };
  684. render_registry.Get_String( VALUE_NAME_RENDER_DEVICE_NAME, device_name, sizeof(device_name));
  685. int adapter_count = d3d->GetAdapterCount();
  686. for (int adapter_index=0; adapter_index<adapter_count; adapter_index++) {
  687. D3DADAPTER_IDENTIFIER8 id;
  688. ::ZeroMemory(&id, sizeof(D3DADAPTER_IDENTIFIER8));
  689. HRESULT res = d3d->GetAdapterIdentifier(adapter_index,D3DENUM_NO_WHQL_LEVEL,&id);
  690. // If device ok, check if it matches the currently set adapter name
  691. if (res == D3D_OK) {
  692. StringClass name(id.Description,true);
  693. if (name==device_name) {
  694. current_adapter_index=adapter_index;
  695. break;
  696. }
  697. }
  698. }
  699. if (FAILED(d3d->GetDeviceCaps(
  700. current_adapter_index,
  701. D3DDEVTYPE_HAL,
  702. &tmp_caps))) {
  703. d3d->Release();
  704. return;
  705. }
  706. ::ZeroMemory(&adapter_id, sizeof(D3DADAPTER_IDENTIFIER8));
  707. if (FAILED( d3d->GetAdapterIdentifier(
  708. current_adapter_index,
  709. D3DENUM_NO_WHQL_LEVEL,
  710. &adapter_id))) {
  711. d3d->Release();
  712. return;
  713. }
  714. // Store device name in registry
  715. render_registry.Set_String( VALUE_NAME_RENDER_DEVICE_NAME, adapter_id.Description);
  716. // Set resolution to 800 x 600 x 16
  717. render_registry.Set_Int( VALUE_NAME_RENDER_DEVICE_WIDTH, 800 );
  718. render_registry.Set_Int( VALUE_NAME_RENDER_DEVICE_HEIGHT, 600 );
  719. render_registry.Set_Int( VALUE_NAME_RENDER_DEVICE_DEPTH, 16 );
  720. render_registry.Set_Int( VALUE_NAME_RENDER_DEVICE_WINDOWED, 0 );
  721. render_registry.Set_Int( VALUE_NAME_RENDER_DEVICE_TEXTURE_DEPTH, 16 );
  722. d3dcaps=&tmp_caps;
  723. display_format=D3DFMT_R5G6B5;
  724. // Test if the card if new enough to do 32 bit...
  725. DX8Caps tmp_caps(d3d,*d3dcaps,WW3D_FORMAT_UNKNOWN,adapter_id);
  726. switch (tmp_caps.Get_Vendor()) {
  727. default:
  728. break;
  729. case DX8Caps::VENDOR_NVIDIA:
  730. switch (tmp_caps.Get_Device()) {
  731. default:
  732. display_format=D3DFMT_X8R8G8B8;
  733. render_registry.Set_Int( VALUE_NAME_RENDER_DEVICE_DEPTH, 32 );
  734. break;
  735. case DX8Caps::DEVICE_NVIDIA_TNT2_ALADDIN:
  736. case DX8Caps::DEVICE_NVIDIA_TNT2:
  737. case DX8Caps::DEVICE_NVIDIA_TNT2_ULTRA:
  738. case DX8Caps::DEVICE_NVIDIA_TNT2_VANTA:
  739. case DX8Caps::DEVICE_NVIDIA_TNT2_M64:
  740. case DX8Caps::DEVICE_NVIDIA_TNT:
  741. case DX8Caps::DEVICE_NVIDIA_RIVA_128:
  742. case DX8Caps::DEVICE_NVIDIA_TNT_VANTA:
  743. case DX8Caps::DEVICE_NVIDIA_NV1:
  744. break;
  745. }
  746. break;
  747. case DX8Caps::VENDOR_ATI:
  748. switch (tmp_caps.Get_Device()) {
  749. case DX8Caps::DEVICE_ATI_RAGE_II:
  750. case DX8Caps::DEVICE_ATI_RAGE_II_PLUS:
  751. case DX8Caps::DEVICE_ATI_RAGE_IIC_PCI:
  752. case DX8Caps::DEVICE_ATI_RAGE_IIC_AGP:
  753. case DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY:
  754. case DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY_M3:
  755. case DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY_M4:
  756. case DX8Caps::DEVICE_ATI_RAGE_128_PRO_ULTRA:
  757. case DX8Caps::DEVICE_ATI_RAGE_128_4X:
  758. case DX8Caps::DEVICE_ATI_RAGE_128_PRO_GL:
  759. case DX8Caps::DEVICE_ATI_RAGE_128_PRO_VR:
  760. case DX8Caps::DEVICE_ATI_RAGE_128_GL:
  761. case DX8Caps::DEVICE_ATI_RAGE_128_VR:
  762. case DX8Caps::DEVICE_ATI_RAGE_PRO:
  763. case DX8Caps::DEVICE_ATI_RAGE_PRO_MOBILITY:
  764. break;
  765. default:
  766. display_format=D3DFMT_X8R8G8B8;
  767. render_registry.Set_Int( VALUE_NAME_RENDER_DEVICE_DEPTH, 32 );
  768. break;
  769. }
  770. break;
  771. }
  772. }
  773. DX8Caps caps(d3d,*d3dcaps,D3DFormat_To_WW3DFormat(display_format),adapter_id);
  774. CanDoMultiPass=caps.Can_Do_Multi_Pass();
  775. bool high_end_processor=CPUDetectClass::Has_SSE_Instruction_Set();
  776. if (CPUDetectClass::Get_Processor_Manufacturer()==CPUDetectClass::MANUFACTURER_AMD &&
  777. CPUDetectClass::Get_AMD_Processor()>=CPUDetectClass::AMD_PROCESSOR_ATHLON_025) {
  778. high_end_processor=true;
  779. }
  780. // If no texture compression, default to texture resolution 1
  781. if (caps.Support_DXTC()) {
  782. registry.Set_Int (VALUE_NAME_TEXTURE_RES, 0);
  783. }
  784. else {
  785. registry.Set_Int (VALUE_NAME_TEXTURE_RES, 1);
  786. }
  787. // High geometry detail on T&L cards, medium on fast processors and low on slow ones
  788. if (caps.Support_TnL()) {
  789. registry.Set_Int (VALUE_NAME_DYN_LOD, 10000);
  790. registry.Set_Int (VALUE_NAME_STATIC_LOD, 10000);
  791. }
  792. else {
  793. // If T&L hardware present, set to medium or low. Set to medium if high end cpu.
  794. // TODO: Set to medium if Athlon detected.
  795. if (high_end_processor) {
  796. registry.Set_Int (VALUE_NAME_DYN_LOD, 5000);
  797. registry.Set_Int (VALUE_NAME_STATIC_LOD, 5000);
  798. }
  799. else {
  800. registry.Set_Int (VALUE_NAME_DYN_LOD, 0);
  801. registry.Set_Int (VALUE_NAME_STATIC_LOD, 0);
  802. }
  803. }
  804. // Set high shadow detail if render to texture is supported AND HWTL available
  805. // Set medium shadow detail if render to texture is supported but no HWTL
  806. // Set low shadow detail if no render to texture is available
  807. if (caps.Support_Render_To_Texture_Format(D3DFormat_To_WW3DFormat(display_format))) {
  808. if (caps.Support_TnL()) {
  809. registry.Set_Int (VALUE_NAME_SHADOW_MODE, 3);
  810. registry.Set_Int (VALUE_NAME_STATIC_SHADOWS, 1);
  811. }
  812. else {
  813. registry.Set_Int (VALUE_NAME_SHADOW_MODE, 2);
  814. registry.Set_Int (VALUE_NAME_STATIC_SHADOWS, 0);
  815. }
  816. }
  817. else {
  818. registry.Set_Int (VALUE_NAME_STATIC_SHADOWS, 0);
  819. // Set to medium if high end cpu detected.
  820. // TODO: Set to medium if Athlon detected.
  821. if (high_end_processor) {
  822. registry.Set_Int (VALUE_NAME_SHADOW_MODE, 1);
  823. }
  824. else {
  825. registry.Set_Int (VALUE_NAME_SHADOW_MODE, 0);
  826. }
  827. }
  828. // If a low end system turn surface effects off
  829. if (caps.Support_TnL()) {
  830. registry.Set_Int (VALUE_NAME_SURFACE_EFFECT, 2);
  831. }
  832. else {
  833. // Set to medium if high end cpu detected.
  834. // TODO: Set to medium if Athlon detected.
  835. if (high_end_processor) {
  836. registry.Set_Int (VALUE_NAME_SURFACE_EFFECT, 1);
  837. }
  838. else {
  839. registry.Set_Int (VALUE_NAME_SURFACE_EFFECT, 0);
  840. }
  841. }
  842. // If HWTL and high end cpu, use highest particle detail
  843. if (caps.Support_TnL() && high_end_processor) {
  844. registry.Set_Int (VALUE_NAME_PARTICLE_DETAIL, 2);
  845. }
  846. // If one or the other, use medium particle detail
  847. else if (caps.Support_TnL() || high_end_processor) {
  848. registry.Set_Int (VALUE_NAME_PARTICLE_DETAIL, 1);
  849. }
  850. else {
  851. registry.Set_Int (VALUE_NAME_PARTICLE_DETAIL, 0);
  852. }
  853. // If the system has less than 100 Megs (64 or 96 most likely) of RAM, select vertex solve to
  854. // save memory.
  855. // If card can't do multi pass (which is the case if we've seen z-fighting problems when multi-passing)
  856. // select vertex solve.
  857. if (!caps.Can_Do_Multi_Pass() || CPUDetectClass::Get_Total_Physical_Memory()<100*1024*1024) {
  858. registry.Set_Int (VALUE_NAME_PRELIT_MODE, 0);
  859. }
  860. // Otherwise select multitexturing if card can do it, or multipass...
  861. else {
  862. if (caps.Get_Max_Textures_Per_Pass()>=2) {
  863. registry.Set_Int (VALUE_NAME_PRELIT_MODE, 2);
  864. }
  865. else {
  866. registry.Set_Int (VALUE_NAME_PRELIT_MODE, 1);
  867. }
  868. }
  869. RegistryClass registry_options (KEY_NAME_OPTIONS);
  870. if (!registry_options.Is_Valid()) return;
  871. // The uv bias setting for most of the cards
  872. // (PowerVR Kyro and Kyro II and ATI Rage Pro need different UV bias and the rest of the cards.)
  873. registry_options.Set_Int( "ScreenUVBias", 1 );
  874. switch (caps.Get_Vendor()) {
  875. default:
  876. registry.Set_Int(VALUE_NAME_TEXTURE_FILTER,0); // Most cards default to bilinear filtering
  877. break;
  878. case DX8Caps::VENDOR_NVIDIA:
  879. switch (caps.Get_Device()) {
  880. case DX8Caps::DEVICE_NVIDIA_TNT2_ALADDIN:
  881. case DX8Caps::DEVICE_NVIDIA_TNT2:
  882. case DX8Caps::DEVICE_NVIDIA_TNT2_ULTRA:
  883. case DX8Caps::DEVICE_NVIDIA_TNT2_VANTA:
  884. case DX8Caps::DEVICE_NVIDIA_TNT2_M64:
  885. case DX8Caps::DEVICE_NVIDIA_TNT:
  886. case DX8Caps::DEVICE_NVIDIA_RIVA_128:
  887. case DX8Caps::DEVICE_NVIDIA_TNT_VANTA:
  888. case DX8Caps::DEVICE_NVIDIA_NV1:
  889. registry.Set_Int(VALUE_NAME_TEXTURE_FILTER,0);
  890. break;
  891. default:
  892. registry.Set_Int(VALUE_NAME_TEXTURE_FILTER,1); // New NVidia cards default to trilinear
  893. }
  894. break;
  895. case DX8Caps::VENDOR_ATI:
  896. switch (caps.Get_Device()) {
  897. case DX8Caps::DEVICE_ATI_RAGE_II:
  898. case DX8Caps::DEVICE_ATI_RAGE_II_PLUS:
  899. case DX8Caps::DEVICE_ATI_RAGE_IIC_PCI:
  900. case DX8Caps::DEVICE_ATI_RAGE_IIC_AGP:
  901. case DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY:
  902. case DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY_M3:
  903. case DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY_M4:
  904. case DX8Caps::DEVICE_ATI_RAGE_128_PRO_ULTRA:
  905. case DX8Caps::DEVICE_ATI_RAGE_128_4X:
  906. case DX8Caps::DEVICE_ATI_RAGE_128_PRO_GL:
  907. case DX8Caps::DEVICE_ATI_RAGE_128_PRO_VR:
  908. case DX8Caps::DEVICE_ATI_RAGE_128_GL:
  909. case DX8Caps::DEVICE_ATI_RAGE_128_VR:
  910. case DX8Caps::DEVICE_ATI_RAGE_PRO:
  911. case DX8Caps::DEVICE_ATI_RAGE_PRO_MOBILITY:
  912. registry.Set_Int(VALUE_NAME_TEXTURE_FILTER,0);
  913. // It seems the bias needs to be adjusted on Rage128 as well...
  914. if (caps.Get_Device()==DX8Caps::DEVICE_ATI_RAGE_PRO ||
  915. caps.Get_Device()==DX8Caps::DEVICE_ATI_RAGE_PRO_MOBILITY ||
  916. caps.Get_Device()==DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY ||
  917. caps.Get_Device()==DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY_M3 ||
  918. caps.Get_Device()==DX8Caps::DEVICE_ATI_RAGE_128_MOBILITY_M4 ||
  919. caps.Get_Device()==DX8Caps::DEVICE_ATI_RAGE_128_PRO_ULTRA) {
  920. registry_options.Set_Int( "ScreenUVBias", 0 );
  921. }
  922. break;
  923. default:
  924. registry.Set_Int(VALUE_NAME_TEXTURE_FILTER,1); // New ATI cards default to trilinear
  925. break;
  926. }
  927. break;
  928. case DX8Caps::VENDOR_POWERVR:
  929. // not sure how this goes. Kyro at the office requires 1, but some other powervr
  930. // card seems to require 0...
  931. registry_options.Set_Int( "ScreenUVBias", 0 );
  932. switch (caps.Get_Device()) {
  933. case DX8Caps::DEVICE_POWERVR_KYRO:
  934. registry_options.Set_Int( "ScreenUVBias", 1 );
  935. break;
  936. }
  937. break;
  938. }
  939. d3d->Release();
  940. }
  941. /////////////////////////////////////////////////////////////////////////////
  942. //
  943. // OnShowWindow
  944. //
  945. // Modified: 12/06/2001 by MML - Retrieving strings from Locomoto file.
  946. //
  947. /////////////////////////////////////////////////////////////////////////////
  948. void
  949. PerformanceConfigDialogClass::OnShowWindow(BOOL bShow, UINT nStatus)
  950. {
  951. char string[ _MAX_PATH ];
  952. CDialog::OnShowWindow(bShow, nStatus);
  953. if (bShow) {
  954. //
  955. // Insert code here
  956. //
  957. RegistryClass registry (KEY_NAME_SETTINGS);
  958. if (!registry.Is_Valid ()) return;
  959. VideoConfigDialogClass* video=VideoConfigDialogClass::Get_Instance();
  960. if (video) {
  961. IDirect3D8* d3d=DX8Wrapper::_Get_D3D8();
  962. d3d->AddRef();
  963. D3DADAPTER_IDENTIFIER8 adapter_id=video->Get_Current_Adapter_Identifier();
  964. D3DFORMAT display_format;
  965. if (video->Get_Current_Bit_Depth()==32) {
  966. display_format=D3DFMT_X8R8G8B8;
  967. }
  968. else {
  969. display_format=D3DFMT_R5G6B5;
  970. }
  971. DX8Caps caps(d3d,video->Get_Current_Caps(),D3DFormat_To_WW3DFormat(display_format),adapter_id);
  972. CanDoMultiPass=caps.Can_Do_Multi_Pass();
  973. //
  974. // Populate the lighting combobox
  975. //
  976. // Get the current selection
  977. char cur_sel_string[256];
  978. unsigned sel=SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_GETCURSEL, 0, 0);
  979. if (sel!=CB_ERR) {
  980. SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_GETLBTEXT, sel, (LPARAM)cur_sel_string);
  981. }
  982. else {
  983. cur_sel_string[0]=0;
  984. sel=registry.Get_Int (VALUE_NAME_PRELIT_MODE, WW3D::PRELIT_MODE_LIGHTMAP_MULTI_TEXTURE);
  985. }
  986. // Reset content and add available modes
  987. SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_RESETCONTENT, 0, 0);
  988. SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_ADDSTRING, 0, (LPARAM)Locale_GetString( IDS_VERTEX, string ));
  989. if (caps.Can_Do_Multi_Pass()) {
  990. SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_ADDSTRING, 0, (LPARAM)Locale_GetString( IDS_MULTI_PASS, string ));
  991. }
  992. if (caps.Get_Max_Textures_Per_Pass()>1) {
  993. SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_ADDSTRING, 0, (LPARAM)Locale_GetString( IDS_MULTI_TEXTURE, string ));
  994. }
  995. // Try to set the previous selection
  996. unsigned res=SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_FINDSTRINGEXACT, -1, (LPARAM)cur_sel_string);
  997. if (res==CB_ERR) {
  998. if (sel==0) res=0;
  999. else {
  1000. res=SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_GETCOUNT, 0, 0)-1;
  1001. if (sel<res) res=sel;
  1002. }
  1003. }
  1004. SendDlgItemMessage (IDC_LIGHTING_MODE_COMBO, CB_SETCURSEL, res, 0);
  1005. //
  1006. // Populate the texture filtering combobox
  1007. //
  1008. // Get the current selection
  1009. sel=SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_GETCURSEL, 0, 0);
  1010. if (sel!=CB_ERR) {
  1011. SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_GETLBTEXT, sel, (LPARAM)cur_sel_string);
  1012. }
  1013. else {
  1014. cur_sel_string[0]=0;
  1015. sel=registry.Get_Int (VALUE_NAME_TEXTURE_FILTER, TextureClass::TEXTURE_FILTER_BILINEAR);
  1016. }
  1017. SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_RESETCONTENT, 0, 0);
  1018. SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_ADDSTRING, 0, (LPARAM)Locale_GetString( IDS_BILINEAR, string ));
  1019. SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_ADDSTRING, 0, (LPARAM)Locale_GetString( IDS_TRILINEAR, string ));
  1020. if (caps.Support_Anisotropic_Filtering()) {
  1021. SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_ADDSTRING, 0, (LPARAM)Locale_GetString( IDS_ANISOTROPIC, string ));
  1022. }
  1023. // Try to set the previous selection
  1024. res=SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_FINDSTRINGEXACT, -1, (LPARAM)cur_sel_string);
  1025. if (res==CB_ERR) {
  1026. if (sel==0) res=0;
  1027. else {
  1028. res=SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_GETCOUNT, 0, 0)-1;
  1029. if (sel<res) res=sel;
  1030. }
  1031. }
  1032. SendDlgItemMessage (IDC_TEXTURE_FILTER_COMBO, CB_SETCURSEL, res, 0);
  1033. d3d->Release();
  1034. Determine_Performance_Setting ();
  1035. }
  1036. }
  1037. return ;
  1038. }