From 2e8cca9ca18a7d4375bc1ae4be6dfedbba6c6d79 Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Mon, 4 Dec 2023 11:57:51 -0500 Subject: Initialize the framebuffers within the constructor (#1901) --- src/GPU.cpp | 7 ++++++- src/GPU.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/GPU.cpp b/src/GPU.cpp index c80e311..2c140a8 100644 --- a/src/GPU.cpp +++ b/src/GPU.cpp @@ -75,7 +75,7 @@ GPU::GPU(melonDS::NDS& nds, std::unique_ptr&& renderer3d, std::uniqu NDS.RegisterEventFunc(Event_LCD, LCD_FinishFrame, MemberEventFunc(GPU, FinishFrame)); NDS.RegisterEventFunc(Event_DisplayFIFO, 0, MemberEventFunc(GPU, DisplayFIFO)); - FrontBuffer = 0; + InitFramebuffers(); } GPU::~GPU() noexcept @@ -298,6 +298,11 @@ void GPU::SetRenderer3D(std::unique_ptr&& renderer) noexcept else GPU3D.SetCurrentRenderer(std::move(renderer)); + InitFramebuffers(); +} + +void GPU::InitFramebuffers() noexcept +{ int fbsize; if (GPU3D.IsRendererAccelerated()) fbsize = (256*3 + 1) * 192; diff --git a/src/GPU.h b/src/GPU.h index 21a05d5..ee7311a 100644 --- a/src/GPU.h +++ b/src/GPU.h @@ -607,6 +607,7 @@ public: private: void ResetVRAMCache() noexcept; void AssignFramebuffers() noexcept; + void InitFramebuffers() noexcept; template T ReadVRAM_ABGExtPal(u32 addr) const noexcept { -- cgit v1.2.3