summaryrefslogtreecommitdiff
path: root/include/mbgl/gfx/backend.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/gfx/backend.hpp')
-rw-r--r--include/mbgl/gfx/backend.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/mbgl/gfx/backend.hpp b/include/mbgl/gfx/backend.hpp
new file mode 100644
index 0000000000..eed63dfcba
--- /dev/null
+++ b/include/mbgl/gfx/backend.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <cstdint>
+#include <cstdlib>
+#include <memory>
+
+namespace mbgl {
+namespace gfx {
+
+class Backend {
+public:
+ enum class Type : uint8_t {
+ OpenGL,
+ };
+
+ static constexpr Type DefaultType = Type::OpenGL;
+
+ static void SetType(const Type value) {
+ if (Value(value) != value) {
+ abort(); // SetType must be called prior to any GetType calls.
+ }
+ }
+
+ static Type GetType() {
+ return Value(DefaultType);
+ }
+
+ template <typename T, typename... Args>
+ static std::unique_ptr<T> Create(Args... args) {
+ return Create<Type::OpenGL, T, Args...>(std::forward<Args>(args)...);
+ }
+
+private:
+ template <Type, typename T, typename... Args>
+ static std::unique_ptr<T> Create(Args...);
+
+ static Type Value(Type value) {
+ static const Type type = value;
+ return type;
+ }
+};
+
+} // namespace gfx
+} // namespace mbgl