Added a static New method to RefCounted-derived classes

Former-commit-id: efd9e68e050fb6cc7e0df7a7c222ca759c502dc5
This commit is contained in:
Lynix
2015-01-25 23:41:09 +01:00
parent 5f5be93992
commit 0db92e671d
59 changed files with 532 additions and 354 deletions

View File

@@ -134,6 +134,7 @@ class NAZARA_API NzMaterial : public NzRefCounted, public NzResource
NzMaterial& operator=(const NzMaterial& material);
static NzMaterial* GetDefault();
template<typename... Args> static NzMaterialRef New(Args&&... args);
private:
struct ShaderInstance
@@ -172,8 +173,10 @@ class NAZARA_API NzMaterial : public NzRefCounted, public NzResource
float m_alphaThreshold;
float m_shininess;
static NzMaterial* s_defaultMaterial;
static NzMaterialRef s_defaultMaterial;
static NzMaterialLoader::LoaderList s_loaders;
};
#include <Nazara/Graphics/Material.inl>
#endif // NAZARA_MATERIAL_HPP

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Graphics/Debug.hpp>
template<typename... Args>
NzMaterialRef NzMaterial::New(Args&&... args)
{
std::unique_ptr<NzMaterial> object(new NzMaterial(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Graphics/DebugOff.hpp>