aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2021-09-14 20:46:02 +0200
committerGitHub <noreply@github.com>2021-09-14 20:46:02 +0200
commit719a12ecac1c5363612e0c230eae411bdb3fe058 (patch)
treeec8df160abd3ddd473c4987cfae9ec6142285771 /src/gui
parent4feb799b7e33c1a544036a830faf00eb33d3eaf5 (diff)
downloadminetest-719a12ecac1c5363612e0c230eae411bdb3fe058.tar.gz
minetest-719a12ecac1c5363612e0c230eae411bdb3fe058.tar.bz2
minetest-719a12ecac1c5363612e0c230eae411bdb3fe058.zip
Chop game background in mainmenu (#10796)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/guiEngine.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp
index b3808535c..c39c3ee0d 100644
--- a/src/gui/guiEngine.cpp
+++ b/src/gui/guiEngine.cpp
@@ -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);
}