From 670eaf346abb6af03dec8350b2829889db825103 Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Mon, 14 Oct 2024 23:51:49 -0700 Subject: [PATCH] Allocate melonDS's video buffer according to effective gl scaling resolves #4090 --- .../Consoles/Nintendo/NDS/MelonDS.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs index 0346f06d39..8345af8670 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs @@ -76,8 +76,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS { DefaultWidth = 256, DefaultHeight = 384, - MaxWidth = (256 * 16) * 3 + ((128 * 16) * 4 / 3) + 1, - MaxHeight = (384 / 2 * 16) * 2 + (128 * 16), + MaxWidth = 256 * 3 + (128 * 4 / 3) + 1, + MaxHeight = (384 / 2) * 2 + 128, MaxSamples = 4096, // rather large max samples is intentional, see comment in ThreadStartCallback DefaultFpsNumerator = 33513982, DefaultFpsDenominator = 560190, @@ -136,6 +136,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS else { _glContext = _openGLProvider.RequestGLContext(majorGlVersion, minorGlVersion, true); + // update buffer width/height for scaling + if (_activeSyncSettings.GLScaleFactor > 1) + { + BufferWidth = (256 * _activeSyncSettings.GLScaleFactor) * 3 + ((128 * _activeSyncSettings.GLScaleFactor) * 4 / 3) + 1; + BufferHeight = (384 / 2 * _activeSyncSettings.GLScaleFactor) * 2 + (128 * _activeSyncSettings.GLScaleFactor); + _videoBuffer = new int[BufferWidth * BufferHeight]; + } } }