summaryrefslogtreecommitdiff
path: root/Source/Core/Common/GL/GLInterface/WGL.cpp
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2018-10-03 23:03:30 +1000
committerStenzek <stenzek@gmail.com>2018-10-20 21:11:34 +1000
commit4b8d1c2b429485d54d7dad2fdc142ed43b34b992 (patch)
treed8076068e7ae2f2334813b9d79d2e4da31c7ead3 /Source/Core/Common/GL/GLInterface/WGL.cpp
parentdcdd02d646230e7903520a41dc9f86e57ae16dbe (diff)
GLContext: Combine shared context initialization and creation
Diffstat (limited to 'Source/Core/Common/GL/GLInterface/WGL.cpp')
-rw-r--r--Source/Core/Common/GL/GLInterface/WGL.cpp37
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)