Load OpenGL ES 2.0 function procs

Load functions procs supported by OpenGL ES 2.0, though there is not a
compatible renderer yet. Change argument for GLimp_Init from coreContext
to fixedFunction.
This commit is contained in:
Zack Middleton 2018-07-20 23:40:21 -05:00
parent 7391215bd4
commit d861a4f427
7 changed files with 77 additions and 54 deletions

View file

@ -69,7 +69,15 @@ QGL_1_1_FIXED_FUNCTION_PROCS;
QGL_DESKTOP_1_1_PROCS;
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
QGL_ES_1_1_PROCS;
QGL_ES_1_1_FIXED_FUNCTION_PROCS;
QGL_1_3_PROCS;
QGL_1_5_PROCS;
QGL_2_0_PROCS;
QGL_3_0_PROCS;
QGL_ARB_occlusion_query_PROCS;
QGL_ARB_framebuffer_object_PROCS;
QGL_ARB_vertex_array_object_PROCS;
QGL_EXT_direct_state_access_PROCS;
#undef GLE
/*
@ -229,7 +237,7 @@ GLimp_GetProcAddresses
Get addresses for OpenGL functions.
===============
*/
static qboolean GLimp_GetProcAddresses( qboolean coreContext ) {
static qboolean GLimp_GetProcAddresses( qboolean fixedFunction ) {
qboolean success = qtrue;
const char *version;
@ -268,23 +276,41 @@ static qboolean GLimp_GetProcAddresses( qboolean coreContext ) {
sscanf( version, "%d.%d", &qglMajorVersion, &qglMinorVersion );
}
if ( coreContext && QGL_VERSION_ATLEAST( 3, 2 ) ) {
QGL_1_1_PROCS;
QGL_DESKTOP_1_1_PROCS;
} else if ( QGL_VERSION_ATLEAST( 1, 2 ) ) {
QGL_1_1_PROCS;
QGL_1_1_FIXED_FUNCTION_PROCS;
QGL_DESKTOP_1_1_PROCS;
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
} else if ( qglesMajorVersion == 1 && qglesMinorVersion >= 1 ) {
// OpenGL ES 1.1 (2.0 is not backward compatible)
QGL_1_1_PROCS;
QGL_1_1_FIXED_FUNCTION_PROCS;
QGL_ES_1_1_PROCS;
// error so this doesn't segfault due to NULL desktop GL functions being used
Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s\n", version );
if ( fixedFunction ) {
if ( QGL_VERSION_ATLEAST( 1, 2 ) ) {
QGL_1_1_PROCS;
QGL_1_1_FIXED_FUNCTION_PROCS;
QGL_DESKTOP_1_1_PROCS;
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
} else if ( qglesMajorVersion == 1 && qglesMinorVersion >= 1 ) {
// OpenGL ES 1.1 (2.0 is not backward compatible)
QGL_1_1_PROCS;
QGL_1_1_FIXED_FUNCTION_PROCS;
QGL_ES_1_1_PROCS;
QGL_ES_1_1_FIXED_FUNCTION_PROCS;
// error so this doesn't segfault due to NULL desktop GL functions being used
Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s\n", version );
} else {
Com_Error( ERR_FATAL, "Unsupported OpenGL Version (%s), OpenGL 1.2 is required\n", version );
}
} else {
Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s\n", version );
if ( QGL_VERSION_ATLEAST( 2, 0 ) ) {
QGL_1_1_PROCS;
QGL_DESKTOP_1_1_PROCS;
QGL_1_3_PROCS;
QGL_1_5_PROCS;
QGL_2_0_PROCS;
} else if ( QGLES_VERSION_ATLEAST( 2, 0 ) ) {
QGL_1_1_PROCS;
QGL_ES_1_1_PROCS;
QGL_1_3_PROCS;
QGL_1_5_PROCS;
QGL_2_0_PROCS;
// error so this doesn't segfault due to NULL desktop GL functions being used
Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s\n", version );
} else {
Com_Error( ERR_FATAL, "Unsupported OpenGL Version (%s), OpenGL 2.0 is required\n", version );
}
}
if ( QGL_VERSION_ATLEAST( 3, 0 ) || QGLES_VERSION_ATLEAST( 3, 0 ) ) {
@ -316,7 +342,15 @@ static void GLimp_ClearProcAddresses( void ) {
QGL_DESKTOP_1_1_PROCS;
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
QGL_ES_1_1_PROCS;
QGL_ES_1_1_FIXED_FUNCTION_PROCS;
QGL_1_3_PROCS;
QGL_1_5_PROCS;
QGL_2_0_PROCS;
QGL_3_0_PROCS;
QGL_ARB_occlusion_query_PROCS;
QGL_ARB_framebuffer_object_PROCS;
QGL_ARB_vertex_array_object_PROCS;
QGL_EXT_direct_state_access_PROCS;
qglActiveTextureARB = NULL;
qglClientActiveTextureARB = NULL;
@ -333,7 +367,7 @@ static void GLimp_ClearProcAddresses( void ) {
GLimp_SetMode
===============
*/
static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qboolean coreContext)
static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qboolean fixedFunction)
{
const char *glstring;
int perChannelColorBits;
@ -597,7 +631,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
SDL_SetWindowIcon( SDL_window, icon );
if (coreContext)
if (!fixedFunction)
{
int profileMask, majorVersion, minorVersion;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profileMask);
@ -623,7 +657,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
ri.Printf(PRINT_ALL, "SDL_GL_CreateContext succeeded.\n");
if ( GLimp_GetProcAddresses( qtrue ) )
if ( GLimp_GetProcAddresses( fixedFunction ) )
{
renderer = (const char *)qglGetString(GL_RENDERER);
}
@ -663,7 +697,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
continue;
}
if ( !GLimp_GetProcAddresses( qfalse ) )
if ( !GLimp_GetProcAddresses( fixedFunction ) )
{
ri.Printf( PRINT_ALL, "GLimp_GetProcAddresses() failed\n" );
GLimp_ClearProcAddresses();
@ -940,7 +974,7 @@ This routine is responsible for initializing the OS specific portions
of OpenGL
===============
*/
void GLimp_Init( qboolean coreContext)
void GLimp_Init( qboolean fixedFunction )
{
ri.Printf( PRINT_DEVELOPER, "Glimp_Init( )\n" );
@ -960,13 +994,13 @@ void GLimp_Init( qboolean coreContext)
ri.Sys_GLimpInit( );
// Create the window and set up the context
if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, r_noborder->integer, coreContext))
if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, r_noborder->integer, fixedFunction))
goto success;
// Try again, this time in a platform specific "safe mode"
ri.Sys_GLimpSafeInit( );
if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, qfalse, coreContext))
if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, qfalse, fixedFunction))
goto success;
// Finally, try the default screen resolution
@ -975,7 +1009,7 @@ void GLimp_Init( qboolean coreContext)
ri.Printf( PRINT_ALL, "Setting r_mode %d failed, falling back on r_mode %d\n",
r_mode->integer, R_MODE_FALLBACK );
if(GLimp_StartDriverAndSetMode(R_MODE_FALLBACK, qfalse, qfalse, coreContext))
if(GLimp_StartDriverAndSetMode(R_MODE_FALLBACK, qfalse, qfalse, fixedFunction))
goto success;
}