mirror of
https://github.com/minetest/minetest.git
synced 2024-12-27 16:37:30 +01:00
Chop game background in mainmenu (#10796)
This commit is contained in:
parent
4feb799b7e
commit
719a12ecac
Binary file not shown.
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 160 B |
@ -437,9 +437,22 @@ void GUIEngine::drawBackground(video::IVideoDriver *driver)
|
||||
return;
|
||||
}
|
||||
|
||||
// Chop background image to the smaller screen dimension
|
||||
v2u32 bg_size = screensize;
|
||||
v2f32 scale(
|
||||
(f32) bg_size.X / sourcesize.X,
|
||||
(f32) bg_size.Y / sourcesize.Y);
|
||||
if (scale.X < scale.Y)
|
||||
bg_size.X = (int) (scale.Y * sourcesize.X);
|
||||
else
|
||||
bg_size.Y = (int) (scale.X * sourcesize.Y);
|
||||
v2s32 offset = v2s32(
|
||||
(s32) screensize.X - (s32) bg_size.X,
|
||||
(s32) screensize.Y - (s32) bg_size.Y
|
||||
) / 2;
|
||||
/* Draw background texture */
|
||||
draw2DImageFilterScaled(driver, texture,
|
||||
core::rect<s32>(0, 0, screensize.X, screensize.Y),
|
||||
core::rect<s32>(offset.X, offset.Y, bg_size.X + offset.X, bg_size.Y + offset.Y),
|
||||
core::rect<s32>(0, 0, sourcesize.X, sourcesize.Y),
|
||||
NULL, NULL, true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user