Various improvements to SDL2 video code.

- Ported the missing resolutions from zdoom.
- Remove unneeded code which was removed also from zdoom.
- Uncomment DOUBLEBUFFER GL attribute. It was present in the old SDL_SetVideoMode call code, so why not.
This commit is contained in:
Edoardo Prezioso 2015-01-08 01:39:29 +01:00
parent 37321d1d48
commit cab509c4d2
2 changed files with 25 additions and 36 deletions

View file

@ -77,6 +77,7 @@ static MiniModeInfo WinModes[] =
{ 720, 480 }, // 16:10 { 720, 480 }, // 16:10
{ 720, 540 }, { 720, 540 },
{ 800, 450 }, // 16:9 { 800, 450 }, // 16:9
{ 800, 480 },
{ 800, 500 }, // 16:10 { 800, 500 }, // 16:10
{ 800, 600 }, { 800, 600 },
{ 848, 480 }, // 16:9 { 848, 480 }, // 16:9
@ -91,23 +92,33 @@ static MiniModeInfo WinModes[] =
{ 1152, 720 }, // 16:10 { 1152, 720 }, // 16:10
{ 1152, 864 }, { 1152, 864 },
{ 1280, 720 }, // 16:9 { 1280, 720 }, // 16:9
{ 1280, 854 },
{ 1280, 800 }, // 16:10 { 1280, 800 }, // 16:10
{ 1280, 960 }, { 1280, 960 },
{ 1344, 756 }, // 16:9 { 1280, 1024 }, // 5:4
{ 1360, 768 }, // 16:9 { 1360, 768 }, // 16:9
{ 1366, 768 },
{ 1400, 787 }, // 16:9 { 1400, 787 }, // 16:9
{ 1400, 875 }, // 16:10 { 1400, 875 }, // 16:10
{ 1440, 900 },
{ 1400, 1050 }, { 1400, 1050 },
{ 1440, 900 },
{ 1440, 960 },
{ 1440, 1080 },
{ 1600, 900 }, // 16:9 { 1600, 900 }, // 16:9
{ 1600, 1000 }, // 16:10 { 1600, 1000 }, // 16:10
{ 1600, 1200 }, { 1600, 1200 },
{ 1680, 1050 }, // 16:10 { 1920, 1080 },
{ 1920, 1080 }, // 16:9 { 1920, 1200 },
{ 1920, 1200 }, // 16:10 { 2048, 1536 },
{ 2054, 1536 }, { 2560, 1440 },
{ 2560, 1440 }, // 16:9 { 2560, 1600 },
{ 2880, 1800 } // 16:10 { 2560, 2048 },
{ 2880, 1800 },
{ 3200, 1800 },
{ 3840, 2160 },
{ 3840, 2400 },
{ 4096, 2160 },
{ 5120, 2880 }
}; };
// CODE -------------------------------------------------------------------- // CODE --------------------------------------------------------------------
@ -115,7 +126,6 @@ static MiniModeInfo WinModes[] =
SDLGLVideo::SDLGLVideo (int parm) SDLGLVideo::SDLGLVideo (int parm)
{ {
IteratorBits = 0; IteratorBits = 0;
IteratorFS = false;
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
fprintf( stderr, "Video initialization failed: %s\n", fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) ); SDL_GetError( ) );
@ -135,7 +145,6 @@ void SDLGLVideo::StartModeIterator (int bits, bool fs)
{ {
IteratorMode = 0; IteratorMode = 0;
IteratorBits = bits; IteratorBits = bits;
IteratorFS = fs;
} }
bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox) bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox)
@ -143,30 +152,11 @@ bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox)
if (IteratorBits != 8) if (IteratorBits != 8)
return false; return false;
if (!IteratorFS) if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0]))
{ {
if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0])) *width = WinModes[IteratorMode].Width;
{ *height = WinModes[IteratorMode].Height;
*width = WinModes[IteratorMode].Width; ++IteratorMode;
*height = WinModes[IteratorMode].Height;
++IteratorMode;
return true;
}
}
else
{
SDL_DisplayMode mode = {}, oldmode = {};
if(IteratorMode != 0)
SDL_GetDisplayMode(vid_adapter, IteratorMode-1, &oldmode);
do
{
if (SDL_GetDisplayMode(vid_adapter, IteratorMode, &mode) != 0)
return false;
++IteratorMode;
} while(mode.w == oldmode.w && mode.h == oldmode.h);
*width = mode.w;
*height = mode.h;
return true; return true;
} }
return false; return false;
@ -294,7 +284,7 @@ bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample)
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 );
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if (multisample > 0) { if (multisample > 0) {
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample );

View file

@ -32,7 +32,6 @@ class SDLGLVideo : public IVideo
private: private:
int IteratorMode; int IteratorMode;
int IteratorBits; int IteratorBits;
bool IteratorFS;
}; };
class SDLGLFB : public DFrameBuffer class SDLGLFB : public DFrameBuffer
{ {