@@ -41,6 +41,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
41
41
42
42
static Log::Logger logger (" glconfig" , " " , Log::Level::NOTICE);
43
43
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
+
44
52
static Cvar::Modified<Cvar::Cvar<bool >> r_noBorder (
45
53
" r_noBorder" , " draw window without border" , Cvar::ARCHIVE, false );
46
54
static Cvar::Modified<Cvar::Range<Cvar::Cvar<int >>> r_swapInterval (
@@ -770,7 +778,8 @@ static void GLimp_SetAttributes( const glConfiguration &configuration )
770
778
SDL_GL_SetAttribute ( SDL_GL_STENCIL_SIZE, 0 );
771
779
SDL_GL_SetAttribute ( SDL_GL_DOUBLEBUFFER, 1 );
772
780
773
- if ( !r_glAllowSoftware->integer )
781
+ Cvar::Latch ( r_glAllowSoftware );
782
+ if ( !r_glAllowSoftware.Get () )
774
783
{
775
784
SDL_GL_SetAttribute ( SDL_GL_ACCELERATED_VISUAL, 1 );
776
785
}
@@ -1124,9 +1133,9 @@ static rserr_t GLimp_ValidateBestContext(
1124
1133
{ 1 , 0 , glProfile::COMPATIBILITY, true },
1125
1134
};
1126
1135
1127
- logger.Debug ( " Validating best OpenGL context. " );
1136
+ logger.Debug ( " Validating best OpenGL context" );
1128
1137
1129
- bool needHighestExtended = !! r_glExtendedValidation-> integer ;
1138
+ bool needHighestExtended = r_glExtendedValidation. Get () ;
1130
1139
for ( int colorBits : {24 , 16 } )
1131
1140
{
1132
1141
for ( auto & row : glSupportArray )
@@ -1182,14 +1191,16 @@ static glConfiguration GLimp_ApplyCustomOptions( const int GLEWmajor, const glCo
1182
1191
{
1183
1192
glConfiguration customConfiguration = {};
1184
1193
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" ) )
1186
1197
{
1187
1198
logger.Debug ( " Compatibility profile is forced by r_glProfile" );
1188
1199
1189
1200
customConfiguration.profile = glProfile::COMPATIBILITY;
1190
1201
}
1191
1202
1192
- if ( bestConfiguration.profile == glProfile::COMPATIBILITY && !Q_stricmp ( r_glProfile-> string , " core" ) )
1203
+ if ( bestConfiguration.profile == glProfile::COMPATIBILITY && !Q_stricmp ( glProfile. c_str () , " core" ) )
1193
1204
{
1194
1205
if ( GLEWmajor < 2 )
1195
1206
{
@@ -1204,8 +1215,10 @@ static glConfiguration GLimp_ApplyCustomOptions( const int GLEWmajor, const glCo
1204
1215
}
1205
1216
}
1206
1217
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 () );
1209
1222
1210
1223
if ( customConfiguration.major == 0 )
1211
1224
{
@@ -1598,11 +1611,11 @@ static rserr_t GLimp_SetMode( const int mode, const bool fullscreen, const bool
1598
1611
static glConfiguration bestValidatedConfiguration = {}; // considering only up to OpenGL 3.2
1599
1612
static glConfiguration extendedValidationResult = {}; // max available OpenGL version for diagnostic purposes
1600
1613
1601
- if ( r_glExtendedValidation-> integer && extendedValidationResult.major != 0 )
1614
+ if ( r_glExtendedValidation. Get () && extendedValidationResult.major != 0 )
1602
1615
{
1603
1616
logger.Debug ( " Previously best validated context: %s" , ContextDescription ( extendedValidationResult ) );
1604
1617
}
1605
- else if ( bestValidatedConfiguration.major == 0 || r_glExtendedValidation-> integer )
1618
+ else if ( bestValidatedConfiguration.major == 0 || r_glExtendedValidation. Get () )
1606
1619
{
1607
1620
// Detect best configuration.
1608
1621
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
1621
1634
}
1622
1635
}
1623
1636
1624
- if ( r_glExtendedValidation-> integer )
1637
+ if ( r_glExtendedValidation. Get () )
1625
1638
{
1626
1639
logger.Notice ( " Highest available context: %s" , ContextDescription ( extendedValidationResult ) );
1627
1640
}
0 commit comments