Skip to content

Commit

Permalink
ref_gl: do not trust REFAPI context version, get it from OpenGL anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
mittorn committed Oct 13, 2023
1 parent e6b4274 commit 911a7ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ref/gl/gl_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,8 @@ typedef float GLmatrix[16];
#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010

#define GL_MAJOR_VERSION 0x821B
#define GL_MINOR_VERSION 0x821C

#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
Expand Down
24 changes: 20 additions & 4 deletions ref/gl/gl_opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ void GL_InitExtensionsBigGL( void )
void GL_InitExtensions( void )
{
char value[MAX_VA_STRING];
GLint major = 0, minor = 0;

GL_OnContextCreated();

Expand All @@ -1002,11 +1003,26 @@ void GL_InitExtensions( void )
glConfig.renderer_string = (const char *)pglGetString( GL_RENDERER );
glConfig.version_string = (const char *)pglGetString( GL_VERSION );
glConfig.extensions_string = (const char *)pglGetString( GL_EXTENSIONS );
if( !glConfig.version_major && glConfig.version_string )

pglGetIntegerv(GL_MAJOR_VERSION, &major);
pglGetIntegerv(GL_MINOR_VERSION, &minor);
if( !major && glConfig.version_string )
{
const char *str = glConfig.version_string;
float ver;

while(*str && (*str < '0' || *str > '9')) str++;
ver = Q_atof(str);
if( ver )
{
glConfig.version_major = ver;
glConfig.version_minor = (int)(ver * 10) % 10;
}
}
else
{
float ver = Q_atof( glConfig.version_string );
glConfig.version_major = ver;
glConfig.version_major = (int)(ver * 10) % 10;
glConfig.version_major = major;
glConfig.version_minor = minor;
}
#ifndef XASH_GL_STATIC
if( !glConfig.extensions_string )
Expand Down

0 comments on commit 911a7ee

Please sign in to comment.