diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-11-27 17:25:20 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-11-29 15:48:51 +0100 |
commit | 2eec5a19803a01e21d5793706ae69ac0d886cee5 (patch) | |
tree | fb0f1464f1e73eca49dd062dfd70770e84ec6b8b /platform/default/headless_backend_osmesa.cpp | |
parent | 335f04f7e13422ce53cbbf13cebb8283149faba8 (diff) | |
download | qtlocation-mapboxgl-2eec5a19803a01e21d5793706ae69ac0d886cee5.tar.gz |
[core] move HeadlessBackend extension initialization code into Impl
Diffstat (limited to 'platform/default/headless_backend_osmesa.cpp')
-rw-r--r-- | platform/default/headless_backend_osmesa.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
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<OSMesaImpl>(); +void HeadlessBackend::createImpl() { + assert(!impl); + impl = std::make_unique<OSMesaBackendImpl>(); } } // namespace mbgl |