Skip to content

Commit e233638

Browse files
committed
Enable 2 OpenGL introspections based on version >=3.0
- Use the newer extension list API when OpenGL version >= 3.0, rather than when it is >= 3.2. - Check for context "forward compatibility" when the OpenGL version >= 3.0, rather than when a core profile is in use.
1 parent 548e072 commit e233638

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

src/engine/renderer/tr_init.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -983,21 +983,21 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p
983983
{
984984
Log::Notice("%sUsing an OpenGL compatibility profile.", Color::ToString( Color::Red ) );
985985
}
986-
987-
if ( glConfig2.glForwardCompatibleContext )
988-
{
989-
Log::Notice("OpenGL 3.x context is forward compatible.");
990-
}
991-
else
992-
{
993-
Log::Notice("OpenGL 3.x context is not forward compatible.");
994-
}
995986
}
996987
else
997988
{
998989
Log::Notice("%sUsing OpenGL 2.x context.", Color::ToString( Color::Red ) );
999990
}
1000991

992+
if ( glConfig2.glForwardCompatibleContext )
993+
{
994+
Log::Notice("OpenGL context is forward compatible.");
995+
}
996+
else
997+
{
998+
Log::Notice("OpenGL context is not forward compatible.");
999+
}
1000+
10011001
if ( glConfig2.glEnabledExtensionsString.length() != 0 )
10021002
{
10031003
Log::Notice("%sUsing OpenGL extensions: %s", Color::ToString( Color::Green ), glConfig2.glEnabledExtensionsString );

src/engine/sys/sdl_glimp.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,19 @@ static void GLimp_RegisterConfiguration( const glConfiguration& highestConfigura
13771377
}
13781378
}
13791379

1380-
if ( requestedConfiguration.profile == glProfile::CORE )
1380+
{
1381+
int GLmajor, GLminor;
1382+
if ( 2 != sscanf( ( const char * ) glGetString( GL_VERSION ), "%d.%d", &GLmajor, &GLminor ) )
1383+
{
1384+
Sys::Error( "Indecipherable GL_VERSION" );
1385+
}
1386+
1387+
glConfig2.glMajor = GLmajor;
1388+
glConfig2.glMinor = GLminor;
1389+
}
1390+
1391+
// CONTEXT_FLAGS and forward compatibility were added in OpenGL 3.0
1392+
if ( glConfig2.glMajor >= 3 )
13811393
{
13821394
// Check if context is forward compatible.
13831395
int contextFlags;
@@ -1387,26 +1399,18 @@ static void GLimp_RegisterConfiguration( const glConfiguration& highestConfigura
13871399

13881400
if ( glConfig2.glForwardCompatibleContext )
13891401
{
1390-
logger.Debug( "Provided OpenGL core context is forward compatible." );
1402+
logger.Debug( "Provided OpenGL context is forward compatible." );
13911403
}
13921404
else
13931405
{
1394-
logger.Debug( "Provided OpenGL core context is not forward compatible." );
1406+
logger.Debug( "Provided OpenGL context is not forward compatible." );
13951407
}
13961408
}
13971409
else
13981410
{
13991411
glConfig2.glForwardCompatibleContext = false;
14001412
}
14011413

1402-
{
1403-
int GLmajor, GLminor;
1404-
sscanf( ( const char * ) glGetString( GL_VERSION ), "%d.%d", &GLmajor, &GLminor );
1405-
1406-
glConfig2.glMajor = GLmajor;
1407-
glConfig2.glMinor = GLminor;
1408-
}
1409-
14101414
// Get our config strings.
14111415
Q_strncpyz( glConfig.vendor_string, ( char * ) glGetString( GL_VENDOR ), sizeof( glConfig.vendor_string ) );
14121416
Q_strncpyz( glConfig.renderer_string, ( char * ) glGetString( GL_RENDERER ), sizeof( glConfig.renderer_string ) );
@@ -2754,10 +2758,11 @@ bool GLimp_Init()
27542758

27552759
glConfig2.glExtensionsString = std::string();
27562760

2757-
if ( glConfig.driverType == glDriverType_t::GLDRV_OPENGL3 )
2761+
if ( glConfig2.glMajor >= 3 )
27582762
{
27592763
GLint numExts, i;
27602764

2765+
// NUM_EXTENSIONS and glGetStringi( GL_EXTENSIONS, i ) were added in OpenGL 3.0
27612766
glGetIntegerv( GL_NUM_EXTENSIONS, &numExts );
27622767

27632768
logger.Debug( "Found %d OpenGL extensions.", numExts );
@@ -2795,6 +2800,7 @@ bool GLimp_Init()
27952800
}
27962801
else
27972802
{
2803+
// glGetString( GL_EXTENSIONS ) was deprecated in OpenGL 3.0
27982804
char* extensions_string = ( char * ) glGetString( GL_EXTENSIONS );
27992805

28002806
if ( extensions_string == nullptr )

0 commit comments

Comments
 (0)