1
0

Fix background image scaling in MainMenu

This commit is contained in:
Maksym H 2023-09-16 00:40:40 +03:00 committed by mckaygerhard
parent 575f130854
commit b116381d28

View File

@ -474,9 +474,15 @@ void GUIEngine::drawBackground(video::IVideoDriver *driver)
} }
/* Draw background texture */ /* Draw background texture */
float aspectRatioScreen = (float) screensize.X / screensize.Y;
float aspectRatioSource = (float) sourcesize.X / sourcesize.Y;
int sourceX = aspectRatioSource > aspectRatioScreen ? (sourcesize.X - sourcesize.Y * aspectRatioScreen) / 2 : 0;
int sourceY = aspectRatioSource < aspectRatioScreen ? (sourcesize.Y - sourcesize.X / aspectRatioScreen) / 2 : 0;
draw2DImageFilterScaled(driver, texture, draw2DImageFilterScaled(driver, texture,
core::rect<s32>(0, 0, screensize.X, screensize.Y), core::rect<s32>(0, 0, screensize.X, screensize.Y),
core::rect<s32>(0, 0, sourcesize.X, sourcesize.Y), core::rect<s32>(sourceX, sourceY, sourcesize.X - sourceX, sourcesize.Y - sourceY),
NULL, NULL, true); NULL, NULL, true);
} }