From 2eec5a19803a01e21d5793706ae69ac0d886cee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 27 Nov 2017 17:25:20 +0100 Subject: [core] move HeadlessBackend extension initialization code into Impl --- platform/default/headless_backend_osmesa.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'platform/default/headless_backend_osmesa.cpp') diff --git a/platform/default/headless_backend_osmesa.cpp b/platform/default/headless_backend_osmesa.cpp index 4cb0bfc5c4..0da1caf9af 100644 --- a/platform/default/headless_backend_osmesa.cpp +++ b/platform/default/headless_backend_osmesa.cpp @@ -7,8 +7,9 @@ namespace mbgl { -struct OSMesaImpl : public HeadlessBackend::Impl { - OSMesaImpl() { +class OSMesaBackendImpl : public HeadlessBackend::Impl { +public: + OSMesaBackendImpl() { #if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 glContext = OSMesaCreateContextExt(OSMESA_RGBA, 16, 0, 0, nullptr); #else @@ -19,10 +20,14 @@ struct OSMesaImpl : public HeadlessBackend::Impl { } } - ~OSMesaImpl() final { + ~OSMesaBackendImpl() final { OSMesaDestroyContext(glContext); } + gl::ProcAddress getExtensionFunctionPointer(const char* name) final { + return OSMesaGetProcAddress(name); + } + void activateContext() final { if (!OSMesaMakeCurrent(glContext, &fakeBuffer, GL_UNSIGNED_BYTE, 1, 1)) { throw std::runtime_error("Switching OpenGL context failed.\n"); @@ -34,13 +39,9 @@ private: GLubyte fakeBuffer = 0; }; -gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) { - return OSMesaGetProcAddress(name); -} - -void HeadlessBackend::createContext() { - assert(!hasContext()); - impl = std::make_unique(); +void HeadlessBackend::createImpl() { + assert(!impl); + impl = std::make_unique(); } } // namespace mbgl -- cgit v1.2.1