RenderDeviceDialog.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // RenderDeviceDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "phystest.h"
  22. #include "RenderDeviceDialog.h"
  23. #include "ww3d.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CRenderDeviceDialog dialog
  31. CRenderDeviceDialog::CRenderDeviceDialog(CWnd* pParent /*=NULL*/)
  32. : CDialog(CRenderDeviceDialog::IDD, pParent)
  33. {
  34. //{{AFX_DATA_INIT(CRenderDeviceDialog)
  35. // NOTE: the ClassWizard will add member initialization here
  36. //}}AFX_DATA_INIT
  37. }
  38. void CRenderDeviceDialog::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CRenderDeviceDialog)
  42. DDX_Control(pDX, IDC_RENDER_DEVICE_COMBO, m_RenderDeviceCombo);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CRenderDeviceDialog, CDialog)
  46. //{{AFX_MSG_MAP(CRenderDeviceDialog)
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CRenderDeviceDialog message handlers
  51. BOOL CRenderDeviceDialog::OnInitDialog()
  52. {
  53. CDialog::OnInitDialog();
  54. // plug all of the render device names into the combo box
  55. for (int i=0; i<WW3D::Get_Render_Device_Count(); i++) {
  56. const char * name = WW3D::Get_Render_Device_Name(i);
  57. m_RenderDeviceCombo.AddString(name);
  58. }
  59. m_RenderDeviceCombo.SetCurSel(WW3D::Get_Render_Device());
  60. return TRUE;
  61. }
  62. void CRenderDeviceDialog::OnOK()
  63. {
  64. // get the index of the currently selected render device and set ww3d to use it
  65. int device = m_RenderDeviceCombo.GetCurSel();
  66. if (device != CB_ERR) {
  67. // keep trying to set a device until one works
  68. WW3DErrorType err = WW3D_ERROR_GENERIC;
  69. int count = 0;
  70. while ((err != WW3D_ERROR_OK) && (count < WW3D::Get_Render_Device_Count())) {
  71. err = WW3D::Set_Render_Device(device);
  72. count++;
  73. if (err != WW3D_ERROR_OK) {
  74. device = (device + 1) % WW3D::Get_Render_Device_Count();
  75. }
  76. }
  77. assert(err == WW3D_ERROR_OK);
  78. }
  79. CDialog::OnOK();
  80. }