@@ -41,6 +41,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4141
4242static Log::Logger logger (" glconfig" , " " , Log::Level::NOTICE);
4343
44+ static Cvar::Range<Cvar::Cvar<int >> r_glMajorVersion ( " r_glMajorVersion" ,
45+ " Force this GL major version; 0 to set up automatically" , Cvar::NONE, 0 , 0 , 4 );
46+ static Cvar::Range<Cvar::Cvar<int >> r_glMinorVersion ( " r_glMinorVersion" ,
47+ " Force this GL minor version; 0 to set up automatically" , Cvar::NONE, 0 , 0 , 6 );
48+ static Cvar::Cvar<std::string> r_glProfile ( " r_glProfile" ,
49+ " Force this GL profile (core or compat); empty to set up automatically" , Cvar::NONE, " " );
50+ static Cvar::Cvar<bool > r_glAllowSoftware ( " r_glAllowSoftware" , " Allow software rendering" , Cvar::NONE, false );
51+
4452static Cvar::Modified<Cvar::Cvar<bool >> r_noBorder (
4553 " r_noBorder" , " draw window without border" , Cvar::ARCHIVE, false );
4654static Cvar::Modified<Cvar::Range<Cvar::Cvar<int >>> r_swapInterval (
@@ -770,7 +778,8 @@ static void GLimp_SetAttributes( const glConfiguration &configuration )
770778 SDL_GL_SetAttribute ( SDL_GL_STENCIL_SIZE, 0 );
771779 SDL_GL_SetAttribute ( SDL_GL_DOUBLEBUFFER, 1 );
772780
773- if ( !r_glAllowSoftware->integer )
781+ Cvar::Latch ( r_glAllowSoftware );
782+ if ( !r_glAllowSoftware.Get () )
774783 {
775784 SDL_GL_SetAttribute ( SDL_GL_ACCELERATED_VISUAL, 1 );
776785 }
@@ -1124,9 +1133,9 @@ static rserr_t GLimp_ValidateBestContext(
11241133 { 1 , 0 , glProfile::COMPATIBILITY, true },
11251134 };
11261135
1127- logger.Debug ( " Validating best OpenGL context. " );
1136+ logger.Debug ( " Validating best OpenGL context" );
11281137
1129- bool needHighestExtended = !! r_glExtendedValidation-> integer ;
1138+ bool needHighestExtended = r_glExtendedValidation. Get () ;
11301139 for ( int colorBits : {24 , 16 } )
11311140 {
11321141 for ( auto & row : glSupportArray )
@@ -1182,14 +1191,16 @@ static glConfiguration GLimp_ApplyCustomOptions( const int GLEWmajor, const glCo
11821191{
11831192 glConfiguration customConfiguration = {};
11841193
1185- if ( bestConfiguration.profile == glProfile::CORE && !Q_stricmp ( r_glProfile->string , " compat" ) )
1194+ Cvar::Latch ( r_glProfile );
1195+ const std::string glProfile = r_glProfile.Get ();
1196+ if ( bestConfiguration.profile == glProfile::CORE && !Q_stricmp ( glProfile.c_str (), " compat" ) )
11861197 {
11871198 logger.Debug ( " Compatibility profile is forced by r_glProfile" );
11881199
11891200 customConfiguration.profile = glProfile::COMPATIBILITY;
11901201 }
11911202
1192- if ( bestConfiguration.profile == glProfile::COMPATIBILITY && !Q_stricmp ( r_glProfile-> string , " core" ) )
1203+ if ( bestConfiguration.profile == glProfile::COMPATIBILITY && !Q_stricmp ( glProfile. c_str () , " core" ) )
11931204 {
11941205 if ( GLEWmajor < 2 )
11951206 {
@@ -1204,8 +1215,10 @@ static glConfiguration GLimp_ApplyCustomOptions( const int GLEWmajor, const glCo
12041215 }
12051216 }
12061217
1207- customConfiguration.major = std::max ( 0 , r_glMajorVersion->integer );
1208- customConfiguration.minor = std::max ( 0 , r_glMinorVersion->integer );
1218+ Cvar::Latch ( r_glMajorVersion );
1219+ Cvar::Latch ( r_glMinorVersion );
1220+ customConfiguration.major = std::max ( 0 , r_glMajorVersion.Get () );
1221+ customConfiguration.minor = std::max ( 0 , r_glMinorVersion.Get () );
12091222
12101223 if ( customConfiguration.major == 0 )
12111224 {
@@ -1598,11 +1611,11 @@ static rserr_t GLimp_SetMode( const int mode, const bool fullscreen, const bool
15981611 static glConfiguration bestValidatedConfiguration = {}; // considering only up to OpenGL 3.2
15991612 static glConfiguration extendedValidationResult = {}; // max available OpenGL version for diagnostic purposes
16001613
1601- if ( r_glExtendedValidation-> integer && extendedValidationResult.major != 0 )
1614+ if ( r_glExtendedValidation. Get () && extendedValidationResult.major != 0 )
16021615 {
16031616 logger.Debug ( " Previously best validated context: %s" , ContextDescription ( extendedValidationResult ) );
16041617 }
1605- else if ( bestValidatedConfiguration.major == 0 || r_glExtendedValidation-> integer )
1618+ else if ( bestValidatedConfiguration.major == 0 || r_glExtendedValidation. Get () )
16061619 {
16071620 // Detect best configuration.
16081621 rserr_t err = GLimp_ValidateBestContext ( GLEWmajor, bestValidatedConfiguration, extendedValidationResult );
@@ -1621,7 +1634,7 @@ static rserr_t GLimp_SetMode( const int mode, const bool fullscreen, const bool
16211634 }
16221635 }
16231636
1624- if ( r_glExtendedValidation-> integer )
1637+ if ( r_glExtendedValidation. Get () )
16251638 {
16261639 logger.Notice ( " Highest available context: %s" , ContextDescription ( extendedValidationResult ) );
16271640 }
0 commit comments