From 83cf09db1a0da422ccef80aab179368e2aec69d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Fri, 29 Jan 2016 03:56:17 +0100 Subject: [PATCH] GL: Replace CStdGLCtx::Reinitialize with parameter to Clear() --- src/graphics/C4DrawGL.h | 4 +--- src/graphics/C4DrawGLCtx.cpp | 24 ++++++++++-------------- src/graphics/C4DrawGLMac.mm | 2 +- src/gui/C4StartupOptionsDlg.cpp | 2 +- src/platform/C4WindowWin32.cpp | 1 - 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/graphics/C4DrawGL.h b/src/graphics/C4DrawGL.h index 4062ae70d..a18ff4acc 100644 --- a/src/graphics/C4DrawGL.h +++ b/src/graphics/C4DrawGL.h @@ -107,7 +107,7 @@ public: CStdGLCtx(); // ctor ~CStdGLCtx() { Clear(); } // dtor - void Clear(); // clear objects + void Clear(bool multisample_change = false); // clear objects #ifdef USE_WIN32_WINDOWS std::vector EnumerateMultiSamples() const; @@ -119,8 +119,6 @@ public: bool PageFlip(); // present scene - static void Reinitialize(); - protected: void SelectCommon(); // this handles are declared as pointers to structs diff --git a/src/graphics/C4DrawGLCtx.cpp b/src/graphics/C4DrawGLCtx.cpp index 11ffeeb35..e7918a2ed 100644 --- a/src/graphics/C4DrawGLCtx.cpp +++ b/src/graphics/C4DrawGLCtx.cpp @@ -55,17 +55,6 @@ void CStdGLCtx::SelectCommon() } } -void CStdGLCtx::Reinitialize() -{ - assert(!pGL->pCurrCtx); -#ifdef USE_WIN32_WINDOWS - if (hrc) - wglDeleteContext(hrc); - hrc = 0; -#endif -} - - #ifdef USE_WIN32_WINDOWS #include @@ -264,7 +253,7 @@ bool CStdGLCtx::InitGlew(HINSTANCE hInst) CStdGLCtx::CStdGLCtx(): pWindow(0), hDC(0), this_context(contexts.end()) { } -void CStdGLCtx::Clear() +void CStdGLCtx::Clear(bool multisample_change) { Deselect(); if (hDC) @@ -279,6 +268,13 @@ void CStdGLCtx::Clear() contexts.erase(this_context); this_context = contexts.end(); } + if (multisample_change) + { + assert(!pGL->pCurrCtx); + if (hrc) + wglDeleteContext(hrc); + hrc = 0; + } } bool CStdGLCtx::Init(C4Window * pWindow, C4AbstractApp *pApp) @@ -452,7 +448,7 @@ void InitGLXPointers() CStdGLCtx::CStdGLCtx(): pWindow(0), ctx(0), this_context(contexts.end()) { } -void CStdGLCtx::Clear() +void CStdGLCtx::Clear(bool multisample_change) { Deselect(); if (ctx) @@ -586,7 +582,7 @@ bool CStdGLCtx::PageFlip() CStdGLCtx::CStdGLCtx(): pWindow(0), this_context(contexts.end()) { } -void CStdGLCtx::Clear() +void CStdGLCtx::Clear(bool multisample_change) { pWindow = 0; diff --git a/src/graphics/C4DrawGLMac.mm b/src/graphics/C4DrawGLMac.mm index 6fb689302..0164c123c 100644 --- a/src/graphics/C4DrawGLMac.mm +++ b/src/graphics/C4DrawGLMac.mm @@ -558,7 +558,7 @@ static NSOpenGLContext* MainContext; CStdGLCtx::CStdGLCtx(): pWindow(0), this_context(contexts.end()) {} -void CStdGLCtx::Clear() +void CStdGLCtx::Clear(bool multisample_change) { Deselect(); setObjectiveCObject(nil); diff --git a/src/gui/C4StartupOptionsDlg.cpp b/src/gui/C4StartupOptionsDlg.cpp index b105aa29c..fae5dc478 100644 --- a/src/gui/C4StartupOptionsDlg.cpp +++ b/src/gui/C4StartupOptionsDlg.cpp @@ -1060,7 +1060,7 @@ bool C4StartupOptionsDlg::OnGfxMSComboSelChange(C4GUI::ComboBox *pForCombo, int3 // Note: This assumes there is only one GL context (the main context). This // is true in fullscreen mode, and since the startup dlg is only shown in // fullscreen mode we are safe this way. - if(pGL) pGL->pMainCtx->Clear(); + if(pGL) pGL->pMainCtx->Clear(true); #endif int32_t PrevMultiSampling = Config.Graphics.MultiSampling; Config.Graphics.MultiSampling = idNewSelection; diff --git a/src/platform/C4WindowWin32.cpp b/src/platform/C4WindowWin32.cpp index 213b52998..cd90dee07 100644 --- a/src/platform/C4WindowWin32.cpp +++ b/src/platform/C4WindowWin32.cpp @@ -693,7 +693,6 @@ bool C4Window::ReInit(C4AbstractApp* pApp) hWindow, NULL, pApp->hInstance, NULL); if(!hNewRenderWindow) return false; - CStdGLCtx::Reinitialize(); ShowWindow(hNewRenderWindow, SW_SHOW); DestroyWindow(renderwnd); renderwnd = hNewRenderWindow;