@@ -116,7 +116,6 @@ static void drawFramerateBar(void);
116
116
#endif
117
117
118
118
// DEFINE AND ENUMS ///////////////////////////////////////////////////////////
119
- #define W3D_DISPLAY_DEFAULT_BIT_DEPTH 32
120
119
121
120
#define no_SAMPLE_DYNAMIC_LIGHT 1
122
121
#ifdef SAMPLE_DYNAMIC_LIGHT
@@ -735,38 +734,58 @@ void W3DDisplay::init( void )
735
734
m_2DRender = NEW Render2DClass;
736
735
DEBUG_ASSERTCRASH ( m_2DRender, (" Cannot create Render2DClass" ) );
737
736
738
- // set our default width and height and bit depth
739
- // / @todo we should set this according to options read from a file
740
- setWidth ( TheGlobalData->m_xResolution );
741
- setHeight ( TheGlobalData->m_yResolution );
742
- setBitDepth ( W3D_DISPLAY_DEFAULT_BIT_DEPTH );
743
-
744
- if ( WW3D::Set_Render_Device ( 0 ,
745
- getWidth (),
746
- getHeight (),
747
- getBitDepth (),
748
- getWindowed (),
749
- true ) != WW3D_ERROR_OK )
737
+ WW3DErrorType renderDeviceError;
738
+ Int attempt = 0 ;
739
+ do
750
740
{
751
- // Getting the device at the default bit depth (32) didn't work, so try
752
- // getting a 16 bit display. (Voodoo 1-3 only supported 16 bit.) jba.
753
- setBitDepth ( 16 );
754
- if ( WW3D::Set_Render_Device ( 0 ,
755
- getWidth (),
756
- getHeight (),
757
- getBitDepth (),
758
- getWindowed (),
759
- true ) != WW3D_ERROR_OK )
741
+ switch (attempt)
760
742
{
761
-
762
- WW3D::Shutdown ();
763
- WWMath::Shutdown ();
764
- throw ERROR_INVALID_D3D; // failed to initialize. User probably doesn't have DX 8.1
765
- DEBUG_ASSERTCRASH ( 0 , (" Unable to set render device\n " ) );
766
- return ;
743
+ case 0 :
744
+ // set our default width and height and bit depth
745
+ setWidth ( TheGlobalData->m_xResolution );
746
+ setHeight ( TheGlobalData->m_yResolution );
747
+ setBitDepth ( 32 );
748
+ break ;
749
+ case 1 :
750
+ // Getting the device at the default bit depth (32) didn't work, so try
751
+ // getting a 16 bit display. (Voodoo 1-3 only supported 16 bit.) jba.
752
+ setBitDepth ( 16 );
753
+ break ;
754
+ case 2 :
755
+ // TheSuperHackers @bugfix xezon 11/06/2025 Now tries a safe default resolution
756
+ // if the previous one did not succeed. This is unlikely to happen but is possible
757
+ // if the user writes an unsupported resolution into to the Option Preferences.
758
+ TheWritableGlobalData->m_xResolution = 800 ;
759
+ TheWritableGlobalData->m_yResolution = 600 ;
760
+ setWidth ( TheGlobalData->m_xResolution );
761
+ setHeight ( TheGlobalData->m_yResolution );
762
+ setBitDepth ( 32 );
763
+ break ;
764
+ case 3 :
765
+ setBitDepth ( 16 );
766
+ break ;
767
767
}
768
768
769
- } // end if
769
+ renderDeviceError = WW3D::Set_Render_Device (
770
+ 0 ,
771
+ getWidth (),
772
+ getHeight (),
773
+ getBitDepth (),
774
+ getWindowed (),
775
+ true );
776
+
777
+ ++attempt;
778
+ }
779
+ while (attempt < 4 && renderDeviceError != WW3D_ERROR_OK);
780
+
781
+ if (renderDeviceError != WW3D_ERROR_OK)
782
+ {
783
+ WW3D::Shutdown ();
784
+ WWMath::Shutdown ();
785
+ throw ERROR_INVALID_D3D; // failed to initialize. User probably doesn't have DX 8.1
786
+ DEBUG_ASSERTCRASH ( 0 , (" Unable to set render device\n " ) );
787
+ return ;
788
+ }
770
789
771
790
// Check if level was never set and default to setting most suitable for system.
772
791
if (TheGameLODManager->getStaticLODLevel () == STATIC_GAME_LOD_UNKNOWN)
0 commit comments