summaryrefslogtreecommitdiff
path: root/src/mbgl/map/backend.cpp
blob: 29f7522e4f6482c1455f420b2d15e39837ec331a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <mbgl/map/backend.hpp>
#include <mbgl/map/backend_scope.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/extension.hpp>
#include <mbgl/gl/debugging.hpp>

#include <cassert>

namespace mbgl {

Backend::Backend() = default;

gl::Context& Backend::getContext() {
    assert(BackendScope::exists());
    std::call_once(initialized, [this] {
        context = std::make_unique<gl::Context>();
        gl::debugging::enable();
        gl::initializeExtensions(
            std::bind(&Backend::initializeExtension, this, std::placeholders::_1));
    });
    return *context;
}

Backend::~Backend() = default;

} // namespace mbgl