Files
MapLibreParticleLab/src/mbgl/map/backend.cpp
Konstantin Käfer e67abfbe67 [core] Refactor OpenGL extension loading mechanism
Previously, we initialized global variables that held pointers to the extension functions. While this seemed to work, the spec doesn't guarantee that the function pointers are identical for different OpenGL contexts. Therefore, we are now making them a member variable of the Context object.
2017-03-23 14:50:11 -07:00

27 lines
645 B
C++

#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>();
context->enableDebugging();
context->initializeExtensions(
std::bind(&Backend::initializeExtension, this, std::placeholders::_1));
});
return *context;
}
Backend::~Backend() = default;
} // namespace mbgl