summaryrefslogtreecommitdiff
path: root/common/headless_view.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/headless_view.cpp')
-rw-r--r--common/headless_view.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/common/headless_view.cpp b/common/headless_view.cpp
index 42d595310d..37982e6891 100644
--- a/common/headless_view.cpp
+++ b/common/headless_view.cpp
@@ -109,10 +109,7 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) {
#if MBGL_USE_GLX
x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), width, height, 32);
glx_pixmap = glXCreateGLXPixmap(x_display, x_info, x_pixmap);
-
- make_active();
#endif
-
}
void HeadlessView::clear_buffers() {
@@ -135,6 +132,8 @@ void HeadlessView::clear_buffers() {
glDeleteRenderbuffersEXT(1, &fbo_depth_stencil);
fbo_depth_stencil = 0;
}
+
+ make_inactive();
#endif
#if MBGL_USE_GLX
@@ -151,14 +150,13 @@ void HeadlessView::clear_buffers() {
}
HeadlessView::~HeadlessView() {
- clear_buffers();
+ make_inactive();
#if MBGL_USE_CGL
CGLDestroyContext(gl_context);
#endif
#if MBGL_USE_GLX
- glXMakeCurrent(x_display, None, NULL);
glXDestroyContext(x_display, gl_context);
XFree(x_info);
XCloseDisplay(x_display);
@@ -184,6 +182,21 @@ void HeadlessView::make_active() {
#endif
}
+void HeadlessView::make_inactive() {
+#if MBGL_USE_CGL
+ CGLError error = CGLSetCurrentContext(nullptr);
+ if (error) {
+ fprintf(stderr, "Removing OpenGL context failed\n");
+ }
+#endif
+
+#if MBGL_USE_GLX
+ if (!glXMakeCurrent(x_display, None, NULL)) {
+ fprintf(stderr, "Removing OpenGL context failed\n");
+ }
+#endif
+}
+
void HeadlessView::swap() {}
unsigned int HeadlessView::root_fbo() {