diff options
Diffstat (limited to 'Source/Core/Common/GL/GLInterface/WGL.cpp')
| -rw-r--r-- | Source/Core/Common/GL/GLInterface/WGL.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
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<GLContext> GLContextWGL::CreateSharedContext() { - GLContextWGL* wgl_main_context = static_cast<GLContextWGL*>(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<GLContext> GLContextWGL::CreateSharedContext() -{ - std::unique_ptr<GLContextWGL> context = std::make_unique<GLContextWGL>(); - if (!context->Initialize(this)) + HGLRC rc = CreateCoreContext(dc, m_rc); + if (!rc) { - context->Shutdown(); + wglReleasePbufferDCARB(static_cast<HPBUFFERARB>(pbuffer), dc); + wglDestroyPbufferARB(static_cast<HPBUFFERARB>(pbuffer)); return nullptr; } - return std::move(context); + std::unique_ptr<GLContextWGL> context = std::make_unique<GLContextWGL>(); + 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) |
