Replaced (Uber)ShaderLibrary by template class ObjectLibrary

Former-commit-id: d488cfd4e5e3ff31112fffebce2b7cdb86cc2e55
This commit is contained in:
Lynix
2015-01-28 15:49:04 +01:00
parent c2d1773b41
commit e18e490c59
23 changed files with 152 additions and 195 deletions

View File

@@ -11,6 +11,7 @@
#include <Nazara/Core/ByteArray.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
@@ -26,11 +27,13 @@ class NzShaderStage;
using NzShaderConstListener = NzObjectListenerWrapper<const NzShader>;
using NzShaderConstRef = NzObjectRef<const NzShader>;
using NzShaderLibrary = NzObjectLibrary<NzShader>;
using NzShaderListener = NzObjectListenerWrapper<NzShader>;
using NzShaderRef = NzObjectRef<NzShader>;
class NAZARA_API NzShader : public NzRefCounted, NzNonCopyable
{
friend NzShaderLibrary;
friend class NzRenderer;
public:
@@ -102,10 +105,15 @@ class NAZARA_API NzShader : public NzRefCounted, NzNonCopyable
private:
bool PostLinkage();
static bool Initialize();
static void Uninitialize();
std::vector<unsigned int> m_attachedShaders[nzShaderStage_Max+1];
bool m_linked;
int m_uniformLocations[nzShaderUniform_Max+1];
unsigned int m_program;
static NzShaderLibrary::LibraryMap s_library;
};
#include <Nazara/Renderer/Shader.inl>

View File

@@ -1,36 +0,0 @@
// 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_SHADERLIBRARY_HPP
#define NAZARA_SHADERLIBRARY_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Renderer/Shader.hpp>
#include <unordered_map>
class NAZARA_API NzShaderLibrary
{
friend class NzRenderer;
public:
NzShaderLibrary() = delete;
~NzShaderLibrary() = delete;
static NzShader* Get(const NzString& name);
static bool Has(const NzString& name);
static void Register(const NzString& name, NzShader* shader);
static void Unregister(const NzString& name);
private:
static bool Initialize();
static void Uninitialize();
static std::unordered_map<NzString, NzShaderRef> s_library;
};
#endif // NAZARA_SHADERLIBRARY_HPP

View File

@@ -9,6 +9,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ParameterList.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
@@ -19,16 +20,26 @@ class NzUberShader;
using NzUberShaderConstListener = NzObjectListenerWrapper<const NzUberShader>;
using NzUberShaderConstRef = NzObjectRef<const NzUberShader>;
using NzUberShaderLibrary = NzObjectLibrary<NzUberShader>;
using NzUberShaderListener = NzObjectListenerWrapper<NzUberShader>;
using NzUberShaderRef = NzObjectRef<NzUberShader>;
class NAZARA_API NzUberShader : public NzRefCounted
{
friend NzUberShaderLibrary;
friend class NzRenderer;
public:
NzUberShader() = default;
virtual ~NzUberShader();
virtual NzUberShaderInstance* Get(const NzParameterList& parameters) const = 0;
private:
static bool Initialize();
static void Uninitialize();
static NzUberShaderLibrary::LibraryMap s_library;
};
#endif // NAZARA_UBERSHADER_HPP

View File

@@ -1,36 +0,0 @@
// 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_UBERSHADERLIBRARY_HPP
#define NAZARA_UBERSHADERLIBRARY_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Renderer/UberShader.hpp>
#include <unordered_map>
class NAZARA_API NzUberShaderLibrary
{
friend class NzRenderer;
public:
NzUberShaderLibrary() = delete;
~NzUberShaderLibrary() = delete;
static NzUberShader* Get(const NzString& name);
static bool Has(const NzString& name);
static void Register(const NzString& name, NzUberShader* uberShader);
static void Unregister(const NzString& name);
private:
static bool Initialize();
static void Uninitialize();
static std::unordered_map<NzString, NzUberShaderRef> s_library;
};
#endif // NAZARA_UBERSHADERLIBRARY_HPP