Switch from Nz prefix to namespace Nz
What a huge commit Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
@@ -20,114 +20,117 @@
|
||||
#include <Nazara/Utility/CubemapParams.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
|
||||
class NzTexture;
|
||||
|
||||
using NzTextureConstRef = NzObjectRef<const NzTexture>;
|
||||
using NzTextureLibrary = NzObjectLibrary<NzTexture>;
|
||||
using NzTextureManager = NzResourceManager<NzTexture, NzImageParams>;
|
||||
using NzTextureRef = NzObjectRef<NzTexture>;
|
||||
|
||||
struct NzTextureImpl;
|
||||
|
||||
class NAZARA_RENDERER_API NzTexture : public NzAbstractImage, public NzRefCounted, public NzResource
|
||||
namespace Nz
|
||||
{
|
||||
friend NzTextureLibrary;
|
||||
friend NzTextureManager;
|
||||
friend class NzRenderer;
|
||||
class Texture;
|
||||
|
||||
public:
|
||||
NzTexture() = default;
|
||||
NzTexture(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
explicit NzTexture(const NzImage& image);
|
||||
NzTexture(const NzTexture&) = delete;
|
||||
NzTexture(NzTexture&&) = delete;
|
||||
~NzTexture();
|
||||
using TextureConstRef = ObjectRef<const Texture>;
|
||||
using TextureLibrary = ObjectLibrary<Texture>;
|
||||
using TextureManager = ResourceManager<Texture, ImageParams>;
|
||||
using TextureRef = ObjectRef<Texture>;
|
||||
|
||||
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
void Destroy();
|
||||
struct TextureImpl;
|
||||
|
||||
bool Download(NzImage* image) const;
|
||||
class NAZARA_RENDERER_API Texture : public AbstractImage, public RefCounted, public Resource
|
||||
{
|
||||
friend TextureLibrary;
|
||||
friend TextureManager;
|
||||
friend class Renderer;
|
||||
|
||||
bool EnableMipmapping(bool enable);
|
||||
public:
|
||||
Texture() = default;
|
||||
Texture(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
|
||||
explicit Texture(const Image& image);
|
||||
Texture(const Texture&) = delete;
|
||||
Texture(Texture&&) = delete;
|
||||
~Texture();
|
||||
|
||||
void EnsureMipmapsUpdate() const;
|
||||
bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
|
||||
void Destroy();
|
||||
|
||||
unsigned int GetDepth(nzUInt8 level = 0) const;
|
||||
nzPixelFormat GetFormat() const;
|
||||
unsigned int GetHeight(nzUInt8 level = 0) const;
|
||||
nzUInt8 GetLevelCount() const;
|
||||
nzUInt8 GetMaxLevel() const;
|
||||
unsigned int GetMemoryUsage() const;
|
||||
unsigned int GetMemoryUsage(nzUInt8 level) const;
|
||||
NzVector3ui GetSize(nzUInt8 level = 0) const;
|
||||
nzImageType GetType() const;
|
||||
unsigned int GetWidth(nzUInt8 level = 0) const;
|
||||
bool Download(Image* image) const;
|
||||
|
||||
bool HasMipmaps() const;
|
||||
bool EnableMipmapping(bool enable);
|
||||
|
||||
void InvalidateMipmaps();
|
||||
bool IsValid() const;
|
||||
void EnsureMipmapsUpdate() const;
|
||||
|
||||
// Load
|
||||
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromImage(const NzImage& image, bool generateMipmaps = true);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
unsigned int GetDepth(UInt8 level = 0) const;
|
||||
PixelFormatType GetFormat() const;
|
||||
unsigned int GetHeight(UInt8 level = 0) const;
|
||||
UInt8 GetLevelCount() const;
|
||||
UInt8 GetMaxLevel() const;
|
||||
unsigned int GetMemoryUsage() const;
|
||||
unsigned int GetMemoryUsage(UInt8 level) const;
|
||||
Vector3ui GetSize(UInt8 level = 0) const;
|
||||
ImageType GetType() const;
|
||||
unsigned int GetWidth(UInt8 level = 0) const;
|
||||
|
||||
// LoadArray
|
||||
bool LoadArrayFromFile(const NzString& filePath, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
|
||||
bool LoadArrayFromImage(const NzImage& image, bool generateMipmaps = true, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
|
||||
bool LoadArrayFromMemory(const void* data, std::size_t size, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
|
||||
bool LoadArrayFromStream(NzInputStream& stream, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
|
||||
bool HasMipmaps() const;
|
||||
|
||||
// LoadCubemap
|
||||
bool LoadCubemapFromFile(const NzString& filePath, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzCubemapParams& cubemapParams = NzCubemapParams());
|
||||
bool LoadCubemapFromImage(const NzImage& image, bool generateMipmaps = true, const NzCubemapParams& params = NzCubemapParams());
|
||||
bool LoadCubemapFromMemory(const void* data, std::size_t size, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzCubemapParams& cubemapParams = NzCubemapParams());
|
||||
bool LoadCubemapFromStream(NzInputStream& stream, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzCubemapParams& cubemapParams = NzCubemapParams());
|
||||
void InvalidateMipmaps();
|
||||
bool IsValid() const;
|
||||
|
||||
// LoadFace
|
||||
bool LoadFaceFromFile(nzCubemapFace face, const NzString& filePath, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFaceFromMemory(nzCubemapFace face, const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFaceFromStream(nzCubemapFace face, NzInputStream& stream, const NzImageParams& params = NzImageParams());
|
||||
// Load
|
||||
bool LoadFromFile(const String& filePath, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromImage(const Image& image, bool generateMipmaps = true);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromStream(InputStream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
|
||||
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
|
||||
// LoadArray
|
||||
bool LoadArrayFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromStream(InputStream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
|
||||
bool Update(const NzImage& image, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzBoxui& box, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
// LoadCubemap
|
||||
bool LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
bool LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams());
|
||||
bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
bool LoadCubemapFromStream(InputStream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
// LoadFace
|
||||
bool LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params = ImageParams());
|
||||
bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams());
|
||||
bool LoadFaceFromStream(CubemapFace face, InputStream& stream, const ImageParams& params = ImageParams());
|
||||
|
||||
NzTexture& operator=(const NzTexture&) = delete;
|
||||
NzTexture& operator=(NzTexture&&) = delete;
|
||||
bool SetMipmapRange(UInt8 minLevel, UInt8 maxLevel);
|
||||
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(nzPixelFormat format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(nzImageType type);
|
||||
template<typename... Args> static NzTextureRef New(Args&&... args);
|
||||
bool Update(const Image& image, UInt8 level = 0);
|
||||
bool Update(const Image& image, const Boxui& box, UInt8 level = 0);
|
||||
bool Update(const Image& image, const Rectui& rect, unsigned int z = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnTextureDestroy, const NzTexture* /*texture*/);
|
||||
NazaraSignal(OnTextureRelease, const NzTexture* /*texture*/);
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
private:
|
||||
bool CreateTexture(bool proxy);
|
||||
Texture& operator=(const Texture&) = delete;
|
||||
Texture& operator=(Texture&&) = delete;
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(PixelFormatType format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(ImageType type);
|
||||
template<typename... Args> static TextureRef New(Args&&... args);
|
||||
|
||||
NzTextureImpl* m_impl = nullptr;
|
||||
// Signals:
|
||||
NazaraSignal(OnTextureDestroy, const Texture* /*texture*/);
|
||||
NazaraSignal(OnTextureRelease, const Texture* /*texture*/);
|
||||
|
||||
static NzTextureLibrary::LibraryMap s_library;
|
||||
static NzTextureManager::ManagerMap s_managerMap;
|
||||
static NzTextureManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
private:
|
||||
bool CreateTexture(bool proxy);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
TextureImpl* m_impl = nullptr;
|
||||
|
||||
static TextureLibrary::LibraryMap s_library;
|
||||
static TextureManager::ManagerMap s_managerMap;
|
||||
static TextureManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/Texture.inl>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user