diff options
Diffstat (limited to 'platform/linux/src/headless_backend_glx.cpp')
-rw-r--r-- | platform/linux/src/headless_backend_glx.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/platform/linux/src/headless_backend_glx.cpp b/platform/linux/src/headless_backend_glx.cpp index 6d2939da0f..27af98e70a 100644 --- a/platform/linux/src/headless_backend_glx.cpp +++ b/platform/linux/src/headless_backend_glx.cpp @@ -70,8 +70,9 @@ public: GLXFBConfig* fbConfigs = nullptr; }; -struct GLXImpl : public HeadlessBackend::Impl { - GLXImpl() { +class GLXBackendImpl : public HeadlessBackend::Impl { +public: + GLXBackendImpl() { // Try to create a legacy context. glContext = glXCreateNewContext(glxDisplay->xDisplay, glxDisplay->fbConfigs[0], GLX_RGBA_TYPE, None, True); @@ -91,13 +92,17 @@ struct GLXImpl : public HeadlessBackend::Impl { glXCreatePbuffer(glxDisplay->xDisplay, glxDisplay->fbConfigs[0], pbufferAttributes); } - ~GLXImpl() final { + ~GLXBackendImpl() final { if (glxPbuffer) { glXDestroyPbuffer(glxDisplay->xDisplay, glxPbuffer); } glXDestroyContext(glxDisplay->xDisplay, glContext); } + gl::ProcAddress getExtensionFunctionPointer(const char* name) final { + return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name)); + } + void activateContext() final { if (!glXMakeContextCurrent(glxDisplay->xDisplay, glxPbuffer, glxPbuffer, glContext)) { throw std::runtime_error("Switching OpenGL context failed.\n"); @@ -117,13 +122,9 @@ private: GLXPbuffer glxPbuffer = 0; }; -gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) { - return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name)); -} - -void HeadlessBackend::createContext() { - assert(!hasContext()); - impl = std::make_unique<GLXImpl>(); +void HeadlessBackend::createImpl() { + assert(!impl); + impl = std::make_unique<GLXBackendImpl>(); } } // namespace mbgl |