diff --git a/src/xenia/ui/gl/gl_context.cc b/src/xenia/ui/gl/gl_context.cc index 46cc888c0..5ba6fb97f 100644 --- a/src/xenia/ui/gl/gl_context.cc +++ b/src/xenia/ui/gl/gl_context.cc @@ -59,9 +59,10 @@ void FatalGLError(std::string error) { "of supported GPUs."); } -std::unique_ptr GLContext::Create(Window* target_window) { +std::unique_ptr GLContext::Create(Window* target_window, + GLContext* share_context) { auto context = std::unique_ptr(new GLContext(target_window)); - if (!context->Initialize(target_window)) { + if (!context->Initialize(target_window, share_context)) { return nullptr; } context->AssertExtensionsPresent(); @@ -92,7 +93,7 @@ GLContext::~GLContext() { } } -bool GLContext::Initialize(Window* target_window) { +bool GLContext::Initialize(Window* target_window, GLContext* share_context) { target_window_ = target_window; dc_ = GetDC(HWND(target_window_->native_handle())); @@ -152,7 +153,8 @@ bool GLContext::Initialize(Window* target_window) { WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0}; - glrc_ = wglCreateContextAttribsARB(dc_, nullptr, attrib_list); + glrc_ = wglCreateContextAttribsARB( + dc_, share_context ? share_context->glrc_ : nullptr, attrib_list); wglMakeCurrent(nullptr, nullptr); wglDeleteContext(temp_context); if (!glrc_) { diff --git a/src/xenia/ui/gl/gl_context.h b/src/xenia/ui/gl/gl_context.h index eb09aa36f..a78f045d1 100644 --- a/src/xenia/ui/gl/gl_context.h +++ b/src/xenia/ui/gl/gl_context.h @@ -30,7 +30,8 @@ namespace gl { class GLContext : public GraphicsContext { public: - static std::unique_ptr Create(Window* target_window); + static std::unique_ptr Create(Window* target_window, + GLContext* share_context = nullptr); ~GLContext() override; @@ -53,7 +54,7 @@ class GLContext : public GraphicsContext { explicit GLContext(Window* target_window); GLContext(Window* target_window, HGLRC glrc); - bool Initialize(Window* target_window); + bool Initialize(Window* target_window, GLContext* share_context); void AssertExtensionsPresent(); void SetupDebugging();