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

@@ -40,6 +40,7 @@ class NAZARA_API NzRenderBuffer : public NzRefCounted, NzNonCopyable
bool IsValid() const;
static bool IsSupported();
template<typename... Args> static NzRenderBufferRef New(Args&&... args);
private:
nzPixelFormat m_pixelFormat;
@@ -48,4 +49,6 @@ class NAZARA_API NzRenderBuffer : public NzRefCounted, NzNonCopyable
unsigned int m_width;
};
#include <Nazara/Renderer/RenderBuffer.inl>
#endif // NAZARA_RENDERBUFFER_HPP

View File

@@ -0,0 +1,17 @@
// 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
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
template<typename... Args>
NzRenderBufferRef NzRenderBuffer::New(Args&&... args)
{
std::unique_ptr<NzRenderBuffer> object(new NzRenderBuffer(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -97,6 +97,7 @@ class NAZARA_API NzShader : public NzRefCounted, NzNonCopyable
unsigned int GetOpenGLID() const;
static bool IsStageSupported(nzShaderStage stage);
template<typename... Args> static NzShaderRef New(Args&&... args);
private:
bool PostLinkage();
@@ -107,4 +108,6 @@ class NAZARA_API NzShader : public NzRefCounted, NzNonCopyable
unsigned int m_program;
};
#include <Nazara/Renderer/Shader.inl>
#endif // NAZARA_SHADER_HPP

View File

@@ -0,0 +1,17 @@
// 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
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
template<typename... Args>
NzShaderRef NzShader::New(Args&&... args)
{
std::unique_ptr<NzShader> object(new NzShader(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -101,6 +101,7 @@ class NAZARA_API NzTexture : public NzAbstractImage, public NzRefCounted, public
static bool IsFormatSupported(nzPixelFormat format);
static bool IsMipmappingSupported();
static bool IsTypeSupported(nzImageType type);
template<typename... Args> static NzTextureRef New(Args&&... args);
private:
bool CreateTexture(bool proxy);
@@ -108,4 +109,6 @@ class NAZARA_API NzTexture : public NzAbstractImage, public NzRefCounted, public
NzTextureImpl* m_impl = nullptr;
};
#include <Nazara/Renderer/Texture.inl>
#endif // NAZARA_TEXTURE_HPP

View File

@@ -0,0 +1,17 @@
// 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
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
template<typename... Args>
NzTextureRef NzTexture::New(Args&&... args)
{
std::unique_ptr<NzTexture> object(new NzTexture(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -9,12 +9,21 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Core/ObjectListenerWrapper.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Renderer/Shader.hpp>
#include <Nazara/Renderer/ShaderStage.hpp>
#include <Nazara/Renderer/UberShader.hpp>
#include <Nazara/Renderer/UberShaderInstancePreprocessor.hpp>
#include <unordered_map>
class NzUberShaderPreprocessor;
using NzUberShaderPreprocessorConstListener = NzObjectListenerWrapper<const NzUberShaderPreprocessor>;
using NzUberShaderPreprocessorConstRef = NzObjectRef<const NzUberShaderPreprocessor>;
using NzUberShaderPreprocessorListener = NzObjectListenerWrapper<NzUberShaderPreprocessor>;
using NzUberShaderPreprocessorRef = NzObjectRef<NzUberShaderPreprocessor>;
class NAZARA_API NzUberShaderPreprocessor : public NzUberShader
{
public:
@@ -27,6 +36,7 @@ class NAZARA_API NzUberShaderPreprocessor : public NzUberShader
bool SetShaderFromFile(nzShaderStage stage, const NzString& filePath, const NzString& shaderFlags, const NzString& requiredFlags = NzString());
static bool IsSupported();
template<typename... Args> static NzUberShaderPreprocessorRef New(Args&&... args);
private:
struct Shader
@@ -43,4 +53,6 @@ class NAZARA_API NzUberShaderPreprocessor : public NzUberShader
Shader m_shaders[nzShaderStage_Max+1];
};
#include <Nazara/Renderer/UberShaderPreprocessor.inl>
#endif // NAZARA_UBERSHADERPREPROCESSOR_HPP

View File

@@ -0,0 +1,17 @@
// 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
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
template<typename... Args>
NzUberShaderPreprocessorRef NzUberShaderPreprocessor::New(Args&&... args)
{
std::unique_ptr<NzUberShaderPreprocessor> object(new NzUberShaderPreprocessor(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Renderer/DebugOff.hpp>