Multi-window GL contexts.
This commit is contained in:
@@ -59,9 +59,10 @@ void FatalGLError(std::string error) {
|
|||||||
"of supported GPUs.");
|
"of supported GPUs.");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<GLContext> GLContext::Create(Window* target_window) {
|
std::unique_ptr<GLContext> GLContext::Create(Window* target_window,
|
||||||
|
GLContext* share_context) {
|
||||||
auto context = std::unique_ptr<GLContext>(new GLContext(target_window));
|
auto context = std::unique_ptr<GLContext>(new GLContext(target_window));
|
||||||
if (!context->Initialize(target_window)) {
|
if (!context->Initialize(target_window, share_context)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
context->AssertExtensionsPresent();
|
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;
|
target_window_ = target_window;
|
||||||
dc_ = GetDC(HWND(target_window_->native_handle()));
|
dc_ = GetDC(HWND(target_window_->native_handle()));
|
||||||
|
|
||||||
@@ -152,7 +153,8 @@ bool GLContext::Initialize(Window* target_window) {
|
|||||||
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||||
0};
|
0};
|
||||||
|
|
||||||
glrc_ = wglCreateContextAttribsARB(dc_, nullptr, attrib_list);
|
glrc_ = wglCreateContextAttribsARB(
|
||||||
|
dc_, share_context ? share_context->glrc_ : nullptr, attrib_list);
|
||||||
wglMakeCurrent(nullptr, nullptr);
|
wglMakeCurrent(nullptr, nullptr);
|
||||||
wglDeleteContext(temp_context);
|
wglDeleteContext(temp_context);
|
||||||
if (!glrc_) {
|
if (!glrc_) {
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ namespace gl {
|
|||||||
|
|
||||||
class GLContext : public GraphicsContext {
|
class GLContext : public GraphicsContext {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<GLContext> Create(Window* target_window);
|
static std::unique_ptr<GLContext> Create(Window* target_window,
|
||||||
|
GLContext* share_context = nullptr);
|
||||||
|
|
||||||
~GLContext() override;
|
~GLContext() override;
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ class GLContext : public GraphicsContext {
|
|||||||
explicit GLContext(Window* target_window);
|
explicit GLContext(Window* target_window);
|
||||||
GLContext(Window* target_window, HGLRC glrc);
|
GLContext(Window* target_window, HGLRC glrc);
|
||||||
|
|
||||||
bool Initialize(Window* target_window);
|
bool Initialize(Window* target_window, GLContext* share_context);
|
||||||
void AssertExtensionsPresent();
|
void AssertExtensionsPresent();
|
||||||
|
|
||||||
void SetupDebugging();
|
void SetupDebugging();
|
||||||
|
|||||||
Reference in New Issue
Block a user