Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Alex Cristici <alex.cristici@gmail.com> Co-authored-by: mwilsnd <mwilsnd@gmail.com> Co-authored-by: Stefan Karschti <stefan.karschti@gmail.com> Co-authored-by: Bart Louwers <bart@emeel.net> Co-authored-by: Alex Cristici <alex@skoon.energy> Co-authored-by: Bart Louwers <bart.louwers@gmail.com> Co-authored-by: Wei Chen <alanchenboy@gmail.com> Co-authored-by: Siarhei Fedartsou <siarhei.fedartsou@gmail.com> Co-authored-by: tdcosta100 <tdcosta100@gmail.com>
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <memory>
|
|
|
|
namespace mbgl {
|
|
namespace gfx {
|
|
|
|
class Backend {
|
|
public:
|
|
/// @brief The active graphics API/backend type.
|
|
enum class Type : uint8_t {
|
|
OpenGL, ///< The OpenGL API backend
|
|
Metal, ///< The Metal API backend
|
|
TYPE_MAX, ///< Not a valid backend type, used to determine the number
|
|
///< of available backends (ie for array allocation).
|
|
};
|
|
|
|
#if MLN_RENDER_BACKEND_METAL
|
|
static constexpr Type DefaultType = Type::Metal;
|
|
#else // assume MLN_RENDER_BACKEND_METAL
|
|
static constexpr Type DefaultType = Type::OpenGL;
|
|
#endif
|
|
|
|
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
|