Files
NazaraEngine/include/Nazara/Renderer/Context.hpp
Lynix a069b105e6 Fully replace listener system by signals
Former-commit-id: 032dfddd12cc3a792c71426148c758ffac3621f9
2015-06-07 20:42:41 +02:00

67 lines
1.7 KiB
C++

// 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 <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Renderer/ContextParameters.hpp>
#include <memory>
#include <vector>
class NzContext;
using NzContextConstRef = NzObjectRef<const NzContext>;
using NzContextLibrary = NzObjectLibrary<NzContext>;
using NzContextRef = NzObjectRef<NzContext>;
class NzContextImpl;
class NAZARA_API NzContext : public NzRefCounted
{
friend NzContextImpl;
friend NzContextLibrary;
friend class NzOpenGL;
public:
NzContext() = default;
~NzContext();
bool Create(const NzContextParameters& parameters = NzContextParameters());
void Destroy();
const NzContextParameters& GetParameters() const;
bool IsActive() const;
bool SetActive(bool active) const;
void SwapBuffers();
static bool EnsureContext();
static const NzContext* GetCurrent();
static const NzContext* GetReference();
static const NzContext* GetThreadContext();
// Signals
NazaraSignal(OnContextDestroy, const NzContext*); //< Args: me
NazaraSignal(OnContextRelease, const NzContext*); //< Args: me
private:
static bool Initialize();
static void Uninitialize();
NzContextParameters m_parameters;
NzContextImpl* m_impl = nullptr;
static std::unique_ptr<NzContext> s_reference;
static std::vector<std::unique_ptr<NzContext>> s_contexts;
static NzContextLibrary::LibraryMap s_library;
};
#endif // NAZARA_CONTEXT_HPP