mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2024-12-11 13:11:47 +00:00
Make sure SDL_Init() was called before SDL_VideoInfo()
by adding GLimp_PreInit()
This commit is contained in:
parent
ebbb98c9bd
commit
67d6a5a1fa
4 changed files with 38 additions and 6 deletions
|
@ -870,6 +870,10 @@ void R_InitOpenGL()
|
||||||
common->FatalError( "R_InitOpenGL called while active" );
|
common->FatalError( "R_InitOpenGL called while active" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DG: make sure SDL has setup video so getting supported modes in R_SetNewMode() works
|
||||||
|
GLimp_PreInit();
|
||||||
|
// DG end
|
||||||
|
|
||||||
R_SetNewMode( true );
|
R_SetNewMode( true );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1052,6 +1052,10 @@ struct glimpParms_t
|
||||||
int multiSamples;
|
int multiSamples;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// DG: R_GetModeListForDisplay is called before GLimp_Init(), but SDL needs SDL_Init() first.
|
||||||
|
// So add PreInit for platforms that need it, others can just stub it.
|
||||||
|
void GLimp_PreInit();
|
||||||
|
|
||||||
bool GLimp_Init( glimpParms_t parms );
|
bool GLimp_Init( glimpParms_t parms );
|
||||||
// If the desired mode can't be set satisfactorily, false will be returned.
|
// If the desired mode can't be set satisfactorily, false will be returned.
|
||||||
// If succesful, sets glConfig.nativeScreenWidth, glConfig.nativeScreenHeight, and glConfig.pixelAspect
|
// If succesful, sets glConfig.nativeScreenWidth, glConfig.nativeScreenHeight, and glConfig.pixelAspect
|
||||||
|
|
|
@ -53,6 +53,25 @@ static SDL_Surface* window = NULL;
|
||||||
bool QGL_Init( const char* dllname );
|
bool QGL_Init( const char* dllname );
|
||||||
void QGL_Shutdown();
|
void QGL_Shutdown();
|
||||||
|
|
||||||
|
/*
|
||||||
|
===================
|
||||||
|
GLimp_PreInit
|
||||||
|
|
||||||
|
R_GetModeListForDisplay is called before GLimp_Init(), but SDL needs SDL_Init() first.
|
||||||
|
So do that in GLimp_PreInit()
|
||||||
|
Calling that function more than once doesn't make a difference
|
||||||
|
===================
|
||||||
|
*/
|
||||||
|
void GLimp_PreInit() // DG: added this function for SDL compatibility
|
||||||
|
{
|
||||||
|
if( !SDL_WasInit( SDL_INIT_VIDEO ) )
|
||||||
|
{
|
||||||
|
if( SDL_Init( SDL_INIT_VIDEO ) )
|
||||||
|
common->Error( "Error while initializing SDL: %s", SDL_GetError() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
GLimp_Init
|
GLimp_Init
|
||||||
|
@ -62,11 +81,7 @@ bool GLimp_Init( glimpParms_t parms )
|
||||||
{
|
{
|
||||||
common->Printf( "Initializing OpenGL subsystem\n" );
|
common->Printf( "Initializing OpenGL subsystem\n" );
|
||||||
|
|
||||||
if( !SDL_WasInit( SDL_INIT_VIDEO ) )
|
GLimp_PreInit(); // DG: make sure SDL is initialized
|
||||||
{
|
|
||||||
if( SDL_Init( SDL_INIT_VIDEO ) )
|
|
||||||
common->Error( "Error while initializing SDL: %s", SDL_GetError() );
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint32 flags = SDL_WINDOW_OPENGL;
|
Uint32 flags = SDL_WINDOW_OPENGL;
|
||||||
|
|
||||||
|
@ -378,6 +393,11 @@ bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>&
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
|
||||||
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
||||||
|
if( videoInfo == NULL )
|
||||||
|
{
|
||||||
|
// DG: yes, this can actually fail, e.g. if SDL_Init( SDL_INIT_VIDEO ) wasn't called
|
||||||
|
common->Error( "Can't get Video Info!\n" );
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Rect** modes = SDL_ListModes( videoInfo->vfmt, SDL_OPENGL | SDL_FULLSCREEN );
|
SDL_Rect** modes = SDL_ListModes( videoInfo->vfmt, SDL_OPENGL | SDL_FULLSCREEN );
|
||||||
|
|
||||||
|
|
|
@ -1253,6 +1253,10 @@ static bool GLW_ChangeDislaySettingsIfNeeded( glimpParms_t parms )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLimp_PreInit() {
|
||||||
|
// DG: not needed on this platform, so just do nothing
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
GLimp_Init
|
GLimp_Init
|
||||||
|
|
Loading…
Reference in a new issue