From 4b8d1c2b429485d54d7dad2fdc142ed43b34b992 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 3 Oct 2018 23:03:30 +1000 Subject: GLContext: Combine shared context initialization and creation --- Source/Core/Common/GL/GLInterface/WGL.cpp | 37 +++++++++++++------------------ 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'Source/Core/Common/GL/GLInterface/WGL.cpp') diff --git a/Source/Core/Common/GL/GLInterface/WGL.cpp b/Source/Core/Common/GL/GLInterface/WGL.cpp index 6d1f072aee..032657cf69 100644 --- a/Source/Core/Common/GL/GLInterface/WGL.cpp +++ b/Source/Core/Common/GL/GLInterface/WGL.cpp @@ -306,34 +306,29 @@ bool GLContextWGL::Initialize(void* display_handle, void* window_handle, bool st return true; } -bool GLContextWGL::Initialize(GLContext* main_context) +std::unique_ptr GLContextWGL::CreateSharedContext() { - GLContextWGL* wgl_main_context = static_cast(main_context); - - m_opengl_mode = wgl_main_context->m_opengl_mode; - // WGL does not support surfaceless contexts, so we use a 1x1 pbuffer instead. - if (!CreatePBuffer(wgl_main_context->m_dc, 1, 1, &m_pbuffer_handle, &m_dc)) - return false; - - m_rc = CreateCoreContext(m_dc, wgl_main_context->m_rc); - if (!m_rc) - return false; - - m_is_core_context = true; - return true; -} + HANDLE pbuffer; + HDC dc; + if (!CreatePBuffer(m_dc, 1, 1, &pbuffer, &dc)) + return nullptr; -std::unique_ptr GLContextWGL::CreateSharedContext() -{ - std::unique_ptr context = std::make_unique(); - if (!context->Initialize(this)) + HGLRC rc = CreateCoreContext(dc, m_rc); + if (!rc) { - context->Shutdown(); + wglReleasePbufferDCARB(static_cast(pbuffer), dc); + wglDestroyPbufferARB(static_cast(pbuffer)); return nullptr; } - return std::move(context); + std::unique_ptr context = std::make_unique(); + context->m_pbuffer_handle = pbuffer; + context->m_dc = dc; + context->m_rc = rc; + context->m_opengl_mode = m_opengl_mode; + context->m_is_core_context = m_is_core_context; + return context; } HGLRC GLContextWGL::CreateCoreContext(HDC dc, HGLRC share_context) -- cgit v1.2.3