Implement high dpi support in sdl2 properly

This commit is contained in:
Benau 2022-07-22 21:10:51 +08:00
parent ea69c36cb3
commit e991e06640
6 changed files with 148 additions and 122 deletions

View File

@ -26,6 +26,8 @@
#include "ge_vulkan_scene_manager.hpp"
#include "MoltenVK.h"
#include <SDL_vulkan.h>
extern bool GLContextDebugBit;
namespace irr
@ -57,9 +59,6 @@ extern "C" int Android_disablePadding();
namespace irr
{
float g_native_scale_x = 1.0f;
float g_native_scale_y = 1.0f;
//! constructor
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param),
@ -69,7 +68,8 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
TopPadding(0), BottomPadding(0), LeftPadding(0), RightPadding(0),
InitialOrientation(0), WindowHasFocus(false), WindowMinimized(false),
Resizable(false), AccelerometerIndex(-1), AccelerometerInstance(-1),
GyroscopeIndex(-1), GyroscopeInstance(-1)
GyroscopeIndex(-1), GyroscopeInstance(-1), NativeScaleX(1.0f),
NativeScaleY(1.0f)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceSDL");
@ -155,33 +155,12 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
}
else
return;
updateNativeScale();
Width = (u32)((f32)Width * NativeScaleX);
Height = (u32)((f32)Height * NativeScaleY);
CreationParams.WindowSize.Width = Width;
CreationParams.WindowSize.Height = Height;
}
#if !defined(ANDROID) && !defined(__SWITCH__)
else if (!GUIEngine::isNoGraphics())
{
// Get highdpi native scale using renderer so it will work with any
// backend later (opengl or vulkan)
// Android doesn't use high dpi
SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;
if (SDL_CreateWindowAndRenderer(640, 480,
SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN,
&window, &renderer) == 0)
{
int w, h, rw, rh;
w = h = rw = rh = 0;
SDL_GetWindowSize(window, &w, &h);
SDL_GetRendererOutputSize(renderer, &rw, &rh);
if (w != 0 && h != 0 && rw != 0 && rh != 0)
{
g_native_scale_x = (float)rw / (float)w;
g_native_scale_y = (float)rh / (float)h;
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
}
}
#endif
// create cursor control
CursorControl = new CCursorControl(this);
@ -202,6 +181,26 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
}
void CIrrDeviceSDL::updateNativeScale()
{
int width, height = 0;
SDL_GetWindowSize(Window, &width, &height);
int real_width = width;
int real_height = height;
if (CreationParams.DriverType == video::EDT_OPENGL ||
CreationParams.DriverType == video::EDT_OGLES2)
{
SDL_GL_GetDrawableSize(Window, &real_width, &real_height);
}
else if (CreationParams.DriverType == video::EDT_VULKAN)
{
SDL_Vulkan_GetDrawableSize(Window, &real_width, &real_height);
}
NativeScaleX = (f32)real_width / (f32)width;
NativeScaleY = (f32)real_height / (f32)height;
}
//! destructor
CIrrDeviceSDL::~CIrrDeviceSDL()
{
@ -386,7 +385,14 @@ bool CIrrDeviceSDL::createWindow()
}
}
u32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI;
u32 flags = SDL_WINDOW_SHOWN;
#if !defined(ANDROID) && !defined(__SWITCH__)
if (CreationParams.DriverType == video::EDT_OPENGL ||
CreationParams.DriverType == video::EDT_OGLES2 ||
CreationParams.DriverType == video::EDT_VULKAN)
flags |= SDL_WINDOW_ALLOW_HIGHDPI;
#endif
if (CreationParams.Fullscreen)
flags |= SDL_WINDOW_FULLSCREEN;
@ -427,10 +433,10 @@ bool CIrrDeviceSDL::createWindow()
else
{
Window = SDL_CreateWindow("",
(float)CreationParams.WindowPosition.X / g_native_scale_x,
(float)CreationParams.WindowPosition.Y / g_native_scale_y,
(float)CreationParams.WindowSize.Width / g_native_scale_x,
(float)CreationParams.WindowSize.Height / g_native_scale_y, flags);
(float)CreationParams.WindowPosition.X,
(float)CreationParams.WindowPosition.Y,
(float)CreationParams.WindowSize.Width,
(float)CreationParams.WindowSize.Height, flags);
if (!Window)
{
os::Printer::log( "Could not initialize display!" );
@ -477,10 +483,10 @@ start:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
Window = SDL_CreateWindow("",
(float)CreationParams.WindowPosition.X / g_native_scale_x,
(float)CreationParams.WindowPosition.Y / g_native_scale_y,
(float)CreationParams.WindowSize.Width / g_native_scale_x,
(float)CreationParams.WindowSize.Height / g_native_scale_y, flags);
(float)CreationParams.WindowPosition.X,
(float)CreationParams.WindowPosition.Y,
(float)CreationParams.WindowSize.Width,
(float)CreationParams.WindowSize.Height, flags);
if (Window)
{
Context = SDL_GL_CreateContext(Window);
@ -503,10 +509,10 @@ start:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
Window = SDL_CreateWindow("",
(float)CreationParams.WindowPosition.X / g_native_scale_x,
(float)CreationParams.WindowPosition.Y / g_native_scale_y,
(float)CreationParams.WindowSize.Width / g_native_scale_x,
(float)CreationParams.WindowSize.Height / g_native_scale_y, flags);
(float)CreationParams.WindowPosition.X,
(float)CreationParams.WindowPosition.Y,
(float)CreationParams.WindowSize.Width,
(float)CreationParams.WindowSize.Height, flags);
if (Window)
{
Context = SDL_GL_CreateContext(Window);
@ -528,10 +534,10 @@ start:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
Window = SDL_CreateWindow("",
(float)CreationParams.WindowPosition.X / g_native_scale_x,
(float)CreationParams.WindowPosition.Y / g_native_scale_y,
(float)CreationParams.WindowSize.Width / g_native_scale_x,
(float)CreationParams.WindowSize.Height / g_native_scale_y, flags);
(float)CreationParams.WindowPosition.X,
(float)CreationParams.WindowPosition.Y,
(float)CreationParams.WindowSize.Width,
(float)CreationParams.WindowSize.Height, flags);
if (Window)
{
Context = SDL_GL_CreateContext(Window);
@ -553,10 +559,10 @@ start:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
Window = SDL_CreateWindow("",
(float)CreationParams.WindowPosition.X / g_native_scale_x,
(float)CreationParams.WindowPosition.Y / g_native_scale_y,
(float)CreationParams.WindowSize.Width / g_native_scale_x,
(float)CreationParams.WindowSize.Height / g_native_scale_y, flags);
(float)CreationParams.WindowPosition.X,
(float)CreationParams.WindowPosition.Y,
(float)CreationParams.WindowSize.Width,
(float)CreationParams.WindowSize.Height, flags);
if (Window)
{
Context = SDL_GL_CreateContext(Window);
@ -590,10 +596,10 @@ legacy:
else
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0);
Window = SDL_CreateWindow("",
(float)CreationParams.WindowPosition.X / g_native_scale_x,
(float)CreationParams.WindowPosition.Y / g_native_scale_y,
(float)CreationParams.WindowSize.Width / g_native_scale_x,
(float)CreationParams.WindowSize.Height / g_native_scale_y, flags);
(float)CreationParams.WindowPosition.X,
(float)CreationParams.WindowPosition.Y,
(float)CreationParams.WindowSize.Width,
(float)CreationParams.WindowSize.Height, flags);
if (Window)
{
Context = SDL_GL_CreateContext(Window);
@ -644,6 +650,10 @@ void CIrrDeviceSDL::createDriver()
try
{
VideoDriver = video::createVulkanDriver(CreationParams, FileSystem, Window, this);
// SDL_Vulkan_GetDrawableSize only works after driver is created
updateNativeScale();
Width = (u32)((f32)Width * NativeScaleX);
Height = (u32)((f32)Height * NativeScaleY);
}
catch (std::exception& e)
{
@ -782,8 +792,8 @@ bool CIrrDeviceSDL::run()
case SDL_MOUSEMOTION:
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
MouseX = irrevent.MouseInput.X = SDL_event.motion.x * g_native_scale_x;
MouseY = irrevent.MouseInput.Y = SDL_event.motion.y * g_native_scale_y;
MouseX = irrevent.MouseInput.X = SDL_event.motion.x * NativeScaleX;
MouseY = irrevent.MouseInput.Y = SDL_event.motion.y * NativeScaleY;
irrevent.MouseInput.ButtonStates = MouseButtonStates;
postEventFromUser(irrevent);
@ -793,8 +803,8 @@ bool CIrrDeviceSDL::run()
case SDL_MOUSEBUTTONUP:
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.X = SDL_event.button.x * g_native_scale_x;
irrevent.MouseInput.Y = SDL_event.button.y * g_native_scale_y;
irrevent.MouseInput.X = SDL_event.button.x * NativeScaleX;
irrevent.MouseInput.Y = SDL_event.button.y * NativeScaleY;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
@ -900,16 +910,19 @@ bool CIrrDeviceSDL::run()
case SDL_WINDOWEVENT:
{
u32 new_width = SDL_event.window.data1 * g_native_scale_x;
u32 new_height = SDL_event.window.data2 * g_native_scale_y;
if (SDL_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED &&
((new_width != Width) || (new_height != Height)))
if (SDL_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{
Width = new_width;
Height = new_height;
if (VideoDriver)
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
reset_network_body();
updateNativeScale();
u32 new_width = SDL_event.window.data1 * NativeScaleX;
u32 new_height = SDL_event.window.data2 * NativeScaleY;
if (new_width != Width || new_height != Height)
{
Width = new_width;
Height = new_height;
if (VideoDriver)
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
reset_network_body();
}
}
else if (SDL_event.window.event == SDL_WINDOWEVENT_MINIMIZED)
{
@ -1050,20 +1063,20 @@ video::IVideoModeList* CIrrDeviceSDL::getVideoModeList()
if (SDL_GetDesktopDisplayMode(0, &mode) == 0)
{
VideoModeList.setDesktop(SDL_BITSPERPIXEL(mode.format),
core::dimension2d<u32>(mode.w * g_native_scale_x, mode.h * g_native_scale_y));
core::dimension2d<u32>(mode.w, mode.h));
}
#ifdef MOBILE_STK
// SDL2 will return w,h and h,w for mobile STK, as we only use landscape
// so we just use desktop resolution for now
VideoModeList.addMode(core::dimension2d<u32>(mode.w * g_native_scale_x, mode.h * g_native_scale_y),
VideoModeList.addMode(core::dimension2d<u32>(mode.w, mode.h),
SDL_BITSPERPIXEL(mode.format));
#else
for (int i = 0; i < mode_count; i++)
{
if (SDL_GetDisplayMode(0, i, &mode) == 0)
{
VideoModeList.addMode(core::dimension2d<u32>(mode.w * g_native_scale_x, mode.h * g_native_scale_y),
VideoModeList.addMode(core::dimension2d<u32>(mode.w, mode.h),
SDL_BITSPERPIXEL(mode.format));
}
}
@ -1498,7 +1511,7 @@ extern "C" int Android_getMovedHeight();
s32 CIrrDeviceSDL::getMovedHeight() const
{
#if defined(IOS_STK)
return SDL_GetMovedHeightByScreenKeyboard() * g_native_scale_y;
return SDL_GetMovedHeightByScreenKeyboard() * NativeScaleY;
#elif defined(ANDROID)
return Android_getMovedHeight();
#else
@ -1511,7 +1524,7 @@ extern "C" int Android_getKeyboardHeight();
u32 CIrrDeviceSDL::getOnScreenKeyboardHeight() const
{
#if defined(IOS_STK)
return SDL_GetScreenKeyboardHeight() * g_native_scale_y;
return SDL_GetScreenKeyboardHeight() * NativeScaleY;
#elif defined(ANDROID)
return Android_getKeyboardHeight();
#else
@ -1522,13 +1535,13 @@ u32 CIrrDeviceSDL::getOnScreenKeyboardHeight() const
f32 CIrrDeviceSDL::getNativeScaleX() const
{
return g_native_scale_x;
return NativeScaleX;
}
f32 CIrrDeviceSDL::getNativeScaleY() const
{
return g_native_scale_y;
return NativeScaleY;
}

View File

@ -303,6 +303,8 @@ class MoltenVK;
s32 GyroscopeIndex;
s32 GyroscopeInstance;
f32 NativeScaleX, NativeScaleY;
struct SKeyMap
{
SKeyMap() {}
@ -328,6 +330,7 @@ class MoltenVK;
MoltenVK* m_moltenvk;
#endif
void createGUIAndVulkanScene();
void updateNativeScale();
};
} // end namespace irr

View File

@ -611,21 +611,27 @@ namespace UserConfigParams
PARAM_PREFIX GroupUserConfigParam m_video_group
PARAM_DEFAULT( GroupUserConfigParam("Video", "Video Settings") );
PARAM_PREFIX IntUserConfigParam m_real_width
PARAM_DEFAULT( IntUserConfigParam(1024, "real_width", &m_video_group,
"Screen/window real width in pixels before high dpi is applied") );
PARAM_PREFIX IntUserConfigParam m_real_height
PARAM_DEFAULT( IntUserConfigParam(768, "real_height", &m_video_group,
"Screen/window real height in pixels before high dpi is applied") );
PARAM_PREFIX IntUserConfigParam m_width
PARAM_DEFAULT( IntUserConfigParam(1024, "width", &m_video_group,
"Screen/window width in pixels") );
"Screen/window width in pixels, this value should not be edited") );
PARAM_PREFIX IntUserConfigParam m_height
PARAM_DEFAULT( IntUserConfigParam(768, "height", &m_video_group,
"Screen/window height in pixels") );
"Screen/window height in pixels, this value should not be edited") );
PARAM_PREFIX BoolUserConfigParam m_fullscreen
PARAM_DEFAULT( BoolUserConfigParam(false, "fullscreen",
&m_video_group) );
PARAM_PREFIX IntUserConfigParam m_prev_width
PARAM_DEFAULT( IntUserConfigParam(1024, "prev_width",
&m_video_group, "Previous screen/window width") );
PARAM_PREFIX IntUserConfigParam m_prev_height
PARAM_DEFAULT( IntUserConfigParam(768, "prev_height",
&m_video_group,"Previous screen/window height") );
PARAM_PREFIX IntUserConfigParam m_prev_real_width
PARAM_DEFAULT( IntUserConfigParam(1024, "prev_real_width",
&m_video_group, "Previous real screen/window width") );
PARAM_PREFIX IntUserConfigParam m_prev_real_height
PARAM_DEFAULT( IntUserConfigParam(768, "prev_real_height",
&m_video_group,"Previous real screen/window height") );
PARAM_PREFIX BoolUserConfigParam m_prev_fullscreen
PARAM_DEFAULT( BoolUserConfigParam(false, "prev_fullscreen",
&m_video_group) );

View File

@ -453,13 +453,13 @@ void IrrDriver::initDevice()
{
Log::warn("irr_driver", "Unknown desktop resolution.");
}
else if (UserConfigParams::m_width > (int)ssize.Width ||
UserConfigParams::m_height > (int)ssize.Height)
else if (UserConfigParams::m_real_width > (int)ssize.Width ||
UserConfigParams::m_real_height > (int)ssize.Height)
{
Log::warn("irr_driver", "The window size specified in "
"user config is larger than your screen!");
UserConfigParams::m_width = (int)ssize.Width;
UserConfigParams::m_height = (int)ssize.Height;
UserConfigParams::m_real_width = (int)ssize.Width;
UserConfigParams::m_real_height = (int)ssize.Height;
}
if (UserConfigParams::m_fullscreen)
@ -467,12 +467,12 @@ void IrrDriver::initDevice()
if (modes->getVideoModeCount() > 0)
{
core::dimension2d<u32> res = core::dimension2du(
UserConfigParams::m_width,
UserConfigParams::m_height);
UserConfigParams::m_real_width,
UserConfigParams::m_real_height);
res = modes->getVideoModeResolution(res, res);
UserConfigParams::m_width = res.Width;
UserConfigParams::m_height = res.Height;
UserConfigParams::m_real_width = res.Width;
UserConfigParams::m_real_height = res.Height;
}
else
{
@ -482,12 +482,12 @@ void IrrDriver::initDevice()
}
}
if (UserConfigParams::m_width < 1 || UserConfigParams::m_height < 1)
if (UserConfigParams::m_real_width < 1 || UserConfigParams::m_real_height < 1)
{
Log::warn("irr_driver", "Invalid window size. "
"Try to use the default one.");
UserConfigParams::m_width = MIN_SUPPORTED_WIDTH;
UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT;
UserConfigParams::m_real_width = MIN_SUPPORTED_WIDTH;
UserConfigParams::m_real_height = MIN_SUPPORTED_HEIGHT;
}
m_device->closeDevice();
@ -528,8 +528,8 @@ void IrrDriver::initDevice()
params.SwapInterval = UserConfigParams::m_swap_interval;
params.FileSystem = file_manager->getFileSystem();
params.WindowSize =
core::dimension2du(UserConfigParams::m_width,
UserConfigParams::m_height);
core::dimension2du(UserConfigParams::m_real_width,
UserConfigParams::m_real_height);
params.HandleSRGB = false;
params.ShadersPath = (file_manager->getShadersDir() +
"irrlicht/").c_str();
@ -575,11 +575,11 @@ void IrrDriver::initDevice()
// size is the problem
if(!m_device)
{
UserConfigParams::m_width = MIN_SUPPORTED_WIDTH;
UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT;
UserConfigParams::m_real_width = MIN_SUPPORTED_WIDTH;
UserConfigParams::m_real_height = MIN_SUPPORTED_HEIGHT;
m_device = createDevice(driver_created,
core::dimension2du(UserConfigParams::m_width,
UserConfigParams::m_height ),
core::dimension2du(UserConfigParams::m_real_width,
UserConfigParams::m_real_height ),
32, //bits per pixel
UserConfigParams::m_fullscreen,
false, // stencil buffers
@ -600,6 +600,9 @@ void IrrDriver::initDevice()
{
Log::fatal("irr_driver", "Couldn't initialise irrlicht device. Quitting.\n");
}
UserConfigParams::m_width = (unsigned)((float)UserConfigParams::m_real_width * m_device->getNativeScaleX());
UserConfigParams::m_height = (unsigned)((float)UserConfigParams::m_real_height * m_device->getNativeScaleY());
#ifndef SERVER_ONLY
GE::setVideoDriver(m_device->getVideoDriver());
@ -958,12 +961,12 @@ void IrrDriver::changeResolution(const int w, const int h,
const bool fullscreen)
{
// update user config values
UserConfigParams::m_prev_width = UserConfigParams::m_width;
UserConfigParams::m_prev_height = UserConfigParams::m_height;
UserConfigParams::m_prev_real_width = UserConfigParams::m_real_width;
UserConfigParams::m_prev_real_height = UserConfigParams::m_real_height;
UserConfigParams::m_prev_fullscreen = UserConfigParams::m_fullscreen;
UserConfigParams::m_width = w;
UserConfigParams::m_height = h;
UserConfigParams::m_real_width = w;
UserConfigParams::m_real_height = h;
UserConfigParams::m_fullscreen = fullscreen;
// Setting this flag will trigger a call to applyResolutionSetting()
@ -987,10 +990,9 @@ void IrrDriver::applyResolutionSettings(bool recreate_device)
if (recreate_device)
{
m_video_driver->beginScene(true, true, video::SColor(255,100,101,140));
GL32_draw2DRectangle( video::SColor(255, 0, 0, 0),
core::rect<s32>(0, 0,
UserConfigParams::m_prev_width,
UserConfigParams::m_prev_height) );
GL32_draw2DRectangle( video::SColor(255, 0, 0, 0), core::rect<s32>(0, 0,
s32(m_device->getNativeScaleX() * (float)UserConfigParams::m_prev_real_width),
s32(m_device->getNativeScaleY() * (float)UserConfigParams::m_prev_real_height)) );
m_video_driver->endScene();
}
track_manager->removeAllCachedData();
@ -1119,8 +1121,8 @@ void IrrDriver::applyResolutionSettings(bool recreate_device)
void IrrDriver::cancelResChange()
{
UserConfigParams::m_width = UserConfigParams::m_prev_width;
UserConfigParams::m_height = UserConfigParams::m_prev_height;
UserConfigParams::m_real_width = UserConfigParams::m_prev_real_width;
UserConfigParams::m_real_height = UserConfigParams::m_prev_real_height;
UserConfigParams::m_fullscreen = UserConfigParams::m_prev_fullscreen;
// This will trigger calling applyResolutionSettings in update(). This is
@ -2025,6 +2027,8 @@ void IrrDriver::handleWindowResize()
m_actual_screen_size = m_video_driver->getCurrentRenderTargetSize();
UserConfigParams::m_width = m_actual_screen_size.Width;
UserConfigParams::m_height = m_actual_screen_size.Height;
UserConfigParams::m_real_width = (unsigned)((float)m_actual_screen_size.Width / m_device->getNativeScaleX());
UserConfigParams::m_real_height = (unsigned)((float)m_actual_screen_size.Height / m_device->getNativeScaleY());
resizeWindow();
}
// In case reset by opening options in game

View File

@ -867,13 +867,13 @@ int handleCmdLinePreliminary()
UserConfigParams::m_blacklist_res.end(),res) ==
UserConfigParams::m_blacklist_res.end())
{
UserConfigParams::m_prev_width =
UserConfigParams::m_width = width;
UserConfigParams::m_prev_height =
UserConfigParams::m_height = height;
UserConfigParams::m_prev_real_width =
UserConfigParams::m_real_width = width;
UserConfigParams::m_prev_real_height =
UserConfigParams::m_real_height = height;
Log::verbose("main", "You choose to use %dx%d.",
(int)UserConfigParams::m_width,
(int)UserConfigParams::m_height );
(int)UserConfigParams::m_real_width,
(int)UserConfigParams::m_real_height );
}
else
Log::warn("main", "Resolution %s has been blacklisted, so "

View File

@ -326,8 +326,8 @@ void OptionsScreenVideo::init()
r.fullscreen = true;
m_resolutions.push_back(r);
if (r.width == UserConfigParams::m_width &&
r.height == UserConfigParams::m_height)
if (r.width == UserConfigParams::m_real_width &&
r.height == UserConfigParams::m_real_height)
{
found_config_res = true;
}
@ -344,8 +344,8 @@ void OptionsScreenVideo::init()
if (!found_config_res)
{
r.width = UserConfigParams::m_width;
r.height = UserConfigParams::m_height;
r.width = UserConfigParams::m_real_width;
r.height = UserConfigParams::m_real_height;
r.fullscreen = false;
m_resolutions.push_back(r);
@ -418,8 +418,8 @@ void OptionsScreenVideo::init()
// ---- select current resolution every time
char searching_for[32];
snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_width,
(int)UserConfigParams::m_height);
snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_real_width,
(int)UserConfigParams::m_real_height);
if (!res->setSelection(searching_for, PLAYER_ID_GAME_MASTER,