// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_CONTEXT_HPP #define NAZARA_CONTEXT_HPP #include #include #include #include #include #include #include #include namespace Nz { class Context; using ContextConstRef = ObjectRef; using ContextLibrary = ObjectLibrary; using ContextRef = ObjectRef; class ContextImpl; class NAZARA_RENDERER_API Context : public RefCounted { friend ContextImpl; friend ContextLibrary; friend class OpenGL; public: Context() = default; Context(const Context&) = delete; Context(Context&&) = delete; ~Context(); bool Create(const ContextParameters& parameters = ContextParameters()); void Destroy(); void EnableVerticalSync(bool enabled); const ContextParameters& GetParameters() const; bool IsActive() const; bool SetActive(bool active) const; void SwapBuffers(); Context& operator=(const Context&) = delete; Context& operator=(Context&&) = delete; static bool EnsureContext(); static const Context* GetCurrent(); static const Context* GetReference(); static const Context* GetThreadContext(); // Signals: NazaraSignal(OnContextDestroy, const Context* /*context*/); NazaraSignal(OnContextRelease, const Context* /*context*/); private: static bool Initialize(); static void Uninitialize(); ContextParameters m_parameters; ContextImpl* m_impl = nullptr; static std::unique_ptr s_reference; static std::vector> s_contexts; static ContextLibrary::LibraryMap s_library; }; } #endif // NAZARA_CONTEXT_HPP