mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-02 07:21:52 +00:00
R_GetModeListForDisplay() for SDL2
This commit is contained in:
parent
dd987814f7
commit
f3c4948b2f
1 changed files with 62 additions and 5 deletions
|
@ -447,14 +447,71 @@ R_GetModeListForDisplay
|
||||||
*/
|
*/
|
||||||
bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>& modeList )
|
bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>& modeList )
|
||||||
{
|
{
|
||||||
|
assert( requestedDisplayNum >= 0 );
|
||||||
|
|
||||||
modeList.Clear();
|
modeList.Clear();
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
// RB: TODO didn't find SDL_ListModes API
|
// DG: SDL2 implementation
|
||||||
FillStaticVidModes( modeList );
|
if( requestedDisplayNum >= SDL_GetNumVideoDisplays() )
|
||||||
return true;
|
{
|
||||||
|
// requested invalid displaynum
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
int numModes = SDL_GetNumDisplayModes( requestedDisplayNum );
|
||||||
|
if( numModes > 1 )
|
||||||
|
{
|
||||||
|
for( int i = 0; i < numModes; i++ )
|
||||||
|
{
|
||||||
|
SDL_DisplayMode m;
|
||||||
|
int ret = SDL_GetDisplayMode( requestedDisplayNum, i, &m );
|
||||||
|
if( ret != 0 )
|
||||||
|
{
|
||||||
|
common->Warning( "Can't get video mode no %i, because of %s\n", i, SDL_GetError() );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
vidMode_t mode;
|
||||||
|
mode.width = m.w;
|
||||||
|
mode.height = m.h;
|
||||||
|
mode.displayHz = m.refresh_rate ? m.refresh_rate : 60; // default to 60 if unknown (0)
|
||||||
|
modeList.AddUnique( mode );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( modeList.Num() < 1 )
|
||||||
|
{
|
||||||
|
common->Warning( "Couldn't get information for a single video mode, using default ones..!\n" );
|
||||||
|
FillStaticVidModes( modeList );
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort with lowest resolution first
|
||||||
|
modeList.SortWithTemplate( idSort_VidMode() );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
common->Warning( "Can't get Video Info!\n" );
|
||||||
|
if( numModes < 0 )
|
||||||
|
{
|
||||||
|
common->Warning( "Reason was: %s\n", SDL_GetError() );
|
||||||
|
}
|
||||||
|
FillStaticVidModes( modeList );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
// DG end
|
||||||
|
|
||||||
|
#else // SDL 1
|
||||||
|
|
||||||
|
// DG: SDL1 only knows of one display - some functions rely on
|
||||||
|
// R_GetModeListForDisplay() returning false for invalid displaynum to iterate all displays
|
||||||
|
if( requestedDisplayNum >= 1 )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// DG end
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue