Browse Source

ref_gl: fix codestyle

pull/2/head
mittorn 1 year ago committed by Alibek Omarov
parent
commit
a2b992d865
  1. 4
      ref/gl/gl_image.c
  2. 94
      ref/gl/gl_opengl.c

4
ref/gl/gl_image.c

@ -1083,9 +1083,9 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin @@ -1083,9 +1083,9 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin
samplesCount = 1;
}
pglTexImage2DMultisample( tex->target, samplesCount, tex->format, width, height, GL_TRUE );
#else /* !XASH_GLES && !XASH_GL4ES */
#else /* !XASH_GL_STATIC !XASH_GLES && !XASH_GL4ES */
gEngfuncs.Con_Printf( S_ERROR "GLES renderer don't support GL_TEXTURE_2D_MULTISAMPLE!\n" );
#endif /* !XASH_GLES && !XASH_GL4ES */
#endif /* !XASH_GL_STATIC !XASH_GLES && !XASH_GL4ES */
}
else // 2D or RECT
{

94
ref/gl/gl_opengl.c

@ -334,6 +334,19 @@ static dllfunc_t shaderobjectsfuncs[] = @@ -334,6 +334,19 @@ static dllfunc_t shaderobjectsfuncs[] =
{ NULL, NULL }
};
/*
==================
Even if *ARB functions may work in GL driver in Core context,
renderdoc completely ignores this calls, so we cannot workaround this
by removing ARB suffix after failed function resolve
I desided not to remove ARB suffix from function declarations because
it historicaly related to ARB_shader_object extension, not GL2+ functions
and all shader code from XashXT/ancient xash3d uses it too
Commented out lines left there intentionally to prevent usage on core/gles
==================
*/
static dllfunc_t shaderobjectsfuncs_gles[] =
{
{ "glDeleteShader" , (void **)&pglDeleteObjectARB },
@ -384,22 +397,24 @@ static dllfunc_t shaderobjectsfuncs_gles[] = @@ -384,22 +397,24 @@ static dllfunc_t shaderobjectsfuncs_gles[] =
{ "glVertexAttrib2f" , (void **)&pglVertexAttrib2fARB },
{ "glVertexAttrib2fv" , (void **)&pglVertexAttrib2fvARB },
{ "glVertexAttrib3fv" , (void **)&pglVertexAttrib3fvARB },
{ "glGetProgramiv" , (void**)&pglGetProgramiv },
{ "glDeleteProgram" , (void**)&pglDeleteProgram },
{ "glGetProgramInfoLog" , (void **)&pglGetProgramInfoLog },
// Core/GLES only
{ GL_CALL( glGetProgramiv ) },
{ GL_CALL( glDeleteProgram ) },
{ GL_CALL( glGetProgramInfoLog ) },
//{ "glVertexAttrib4f" , (void **)&pglVertexAttrib4fARB },
//{ "glVertexAttrib4fv" , (void **)&pglVertexAttrib4fvARB },
//{ "glVertexAttrib4ubv" , (void **)&pglVertexAttrib4ubvARB },
{ NULL, NULL }
{ NULL, NULL }
};
static dllfunc_t vaofuncs[] =
{
{ "glBindVertexArray" , (void **)&pglBindVertexArray },
{ "glDeleteVertexArrays" , (void **)&pglDeleteVertexArrays },
{ "glGenVertexArrays" , (void **)&pglGenVertexArrays },
{ "glIsVertexArray" , (void **)&pglIsVertexArray },
{ NULL, NULL }
{ GL_CALL( glBindVertexArray ) },
{ GL_CALL( glDeleteVertexArrays ) },
{ GL_CALL( glGenVertexArrays ) },
{ GL_CALL( glIsVertexArray ) },
{ NULL, NULL }
};
static dllfunc_t multitexturefuncs_es[] =
@ -537,14 +552,16 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char @@ -537,14 +552,16 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
if((*func->func = (void *)gEngfuncs.GL_GetProcAddress( func->name )) == NULL )
{
// HACK: fix ARB names
char *str = Q_strstr(func->name, "ARB");
char *str = Q_strstr( func->name, "ARB" );
if(str)
{
string name;
Q_strncpy( name, func->name, MAX_STRING );
name[str - func->name] = '\0';
*func->func = gEngfuncs.GL_GetProcAddress( name );
if(!*func->func)
if( !*func->func )
GL_SetExtension( r_ext, false );
}
else
@ -749,14 +766,15 @@ void GL_InitExtensionsGLES( void ) @@ -749,14 +766,15 @@ void GL_InitExtensionsGLES( void )
GL_CheckExtension( "vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", extid, 1.0 );
break;
case GL_ARB_MULTITEXTURE:
if(!GL_CheckExtension( "multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0) && glConfig.wrapper == GLES_WRAPPER_NONE )
if( !GL_CheckExtension( "multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 ) && glConfig.wrapper == GLES_WRAPPER_NONE )
{
#ifndef XASH_GL_STATIC
if( !GL_CheckExtension( "multitexture_es1", multitexturefuncs_es, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 ) )
if( !GL_CheckExtension( "multitexture_es2", multitexturefuncs_es2, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 2.0 ) )
#else
break;
if( !GL_CheckExtension( "multitexture_es1", multitexturefuncs_es, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 )
&& !GL_CheckExtension( "multitexture_es2", multitexturefuncs_es2, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 2.0 ))
break;
#endif
//GL_SetExtension( extid, true ); // required to be supported by wrapper
}
GL_SetExtension( extid, true ); // required to be supported by wrapper
pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units );
if( glConfig.max_texture_units <= 1 )
@ -790,15 +808,15 @@ void GL_InitExtensionsGLES( void ) @@ -790,15 +808,15 @@ void GL_InitExtensionsGLES( void )
GL_CheckExtension( "ES2 Shaders", shaderobjectsfuncs_gles, "gl_shaderobjects", extid, 2.0 );
break;
case GL_ARB_VERTEX_ARRAY_OBJECT_EXT:
if(!GL_CheckExtension( "GL_OES_vertex_array_object", vaofuncs, "gl_vertex_array_object", extid, 3.0 ))
!GL_CheckExtension( "GL_EXT_vertex_array_object", vaofuncs, "gl_vertex_array_object", extid, 3.0 );
if( !GL_CheckExtension( "GL_OES_vertex_array_object", vaofuncs, "gl_vertex_array_object", extid, 3.0 ))
GL_CheckExtension( "GL_EXT_vertex_array_object", vaofuncs, "gl_vertex_array_object", extid, 3.0 );
break;
case GL_DRAW_RANGEELEMENTS_EXT:
if(!GL_CheckExtension( "GL_EXT_draw_range_elements", drawrangeelementsfuncs, "gl_drawrangeelements", extid, 3.0 ))
if( !GL_CheckExtension( "GL_EXT_draw_range_elements", drawrangeelementsfuncs, "gl_drawrangeelements", extid, 3.0 ))
GL_CheckExtension( "GL_OES_draw_range_elements", drawrangeelementsfuncs, "gl_drawrangeelements", extid, 3.0 );
break;
case GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT:
if( !GL_CheckExtension( "GL_OES_draw_elements_base_vertex", drawrangeelementsbasevertexfuncs, "gl_drawrangeelementsbasevertex", GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT, 0 ) )
if( !GL_CheckExtension( "GL_OES_draw_elements_base_vertex", drawrangeelementsbasevertexfuncs, "gl_drawrangeelementsbasevertex", GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT, 0 ))
GL_CheckExtension( "GL_EXT_draw_elements_base_vertex", drawrangeelementsbasevertexfuncs, "gl_drawrangeelementsbasevertex", GL_DRAW_RANGE_ELEMENTS_BASE_VERTEX_EXT, 3.2 );
break;
case GL_MAP_BUFFER_RANGE_EXT:
@ -930,7 +948,7 @@ void GL_InitExtensionsBigGL( void ) @@ -930,7 +948,7 @@ void GL_InitExtensionsBigGL( void )
GL_CheckExtension( "GL_ARB_texture_multisample", multisampletexfuncs, "gl_texture_multisample", GL_TEXTURE_MULTISAMPLE, 0 );
GL_CheckExtension( "GL_ARB_texture_compression_bptc", NULL, "gl_texture_bptc_compression", GL_ARB_TEXTURE_COMPRESSION_BPTC, 0 );
#ifndef XASH_GL_STATIC
if(glConfig.context == CONTEXT_TYPE_GL_CORE )
if( glConfig.context == CONTEXT_TYPE_GL_CORE )
GL_CheckExtension( "shader_objects", shaderobjectsfuncs_gles, "gl_shaderobjects", GL_SHADER_OBJECTS_EXT, 2.0 );
else
GL_CheckExtension( "GL_ARB_shader_objects", shaderobjectsfuncs, "gl_shaderobjects", GL_SHADER_OBJECTS_EXT, 2.0 );
@ -965,7 +983,7 @@ void GL_InitExtensionsBigGL( void ) @@ -965,7 +983,7 @@ void GL_InitExtensionsBigGL( void )
if( !GL_CheckExtension( "glDrawRangeElements", drawrangeelementsfuncs, "gl_drawrangeelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ) )
{
if( GL_CheckExtension( "glDrawRangeElementsEXT", drawrangeelementsextfuncs,
"gl_drawrangelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ) )
"gl_drawrangelements", GL_DRAW_RANGEELEMENTS_EXT, 0 ))
{
#ifndef XASH_GL_STATIC
pglDrawRangeElements = pglDrawRangeElementsEXT;
@ -984,7 +1002,7 @@ void GL_InitExtensionsBigGL( void ) @@ -984,7 +1002,7 @@ void GL_InitExtensionsBigGL( void )
VGL_ShimInit();
#endif
#if !defined(XASH_GLES) && !defined(XASH_GL_STATIC)
if( gEngfuncs.Sys_CheckParm("-gl2shim") )
if( gEngfuncs.Sys_CheckParm( "-gl2shim" ))
GL2_ShimInit();
#endif
}
@ -1006,14 +1024,14 @@ void GL_InitExtensions( void ) @@ -1006,14 +1024,14 @@ void GL_InitExtensions( void )
glConfig.version_string = (const char *)pglGetString( GL_VERSION );
glConfig.extensions_string = (const char *)pglGetString( GL_EXTENSIONS );
pglGetIntegerv(GL_MAJOR_VERSION, &major);
pglGetIntegerv(GL_MINOR_VERSION, &minor);
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++;
while( *str && ( *str < '0' || *str > '9' )) str++;
ver = Q_atof(str);
if( ver )
{
@ -1030,21 +1048,23 @@ void GL_InitExtensions( void ) @@ -1030,21 +1048,23 @@ void GL_InitExtensions( void )
if( !glConfig.extensions_string )
{
int n = 0;
pglGetStringi = gEngfuncs.GL_GetProcAddress("glGetStringi");
pglGetStringi = gEngfuncs.GL_GetProcAddress( "glGetStringi" );
pglGetIntegerv(GL_NUM_EXTENSIONS, &n);
if(n && pglGetStringi)
pglGetIntegerv( GL_NUM_EXTENSIONS, &n );
if( n && pglGetStringi )
{
int i;
int len = 1;
int i, len = 1;
char *str;
for(i = 0; i < n; i++)
len += Q_strlen((const char*)pglGetStringi(GL_EXTENSIONS, i)) + 1;
for( i = 0; i < n; i++ )
len += Q_strlen((const char *)pglGetStringi( GL_EXTENSIONS, i )) + 1;
str = (char*)Mem_Calloc( r_temppool, len );
glConfig.extensions_string = str;
for(i = 0; i < n; i++)
for( i = 0; i < n; i++ )
{
int l = Q_strncpy( str, pglGetStringi(GL_EXTENSIONS, i), len);
int l = Q_strncpy( str, pglGetStringi( GL_EXTENSIONS, i ), len );
str += l;
*str++ = ' ';
len -= l + 1;
@ -1355,7 +1375,7 @@ void GL_SetupAttributes( int safegl ) @@ -1355,7 +1375,7 @@ void GL_SetupAttributes( int safegl )
}
#endif // XASH_GLES
if( gEngfuncs.Sys_CheckParm( "-gldebug" ) )
if( gEngfuncs.Sys_CheckParm( "-gldebug" ))
{
gEngfuncs.Con_Reportf( "Creating an extended GL context for debug...\n" );
SetBits( context_flags, FCONTEXT_DEBUG_ARB );

Loading…
Cancel
Save