From e25fd2e8c586cb5023d6e7888fbb9c48afd6e939 Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 3 May 2022 04:11:41 -0700 Subject: [PATCH] Cocoa Port: Restore the HUD visibility state of an OpenGL presenter if it ever needs to be reinitialized. --- desmume/src/frontend/cocoa/OGLDisplayOutput.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/desmume/src/frontend/cocoa/OGLDisplayOutput.cpp b/desmume/src/frontend/cocoa/OGLDisplayOutput.cpp index 5b0f53e95..e884ee704 100644 --- a/desmume/src/frontend/cocoa/OGLDisplayOutput.cpp +++ b/desmume/src/frontend/cocoa/OGLDisplayOutput.cpp @@ -5060,15 +5060,22 @@ void OGLVideoOutput::Init() this->_filtersPreferGPU = this->_canFilterOnGPU; this->_willFilterOnGPU = false; - for (size_t i = 0; i < _layerList->size(); i++) + std::vector wasPreviouslyVisibleList; + for (size_t i = 0; i < this->_layerList->size(); i++) { - delete (*_layerList)[i]; + wasPreviouslyVisibleList.push_back( (*this->_layerList)[i]->IsVisible() ); + delete (*this->_layerList)[i]; } this->_layerList->clear(); this->_layerList->push_back(new OGLDisplayLayer(this)); this->_layerList->push_back(new OGLHUDLayer(this)); + for (size_t i = 0; i < wasPreviouslyVisibleList.size(); i++) + { + (*this->_layerList)[i]->SetVisibility(wasPreviouslyVisibleList[i]); + } + // Render State Setup (common to both shaders and fixed-function pipeline) glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST);