summaryrefslogtreecommitdiff
path: root/platform/default/headless_backend_osmesa.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/default/headless_backend_osmesa.cpp')
-rw-r--r--platform/default/headless_backend_osmesa.cpp21
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