sdl: dynamically set fullscreen resolution when SDL.[x/y]Resolution is set to 0

sdl: new default values for SDL.[X/Y]Resolution to dynamically set fullscreen resolution
This commit is contained in:
punkrockguy318 2013-03-02 19:46:34 +00:00
parent 517ad65bdc
commit ed03db8497
3 changed files with 47 additions and 16 deletions

View File

@ -156,20 +156,14 @@ InitConfig()
config->addOption("slstart", "SDL.ScanLineStart", 0);
config->addOption("slend", "SDL.ScanLineEnd", 239);
const SDL_VideoInfo* vid_info = SDL_GetVideoInfo();
// video controls
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
// if we can detect the screen resolultion, use that for the default fullscreen res
if(vid_info != NULL)
{
config->addOption('x', "xres", "SDL.XResolution", vid_info->current_w);
config->addOption('y', "yres", "SDL.YResolution", vid_info->current_h);
}
else
{
config->addOption('x', "xres", "SDL.XResolution", 512);
config->addOption('y', "yres", "SDL.YResolution", 448);
}
// set x/y res to 0 for automatic fullscreen resolution detection (no change)
config->addOption('x', "xres", "SDL.XResolution", 0);
config->addOption('y', "yres", "SDL.YResolution", 0);
config->addOption("SDL.LastXRes", 0);
config->addOption("SDL.LastYRes", 0);
config->addOption('b', "bpp", "SDL.BitsPerPixel", 32);
config->addOption("doublebuf", "SDL.DoubleBuffering", 0);
config->addOption("autoscale", "SDL.AutoScale", 1);

View File

@ -170,8 +170,8 @@ InitVideo(FCEUGI *gi)
g_config->getOption("SDL.SpecialFilter", &s_sponge);
g_config->getOption("SDL.XStretch", &xstretch);
g_config->getOption("SDL.YStretch", &ystretch);
g_config->getOption("SDL.XResolution", &xres);
g_config->getOption("SDL.YResolution", &yres);
g_config->getOption("SDL.LastXRes", &xres);
g_config->getOption("SDL.LastYRes", &yres);
g_config->getOption("SDL.ClipSides", &s_clipSides);
g_config->getOption("SDL.NoFrame", &noframe);
g_config->getOption("SDL.ShowFPS", &show_fps);
@ -179,7 +179,9 @@ InitVideo(FCEUGI *gi)
// check the starting, ending, and total scan lines
FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline);
s_tlines = s_erendline - s_srendline + 1;
// check if we should auto-set x/y resolution
// check for OpenGL and set the global flags
#if OPENGL
if(s_useOpenGL && !s_sponge) {

View File

@ -615,9 +615,44 @@ int main(int argc, char *argv[])
SDL_Quit();
return 0;
}
// If x/y res set to 0, store current display res in SDL.LastX/YRes
int yres, xres;
g_config->getOption("SDL.XResolution", &xres);
g_config->getOption("SDL.YResolution", &yres);
const SDL_VideoInfo* vid_info = SDL_GetVideoInfo();
if(xres == 0)
{
if(vid_info != NULL)
{
g_config->setOption("SDL.LastXRes", vid_info->current_w);
}
else
{
g_config->setOption("SDL.LastXRes", 512);
}
}
else
{
g_config->setOption("SDL.LastXRes", xres);
}
if(yres == 0)
{
if(vid_info != NULL)
{
g_config->setOption("SDL.LastYRes", vid_info->current_h);
}
else
{
g_config->setOption("SDL.LastYRes", 448);
}
}
else
{
g_config->setOption("SDL.LastYRes", yres);
}
int autoResume;
g_config->getOption("SDL.AutoResume", &autoResume);
if(autoResume)
{