Config::Config() :
profile(1),
fullscreen_size(800, 600),
+ fullscreen_refresh_rate(0),
window_size(800, 600),
aspect_size(0, 0), // auto detect
magnification(0.0f),
config_video_lisp->get("fullscreen_width", fullscreen_size.width);
config_video_lisp->get("fullscreen_height", fullscreen_size.height);
+ config_video_lisp->get("fullscreen_refresh_rate", fullscreen_refresh_rate);
config_video_lisp->get("window_width", window_size.width);
config_video_lisp->get("window_height", window_size.height);
writer.write("fullscreen_width", fullscreen_size.width);
writer.write("fullscreen_height", fullscreen_size.height);
+ writer.write("fullscreen_refresh_rate", fullscreen_refresh_rate);
writer.write("window_width", window_size.width);
writer.write("window_height", window_size.height);
g_config->window_size = Size(800, 600);
g_config->fullscreen_size = Size(800, 600);
+ g_config->fullscreen_refresh_rate = 0;
g_config->aspect_size = Size(0, 0); // auto detect
} else if(arg == "--window" || arg == "-w") {
{
g_config->window_size = Size(width, height);
g_config->fullscreen_size = Size(width, height);
+ g_config->fullscreen_refresh_rate = 0;
}
}
} else if(arg == "--aspect" || arg == "-a") {
log_info << (g_config->use_fullscreen?"fullscreen ":"window ")
<< " Window: " << g_config->window_size
- << " Fullscreen: " << g_config->fullscreen_size
+ << " Fullscreen: " << g_config->fullscreen_size << "@" << g_config->fullscreen_refresh_rate
<< " Area: " << g_config->aspect_size << std::endl;
}
}
}
-
- for(int disp_mode_ctr = 0; disp_mode_ctr < SDL_GetNumDisplayModes(0); disp_mode_ctr++)
+ int display_mode_count = SDL_GetNumDisplayModes(0);
+ for(int i = 0; i < display_mode_count; ++i)
{
-#ifdef OLD_SDL1
- SDL_DisplayMode* current = NULL;
- int disp_retval = SDL_GetDisplayMode(0, // Display Index
- disp_mode_ctr, // Mode index (default to first)
- current); // DisplayMode structure ptr
- if (disp_retval == -1)
- { // No resolutions at all available, bad
- }
- else if(disp_retval == 0)
- { // All resolutions should work, so we fall back to hardcoded defaults
- std::stringstream width;
- std::stringstream height;
- width << current->w;
- height << current->h;
- fullscreen_res->list.push_back(width.str() + "x" + height.str());
+ SDL_DisplayMode mode;
+ int ret = SDL_GetDisplayMode(0, i, &mode);
+ if (ret != 0)
+ {
+ log_warning << "failed to get display mode: " << SDL_GetError() << std::endl;
}
else
{
+ std::ostringstream out;
+ out << mode.w << "x" << mode.h << "@" << mode.refresh_rate;
+ fullscreen_res->list.push_back(out.str());
}
-#endif
}
- // On Ubuntu/Linux resolutions are returned from highest to
- // lowest, so reverse them
- std::sort(fullscreen_res->list.begin(), fullscreen_res->list.end(), StringUtil::numeric_less);
-
+
std::ostringstream out;
- out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height;
+ out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height << "@" << g_config->fullscreen_refresh_rate;
std::string fllscrn_sz = out.str();
size_t cnt = 0;
for (std::vector<std::string>::iterator i = fullscreen_res->list.begin(); i != fullscreen_res->list.end(); ++i)
{
switch (item->id) {
case MNID_ASPECTRATIO:
- {
- if (item->list[item->selected] == _("auto"))
- {
- g_config->aspect_size = Size(0, 0); // Magic values
- Renderer::instance()->apply_config();
- MenuManager::recalc_pos();
- }
- else if (sscanf(item->list[item->selected].c_str(), "%d:%d",
- &g_config->aspect_size.width, &g_config->aspect_size.height) == 2)
- {
- Renderer::instance()->apply_config();
- MenuManager::recalc_pos();
- }
- else
{
- assert(!"This must not be reached");
+ if (item->list[item->selected] == _("auto"))
+ {
+ g_config->aspect_size = Size(0, 0); // Magic values
+ Renderer::instance()->apply_config();
+ MenuManager::recalc_pos();
+ }
+ else if (sscanf(item->list[item->selected].c_str(), "%d:%d",
+ &g_config->aspect_size.width, &g_config->aspect_size.height) == 2)
+ {
+ Renderer::instance()->apply_config();
+ MenuManager::recalc_pos();
+ }
+ else
+ {
+ assert(!"This must not be reached");
+ }
}
- }
- break;
+ break;
case MNID_MAGNIFICATION:
if (item->list[item->selected] == _("auto"))
break;
case MNID_FULLSCREEN_RESOLUTION:
- if(sscanf(item->list[item->selected].c_str(), "%dx%d",
- &g_config->fullscreen_size.width, &g_config->fullscreen_size.height) == 2)
{
- // do nothing, changes are only applied when toggling fullscreen mode
+ int width;
+ int height;
+ int refresh_rate;
+ if(sscanf(item->list[item->selected].c_str(), "%dx%d@%d",
+ &width, &height, &refresh_rate) == 3)
+ {
+ // do nothing, changes are only applied when toggling fullscreen mode
+ g_config->fullscreen_size.width = width;
+ g_config->fullscreen_size.height = height;
+ g_config->fullscreen_refresh_rate = refresh_rate;
+ }
}
break;
{
int fullscreen_flags = SDL_WINDOW_FULLSCREEN; // SDL_WINDOW_FULLSCREEN_DESKTOP or 0
SDL_SetWindowDisplayMode(window, NULL);
- SDL_SetWindowFullscreen(window, fullscreen_flags);
+
+ SDL_DisplayMode mode;
+ mode.format = SDL_PIXELFORMAT_RGB888;
+ mode.w = g_config->fullscreen_size.width;
+ mode.h = g_config->fullscreen_size.height;
+ mode.refresh_rate = g_config->fullscreen_refresh_rate;
+ mode.driverdata = 0;
+
+ if (SDL_SetWindowDisplayMode(window, &mode) != 0)
+ {
+ log_warning << "failed to set display mode: "
+ << mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
+ << SDL_GetError() << std::endl;
+ }
+ else
+ {
+ SDL_SetWindowFullscreen(window, fullscreen_flags);
+ }
}
else
{