Graphics/Backgrounds: Update backgrounds to new coding-style

Former-commit-id: 9f96b93706fd8417d6262392f0ce9ab9ca1985c3
This commit is contained in:
Lynix
2015-06-23 23:35:11 +02:00
parent 0ec0e02a5f
commit 6092b0692b
10 changed files with 253 additions and 248 deletions

View File

@@ -8,12 +8,19 @@
#define NAZARA_ABSTRACTBACKGROUND_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Graphics/Enums.hpp>
class NzAbstractBackground;
class NzAbstractViewer;
class NAZARA_GRAPHICS_API NzAbstractBackground
using NzBackgroundConstRef = NzObjectRef<const NzAbstractBackground>;
using NzBackgroundLibrary = NzObjectLibrary<NzAbstractBackground>;
using NzBackgroundRef = NzObjectRef<NzAbstractBackground>;
class NAZARA_GRAPHICS_API NzAbstractBackground : public NzRefCounted
{
public:
NzAbstractBackground() = default;
@@ -22,6 +29,9 @@ class NAZARA_GRAPHICS_API NzAbstractBackground
virtual void Draw(const NzAbstractViewer* viewer) const = 0;
virtual nzBackgroundType GetBackgroundType() const = 0;
private:
static NzBackgroundLibrary::LibraryMap s_library;
};
#endif // NAZARA_ABSTRACTBACKGROUND_HPP

View File

@@ -12,6 +12,11 @@
#include <Nazara/Graphics/AbstractBackground.hpp>
#include <Nazara/Renderer/UberShader.hpp>
class NzColorBackground;
using NzColorBackgroundConstRef = NzObjectRef<const NzColorBackground>;
using NzColorBackgroundRef = NzObjectRef<NzColorBackground>;
class NAZARA_GRAPHICS_API NzColorBackground : public NzAbstractBackground
{
public:
@@ -24,6 +29,8 @@ class NAZARA_GRAPHICS_API NzColorBackground : public NzAbstractBackground
void SetColor(const NzColor& color);
template<typename... Args> static NzColorBackgroundRef New(Args&&... args);
private:
NzColor m_color;
NzUberShaderConstRef m_uberShader;
@@ -32,4 +39,6 @@ class NAZARA_GRAPHICS_API NzColorBackground : public NzAbstractBackground
int m_vertexDepthUniform;
};
#include <Nazara/Graphics/ColorBackground.inl>
#endif // NAZARA_COLORBACKGROUND_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>
NzColorBackgroundRef NzColorBackground::New(Args&&... args)
{
std::unique_ptr<NzColorBackground> object(new NzColorBackground(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -15,23 +15,33 @@
#include <Nazara/Utility/IndexBuffer.hpp>
#include <Nazara/Utility/VertexBuffer.hpp>
class NzSkyboxBackground;
using NzSkyboxBackgroundConstRef = NzObjectRef<const NzSkyboxBackground>;
using NzSkyboxBackgroundRef = NzObjectRef<NzSkyboxBackground>;
class NAZARA_GRAPHICS_API NzSkyboxBackground : public NzAbstractBackground
{
public:
NzSkyboxBackground();
NzSkyboxBackground(NzTexture* cubemapTexture);
~NzSkyboxBackground();
NzSkyboxBackground(NzTextureRef cubemapTexture = NzTextureRef());
~NzSkyboxBackground() = default;
void Draw(const NzAbstractViewer* viewer) const;
nzBackgroundType GetBackgroundType() const;
NzTexture* GetTexture() const;
const NzTextureSampler& GetTextureSampler();
inline const NzTextureRef& GetTexture() const;
inline NzTextureSampler& GetTextureSampler();
inline const NzTextureSampler& GetTextureSampler() const;
void SetTexture(NzTexture* cubemapTexture);
void SetTextureSampler(const NzTextureSampler& sampler);
inline void SetTexture(NzTextureRef cubemapTexture);
inline void SetTextureSampler(const NzTextureSampler& sampler);
template<typename... Args> static NzSkyboxBackgroundRef New(Args&&... args);
private:
static bool Initialize();
static void Uninitialize();
NzTextureRef m_texture;
NzTextureSampler m_sampler;
NzIndexBufferRef m_indexBuffer;
@@ -39,4 +49,6 @@ class NAZARA_GRAPHICS_API NzSkyboxBackground : public NzAbstractBackground
NzVertexBufferRef m_vertexBuffer;
};
#include <Nazara/Graphics/SkyboxBackground.inl>
#endif // NAZARA_SKYBOXBACKGROUND_HPP

View File

@@ -0,0 +1,45 @@
// 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>
inline const NzTextureRef& NzSkyboxBackground::GetTexture() const
{
return m_texture;
}
inline NzTextureSampler& NzSkyboxBackground::GetTextureSampler()
{
return m_sampler;
}
inline const NzTextureSampler& NzSkyboxBackground::GetTextureSampler() const
{
return m_sampler;
}
inline void NzSkyboxBackground::SetTexture(NzTextureRef cubemapTexture)
{
NazaraAssert(!cubemapTexture || cubemapTexture->IsValid(), "Invalid texture");
NazaraAssert(!cubemapTexture || cubemapTexture->IsCubemap(), "Texture must be a cubemap");
m_texture = std::move(cubemapTexture);
}
void NzSkyboxBackground::SetTextureSampler(const NzTextureSampler& sampler)
{
m_sampler = sampler;
}
template<typename... Args>
NzSkyboxBackgroundRef NzSkyboxBackground::New(Args&&... args)
{
std::unique_ptr<NzSkyboxBackground> object(new NzSkyboxBackground(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@@ -12,18 +12,24 @@
#include <Nazara/Renderer/UberShader.hpp>
#include <Nazara/Renderer/Texture.hpp>
class NzTextureBackground;
using NzTextureBackgroundConstRef = NzObjectRef<const NzTextureBackground>;
using NzTextureBackgroundRef = NzObjectRef<NzTextureBackground>;
class NAZARA_GRAPHICS_API NzTextureBackground : public NzAbstractBackground
{
public:
NzTextureBackground();
NzTextureBackground(NzTexture* texture);
NzTextureBackground(NzTextureRef texture = NzTextureRef());
void Draw(const NzAbstractViewer* viewer) const;
nzBackgroundType GetBackgroundType() const;
NzTexture* GetTexture() const;
inline const NzTextureRef& GetTexture() const;
void SetTexture(NzTexture* texture);
inline void SetTexture(NzTextureRef texture);
template<typename... Args> static NzTextureBackgroundRef New(Args&&... args);
private:
NzTextureRef m_texture;
@@ -34,4 +40,6 @@ class NAZARA_GRAPHICS_API NzTextureBackground : public NzAbstractBackground
int m_vertexDepthUniform;
};
#include <Nazara/Graphics/TextureBackground.inl>
#endif // NAZARA_TEXTUREBACKGROUND_HPP

View File

@@ -0,0 +1,29 @@
// 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>
inline const NzTextureRef& NzTextureBackground::GetTexture() const
{
return m_texture;
}
inline void NzTextureBackground::SetTexture(NzTextureRef texture)
{
NazaraAssert(!texture || texture->IsValid(), "Invalid texture");
m_texture = std::move(texture);
}
template<typename... Args>
NzTextureBackgroundRef NzTextureBackground::New(Args&&... args)
{
std::unique_ptr<NzTextureBackground> object(new NzTextureBackground(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
#include <Nazara/Graphics/DebugOff.hpp>