Graphics/Backgrounds: Update backgrounds to new coding-style
Former-commit-id: 9f96b93706fd8417d6262392f0ce9ab9ca1985c3
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
17
include/Nazara/Graphics/ColorBackground.inl
Normal file
17
include/Nazara/Graphics/ColorBackground.inl
Normal 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>
|
||||
@@ -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
|
||||
|
||||
45
include/Nazara/Graphics/SkyboxBackground.inl
Normal file
45
include/Nazara/Graphics/SkyboxBackground.inl
Normal 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>
|
||||
@@ -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
|
||||
|
||||
29
include/Nazara/Graphics/TextureBackground.inl
Normal file
29
include/Nazara/Graphics/TextureBackground.inl
Normal 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>
|
||||
Reference in New Issue
Block a user