Add GLX context for linux platform
This commit is contained in:
parent
a63c9458cd
commit
a9e5d7a496
|
@ -43,13 +43,13 @@ class GLContext : public GraphicsContext {
|
||||||
|
|
||||||
ImmediateDrawer* immediate_drawer() override;
|
ImmediateDrawer* immediate_drawer() override;
|
||||||
|
|
||||||
bool is_current() = 0;
|
virtual bool is_current() override = 0;
|
||||||
bool MakeCurrent() = 0;
|
virtual bool MakeCurrent() override = 0;
|
||||||
void ClearCurrent() = 0;
|
virtual void ClearCurrent() override = 0;
|
||||||
bool WasLost() override;
|
bool WasLost() override;
|
||||||
|
|
||||||
void BeginSwap() = 0;
|
virtual void BeginSwap() override = 0;
|
||||||
void EndSwap() = 0;
|
virtual void EndSwap() override = 0;
|
||||||
std::unique_ptr<RawImage> Capture() override;
|
std::unique_ptr<RawImage> Capture() override;
|
||||||
|
|
||||||
Blitter* blitter() { return &blitter_; }
|
Blitter* blitter() { return &blitter_; }
|
||||||
|
|
|
@ -29,10 +29,6 @@ namespace ui {
|
||||||
namespace gl {
|
namespace gl {
|
||||||
|
|
||||||
|
|
||||||
DEFINE_bool(disable_gl_context_reset, false,
|
|
||||||
"Do not aggressively reset the GL context (helps with capture "
|
|
||||||
"programs such as OBS or FRAPS).");
|
|
||||||
DEFINE_bool(gl_debug, false, "Enable OpenGL debug validation layer.");
|
|
||||||
|
|
||||||
thread_local GLEWContext* tls_glew_context_ = nullptr;
|
thread_local GLEWContext* tls_glew_context_ = nullptr;
|
||||||
thread_local GLXEWContext* tls_glxew_context_ = nullptr;
|
thread_local GLXEWContext* tls_glxew_context_ = nullptr;
|
||||||
|
@ -40,6 +36,7 @@ extern "C" GLEWContext* glewGetContext() { return tls_glew_context_; }
|
||||||
extern "C" GLXEWContext* glxewGetContext() { return tls_glxew_context_; }
|
extern "C" GLXEWContext* glxewGetContext() { return tls_glxew_context_; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
||||||
Window* target_window,
|
Window* target_window,
|
||||||
GLContext* share_context) {
|
GLContext* share_context) {
|
||||||
|
@ -52,11 +49,10 @@ std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<GLContext> GLContext::CreateOffscreen(
|
std::unique_ptr<GLContext> GLContext::CreateOffscreen(
|
||||||
GraphicsProvider* provider, GLContext* parent_context) {
|
GraphicsProvider* provider, GLContext* parent_context) {
|
||||||
return GLXContext::CreateOffscreen(provider,
|
return GLXContext::CreateOffscreen(provider,
|
||||||
dynamic_cast<GLXContext*>(parent_context));
|
static_cast<GLXContext*>(parent_context));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLXContext::GLXContext(GraphicsProvider* provider, Window* target_window)
|
GLXContext::GLXContext(GraphicsProvider* provider, Window* target_window)
|
||||||
|
@ -152,7 +148,7 @@ bool GLXContext::Initialize(GLContext* share_context) {
|
||||||
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
||||||
robust_access_supported_ ? GLX_LOSE_CONTEXT_ON_RESET_ARB : 0,
|
robust_access_supported_ ? GLX_LOSE_CONTEXT_ON_RESET_ARB : 0,
|
||||||
0};
|
0};
|
||||||
GLXContext* share_context_glx = dynamic_cast<GLXContext*>(share_context);
|
GLXContext* share_context_glx = static_cast<GLXContext*>(share_context);
|
||||||
glx_context_ = glXCreateContextAttribsARB(
|
glx_context_ = glXCreateContextAttribsARB(
|
||||||
display, nullptr,
|
display, nullptr,
|
||||||
share_context ? share_context_glx->glx_context_ : nullptr, True,
|
share_context ? share_context_glx->glx_context_ : nullptr, True,
|
||||||
|
@ -277,7 +273,7 @@ std::unique_ptr<GLXContext> GLXContext::CreateOffscreen(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool GLContext::is_current() {
|
bool GLXContext::is_current() {
|
||||||
return tls_glew_context_ == glew_context_.get();
|
return tls_glew_context_ == glew_context_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +324,7 @@ void GLXContext::BeginSwap() {
|
||||||
|
|
||||||
void GLXContext::EndSwap() {
|
void GLXContext::EndSwap() {
|
||||||
SCOPE_profile_cpu_i("gpu", "xe::ui::gl::GLXContext::EndSwap");
|
SCOPE_profile_cpu_i("gpu", "xe::ui::gl::GLXContext::EndSwap");
|
||||||
glXSwapBuffers(disp_, _xid);
|
glXSwapBuffers(disp_, xid_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gl
|
} // namespace gl
|
||||||
|
|
|
@ -37,6 +37,7 @@ class GLXContext : public GLContext {
|
||||||
|
|
||||||
|
|
||||||
bool is_current() override;
|
bool is_current() override;
|
||||||
|
|
||||||
bool MakeCurrent() override;
|
bool MakeCurrent() override;
|
||||||
void ClearCurrent() override;
|
void ClearCurrent() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue