Browse Source

sdl: vid: refactor context creation, fix crash on exit on REF_SOFTWARE

pull/2/head
Alibek Omarov 6 years ago
parent
commit
211d3c5213
  1. 54
      engine/platform/sdl/vid_sdl.c
  2. 3
      engine/ref_api.h

54
engine/platform/sdl/vid_sdl.c

@ -759,29 +759,27 @@ qboolean R_Init_Video( const int type ) @@ -759,29 +759,27 @@ qboolean R_Init_Video( const int type )
glw_state.desktopWidth = displayMode.w;
glw_state.desktopHeight = displayMode.h;
if( type == REF_SOFTWARE )
{
glw_state.software = true;
if( !(retval = VID_SetMode()) )
{
return retval;
}
return true;
}
if( type != REF_GL )
{
Host_Error( "Can't initialize unknown context type %d!\n", type );
}
if( !glw_state.safe && Sys_GetParmFromCmdLine( "-safegl", safe ) )
glw_state.safe = bound( SAFE_NO, Q_atoi( safe ), SAFE_DONTCARE );
#if !defined(_WIN32)
SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" );
SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" );
#endif
R_InitVideoModes();
// must be initialized before creating window
#ifdef _WIN32
WIN_SetDPIAwareness();
#endif
switch( type )
{
case REF_SOFTWARE:
glw_state.software = true;
break;
case REF_GL:
if( !glw_state.safe && Sys_GetParmFromCmdLine( "-safegl", safe ) )
glw_state.safe = bound( SAFE_NO, Q_atoi( safe ), SAFE_DONTCARE );
// refdll can request some attributes
GL_SetupAttributes( );
@ -790,21 +788,27 @@ qboolean R_Init_Video( const int type ) @@ -790,21 +788,27 @@ qboolean R_Init_Video( const int type )
Con_Reportf( S_ERROR "Couldn't initialize OpenGL: %s\n", SDL_GetError());
return false;
}
R_InitVideoModes();
// must be initialized before creating window
#ifdef _WIN32
WIN_SetDPIAwareness();
#endif
break;
default:
Host_Error( "Can't initialize unknown context type %d!\n", type );
break;
}
if( !(retval = VID_SetMode()) )
{
return retval;
}
switch( type )
{
case REF_GL:
// refdll also can check extensions
ref.dllFuncs.GL_InitExtensions();
break;
case REF_SOFTWARE:
default:
break;
}
host.renderinfo_changed = false;

3
engine/ref_api.h

@ -443,13 +443,12 @@ typedef struct ref_interface_s @@ -443,13 +443,12 @@ typedef struct ref_interface_s
// const char *(*R_GetInitError)( void );
void (*R_Shutdown)( void );
//
// only called for GL contexts
void (*GL_SetupAttributes)( int safegl );
void (*GL_OnContextCreated)( void );
void (*GL_InitExtensions)( void );
void (*GL_ClearExtensions)( void );
void (*R_BeginFrame)( qboolean clearScene );
void (*R_RenderScene)( void );
void (*R_EndFrame)( void );

Loading…
Cancel
Save