Make sure that window size is larger than 0

This commit is contained in:
deve 2015-05-04 11:09:53 +02:00
parent 6082a4502b
commit f019f8622c

View File

@ -349,8 +349,13 @@ void IrrDriver::initDevice()
video::IVideoModeList* modes = m_device->getVideoModeList();
const core::dimension2d<u32> ssize = modes->getDesktopResolution();
if (UserConfigParams::m_width > (int)ssize.Width ||
UserConfigParams::m_height > (int)ssize.Height)
if (ssize.Width < 1 || ssize.Height < 1)
{
Log::warn("irr_driver", "Unknown desktop resolution.");
}
else if (UserConfigParams::m_width > (int)ssize.Width ||
UserConfigParams::m_height > (int)ssize.Height)
{
Log::warn("irr_driver", "The window size specified in "
"user config is larger than your screen!");
@ -358,13 +363,13 @@ void IrrDriver::initDevice()
UserConfigParams::m_height = (int)ssize.Height;
}
core::dimension2d<u32> res = core::dimension2du(UserConfigParams::m_width,
UserConfigParams::m_height);
if (UserConfigParams::m_fullscreen)
{
if (modes->getVideoModeCount() > 0)
{
core::dimension2d<u32> res = core::dimension2du(
UserConfigParams::m_width,
UserConfigParams::m_height);
res = modes->getVideoModeResolution(res, res);
UserConfigParams::m_width = res.Width;
@ -372,13 +377,20 @@ void IrrDriver::initDevice()
}
else
{
Log::verbose("irr_driver", "Cannot get information about "
"resolutions. Try to use the default one.");
UserConfigParams::m_width = MIN_SUPPORTED_WIDTH;
UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT;
Log::warn("irr_driver", "Cannot get information about "
"resolutions. Disable fullscreen.");
UserConfigParams::m_fullscreen = false;
}
}
if (UserConfigParams::m_width < 1 || UserConfigParams::m_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;
}
m_device->closeDevice();
m_video_driver = NULL;
m_gui_env = NULL;