PixelFormat rename

PixelFormatInfo => PixelFormatDescription
PixelFormat => PixelFormatInfo
PixelFormatType => PixelFormat
This commit is contained in:
Lynix 2020-04-10 14:19:36 +02:00
parent 87f1209327
commit 9507c56fc9
35 changed files with 582 additions and 582 deletions

View File

@ -124,7 +124,7 @@ LogoExample::LogoExample(ExampleShared& sharedData) :
ParticleDemo("Logo", sharedData)
{
Nz::ImageParams params;
params.loadFormat = Nz::PixelFormatType_RGBA8;
params.loadFormat = Nz::PixelFormat_RGBA8;
m_logo = Nz::Image::LoadFromFile("E:/Twitch/avatar_interested.png", params);
if (!m_logo)

View File

@ -294,7 +294,7 @@ ParticleDemo("Space battle", sharedData)
}
Nz::TextureRef skyboxCubemap = Nz::Texture::New();
if (skyboxCubemap->Create(Nz::ImageType_Cubemap, Nz::PixelFormatType_RGBA8, 2048, 2048))
if (skyboxCubemap->Create(Nz::ImageType_Cubemap, Nz::PixelFormat_RGBA8, 2048, 2048))
{
skyboxCubemap->LoadFaceFromFile(Nz::CubemapFace_PositiveX, "resources/purple_nebula_skybox/purple_nebula_skybox_right1.png");
skyboxCubemap->LoadFaceFromFile(Nz::CubemapFace_PositiveY, "resources/purple_nebula_skybox/purple_nebula_skybox_top3.png");

View File

@ -169,7 +169,7 @@ int main()
case Nz::Keyboard::F5:
{
Nz::Image screenshot;
screenshot.Create(Nz::ImageType_2D, Nz::PixelFormatType_RGBA8, 1920, 1080);
screenshot.Create(Nz::ImageType_2D, Nz::PixelFormat_RGBA8, 1920, 1080);
window.CopyToImage(&screenshot);
static unsigned int counter = 1;

View File

@ -116,7 +116,7 @@ int main()
// Texture
Nz::ImageRef drfreakImage = Nz::Image::LoadFromFile("resources/Spaceship/Texture/diffuse.png");
if (!drfreakImage || !drfreakImage->Convert(Nz::PixelFormatType_RGBA8))
if (!drfreakImage || !drfreakImage->Convert(Nz::PixelFormat_RGBA8))
{
NazaraError("Failed to load image");
return __LINE__;

View File

@ -47,7 +47,7 @@ namespace Nz
inline float GetOuterAngleTangent() const;
inline float GetRadius() const;
inline TextureRef GetShadowMap() const;
inline PixelFormatType GetShadowMapFormat() const;
inline PixelFormat GetShadowMapFormat() const;
inline const Vector2ui& GetShadowMapSize() const;
inline bool IsShadowCastingEnabled() const;
@ -60,7 +60,7 @@ namespace Nz
inline void SetLightType(LightType type);
inline void SetOuterAngle(float outerAngle);
inline void SetRadius(float radius);
inline void SetShadowMapFormat(PixelFormatType shadowFormat);
inline void SetShadowMapFormat(PixelFormat shadowFormat);
inline void SetShadowMapSize(const Vector2ui& size);
void UpdateBoundingVolume(const Matrix4f& transformMatrix) override;
@ -75,7 +75,7 @@ namespace Nz
Color m_color;
LightType m_type;
PixelFormatType m_shadowMapFormat;
PixelFormat m_shadowMapFormat;
Vector2ui m_shadowMapSize;
mutable TextureRef m_shadowMap;
bool m_shadowCastingEnabled;

View File

@ -194,7 +194,7 @@ namespace Nz
* \return Shadow map format
*/
inline PixelFormatType Light::GetShadowMapFormat() const
inline PixelFormat Light::GetShadowMapFormat() const
{
return m_shadowMapFormat;
}
@ -331,9 +331,9 @@ namespace Nz
* \remark Produces a NazaraAssert if format is not a depth type
*/
inline void Light::SetShadowMapFormat(PixelFormatType shadowFormat)
inline void Light::SetShadowMapFormat(PixelFormat shadowFormat)
{
NazaraAssert(PixelFormat::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format");
NazaraAssert(PixelFormatInfo::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format");
m_shadowMapFormat = shadowFormat;

View File

@ -15,7 +15,7 @@ namespace Nz
{
struct RenderWindowParameters
{
std::vector<PixelFormatType> depthFormats = {Nz::PixelFormatType_Depth32, Nz::PixelFormatType_Depth24}; //< By order of preference
std::vector<PixelFormat> depthFormats = {Nz::PixelFormat_Depth32, Nz::PixelFormat_Depth24}; //< By order of preference
bool verticalSync = false;
};
}

View File

@ -17,7 +17,7 @@ namespace Nz
{
struct TextureInfo
{
PixelFormatType pixelFormat;
PixelFormat pixelFormat;
ImageType type;
unsigned int depth = 1;
unsigned int height;
@ -33,7 +33,7 @@ namespace Nz
Texture(Texture&&) = delete;
virtual ~Texture();
virtual PixelFormatType GetFormat() const = 0;
virtual PixelFormat GetFormat() const = 0;
virtual UInt8 GetLevelCount() const = 0;
virtual Vector3ui GetSize(UInt8 level = 0) const = 0;
virtual ImageType GetType() const = 0;

View File

@ -31,7 +31,7 @@ namespace Nz
UInt8 GetBytesPerPixel() const;
virtual unsigned int GetDepth(UInt8 level = 0) const = 0;
virtual PixelFormatType GetFormat() const = 0;
virtual PixelFormat GetFormat() const = 0;
virtual unsigned int GetHeight(UInt8 level = 0) const = 0;
virtual UInt8 GetLevelCount() const = 0;
virtual UInt8 GetMaxLevel() const = 0;

View File

@ -165,64 +165,64 @@ namespace Nz
PixelFormatContent_Max = PixelFormatContent_Stencil
};
enum PixelFormatType
enum PixelFormat
{
PixelFormatType_Undefined = -1,
PixelFormat_Undefined = -1,
PixelFormatType_A8, // 1*uint8
PixelFormatType_BGR8, // 3*uint8
PixelFormatType_BGRA8, // 4*uint8
PixelFormatType_DXT1,
PixelFormatType_DXT3,
PixelFormatType_DXT5,
PixelFormatType_L8, // 1*uint8
PixelFormatType_LA8, // 2*uint8
PixelFormatType_R8, // 1*uint8
PixelFormatType_R8I, // 1*int8
PixelFormatType_R8UI, // 1*uint8
PixelFormatType_R16, // 1*uint16
PixelFormatType_R16F, // 1*half
PixelFormatType_R16I, // 1*int16
PixelFormatType_R16UI, // 1*uint16
PixelFormatType_R32F, // 1*float
PixelFormatType_R32I, // 1*uint16
PixelFormatType_R32UI, // 1*uint32
PixelFormatType_RG8, // 2*int8
PixelFormatType_RG8I, // 2*int8
PixelFormatType_RG8UI, // 2*uint8
PixelFormatType_RG16, // 2*uint16
PixelFormatType_RG16F, // 2*half
PixelFormatType_RG16I, // 2*int16
PixelFormatType_RG16UI, // 2*uint16
PixelFormatType_RG32F, // 2*float
PixelFormatType_RG32I, // 2*uint16
PixelFormatType_RG32UI, // 2*uint32
PixelFormatType_RGB5A1, // 3*uint5 + alpha bit
PixelFormatType_RGB8, // 3*uint8
PixelFormatType_RGB16F, // 3*half
PixelFormatType_RGB16I, // 4*int16
PixelFormatType_RGB16UI, // 4*uint16
PixelFormatType_RGB32F, // 3*float
PixelFormatType_RGB32I, // 4*int32
PixelFormatType_RGB32UI, // 4*uint32
PixelFormatType_RGBA4, // 4*uint4
PixelFormatType_RGBA8, // 4*uint8
PixelFormatType_RGBA16F, // 4*half
PixelFormatType_RGBA16I, // 4*int16
PixelFormatType_RGBA16UI, // 4*uint16
PixelFormatType_RGBA32F, // 4*float
PixelFormatType_RGBA32I, // 4*int32
PixelFormatType_RGBA32UI, // 4*uint32
PixelFormatType_Depth16,
PixelFormatType_Depth24,
PixelFormatType_Depth24Stencil8,
PixelFormatType_Depth32,
PixelFormatType_Stencil1,
PixelFormatType_Stencil4,
PixelFormatType_Stencil8,
PixelFormatType_Stencil16,
PixelFormat_A8, // 1*uint8
PixelFormat_BGR8, // 3*uint8
PixelFormat_BGRA8, // 4*uint8
PixelFormat_DXT1,
PixelFormat_DXT3,
PixelFormat_DXT5,
PixelFormat_L8, // 1*uint8
PixelFormat_LA8, // 2*uint8
PixelFormat_R8, // 1*uint8
PixelFormat_R8I, // 1*int8
PixelFormat_R8UI, // 1*uint8
PixelFormat_R16, // 1*uint16
PixelFormat_R16F, // 1*half
PixelFormat_R16I, // 1*int16
PixelFormat_R16UI, // 1*uint16
PixelFormat_R32F, // 1*float
PixelFormat_R32I, // 1*uint16
PixelFormat_R32UI, // 1*uint32
PixelFormat_RG8, // 2*int8
PixelFormat_RG8I, // 2*int8
PixelFormat_RG8UI, // 2*uint8
PixelFormat_RG16, // 2*uint16
PixelFormat_RG16F, // 2*half
PixelFormat_RG16I, // 2*int16
PixelFormat_RG16UI, // 2*uint16
PixelFormat_RG32F, // 2*float
PixelFormat_RG32I, // 2*uint16
PixelFormat_RG32UI, // 2*uint32
PixelFormat_RGB5A1, // 3*uint5 + alpha bit
PixelFormat_RGB8, // 3*uint8
PixelFormat_RGB16F, // 3*half
PixelFormat_RGB16I, // 4*int16
PixelFormat_RGB16UI, // 4*uint16
PixelFormat_RGB32F, // 3*float
PixelFormat_RGB32I, // 4*int32
PixelFormat_RGB32UI, // 4*uint32
PixelFormat_RGBA4, // 4*uint4
PixelFormat_RGBA8, // 4*uint8
PixelFormat_RGBA16F, // 4*half
PixelFormat_RGBA16I, // 4*int16
PixelFormat_RGBA16UI, // 4*uint16
PixelFormat_RGBA32F, // 4*float
PixelFormat_RGBA32I, // 4*int32
PixelFormat_RGBA32UI, // 4*uint32
PixelFormat_Depth16,
PixelFormat_Depth24,
PixelFormat_Depth24Stencil8,
PixelFormat_Depth32,
PixelFormat_Stencil1,
PixelFormat_Stencil4,
PixelFormat_Stencil8,
PixelFormat_Stencil16,
PixelFormatType_Max = PixelFormatType_Stencil16
PixelFormat_Max = PixelFormat_Stencil16
};
enum PixelFormatSubType

View File

@ -27,7 +27,7 @@ namespace Nz
struct NAZARA_UTILITY_API ImageParams : ResourceParameters
{
// Le format dans lequel l'image doit être chargée (Undefined pour le format le plus proche de l'original)
PixelFormatType loadFormat = PixelFormatType_Undefined;
PixelFormat loadFormat = PixelFormat_Undefined;
// Le nombre de niveaux de mipmaps maximum devant être créé
UInt8 levelCount = 0;
@ -56,16 +56,16 @@ namespace Nz
struct SharedImage;
Image();
Image(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
Image(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
Image(const Image& image);
Image(SharedImage* sharedImage);
~Image();
bool Convert(PixelFormatType format);
bool Convert(PixelFormat format);
void Copy(const Image* source, const Boxui& srcBox, const Vector3ui& dstPos);
bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
bool Create(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
void Destroy();
bool Fill(const Color& color);
@ -77,7 +77,7 @@ namespace Nz
const UInt8* GetConstPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, UInt8 level = 0) const;
unsigned int GetDepth(UInt8 level = 0) const override;
PixelFormatType GetFormat() const override;
PixelFormat GetFormat() const override;
unsigned int GetHeight(UInt8 level = 0) const override;
UInt8 GetLevelCount() const override;
UInt8 GetMaxLevel() const override;
@ -113,7 +113,7 @@ namespace Nz
Image& operator=(const Image& image);
static void Copy(UInt8* destination, const UInt8* source, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, unsigned int dstWidth = 0, unsigned int dstHeight = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0);
static void Copy(UInt8* destination, const UInt8* source, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, unsigned int dstWidth = 0, unsigned int dstHeight = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0);
static UInt8 GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth = 1);
static UInt8 GetMaxLevel(ImageType type, unsigned int width, unsigned int height, unsigned int depth = 1);
@ -140,7 +140,7 @@ namespace Nz
{
using PixelContainer = std::vector<std::unique_ptr<UInt8[]>>;
SharedImage(unsigned short RefCount, ImageType Type, PixelFormatType Format, PixelContainer&& Levels, unsigned int Width, unsigned int Height, unsigned int Depth) :
SharedImage(unsigned short RefCount, ImageType Type, PixelFormat Format, PixelContainer&& Levels, unsigned int Width, unsigned int Height, unsigned int Depth) :
type(Type),
format(Format),
levels(std::move(Levels)),
@ -152,7 +152,7 @@ namespace Nz
}
ImageType type;
PixelFormatType format;
PixelFormat format;
PixelContainer levels;
unsigned int depth;
unsigned int height;

View File

@ -21,13 +21,13 @@
namespace Nz
{
struct PixelFormatInfo
struct PixelFormatDescription
{
inline PixelFormatInfo();
inline PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType);
inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0);
inline PixelFormatDescription();
inline PixelFormatDescription(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
inline PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType);
inline PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0);
inline void Clear();
@ -52,7 +52,7 @@ namespace Nz
UInt8 bitsPerPixel;
};
class NAZARA_UTILITY_API PixelFormat
class NAZARA_UTILITY_API PixelFormatInfo
{
friend class Utility;
@ -60,37 +60,37 @@ namespace Nz
using ConvertFunction = std::function<UInt8*(const UInt8* start, const UInt8* end, UInt8* dst)>;
using FlipFunction = std::function<void(unsigned int width, unsigned int height, unsigned int depth, const UInt8* src, UInt8* dst)>;
static inline std::size_t ComputeSize(PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth);
static inline std::size_t ComputeSize(PixelFormat format, unsigned int width, unsigned int height, unsigned int depth);
static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst);
static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst);
static inline bool Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* src, void* dst);
static inline bool Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* start, const void* end, void* dst);
static bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst);
static bool Flip(PixelFlipping flipping, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst);
static inline UInt8 GetBitsPerPixel(PixelFormatType format);
static inline PixelFormatContent GetContent(PixelFormatType format);
static inline UInt8 GetBytesPerPixel(PixelFormatType format);
static inline const PixelFormatInfo& GetInfo(PixelFormatType format);
static inline const String& GetName(PixelFormatType format);
static inline UInt8 GetBitsPerPixel(PixelFormat format);
static inline PixelFormatContent GetContent(PixelFormat format);
static inline UInt8 GetBytesPerPixel(PixelFormat format);
static inline const PixelFormatDescription& GetInfo(PixelFormat format);
static inline const String& GetName(PixelFormat format);
static inline bool HasAlpha(PixelFormatType format);
static inline bool HasAlpha(PixelFormat format);
static PixelFormatType IdentifyFormat(const PixelFormatInfo& info);
static PixelFormat IdentifyFormat(const PixelFormatDescription& info);
static inline bool IsCompressed(PixelFormatType format);
static inline bool IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat);
static inline bool IsValid(PixelFormatType format);
static inline bool IsCompressed(PixelFormat format);
static inline bool IsConversionSupported(PixelFormat srcFormat, PixelFormat dstFormat);
static inline bool IsValid(PixelFormat format);
static inline void SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func);
static inline void SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func);
static inline void SetConvertFunction(PixelFormat srcFormat, PixelFormat dstFormat, ConvertFunction func);
static inline void SetFlipFunction(PixelFlipping flipping, PixelFormat format, FlipFunction func);
private:
static bool Initialize();
static void Uninitialize();
static PixelFormatInfo s_pixelFormatInfos[PixelFormatType_Max + 1];
static ConvertFunction s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1];
static std::map<PixelFormatType, FlipFunction> s_flipFunctions[PixelFlipping_Max+1];
static PixelFormatDescription s_pixelFormatInfos[PixelFormat_Max + 1];
static ConvertFunction s_convertFunctions[PixelFormat_Max+1][PixelFormat_Max+1];
static std::map<PixelFormat, FlipFunction> s_flipFunctions[PixelFlipping_Max+1];
};
}

View File

@ -9,13 +9,13 @@
namespace Nz
{
inline PixelFormatInfo::PixelFormatInfo() :
inline PixelFormatDescription::PixelFormatDescription() :
content(PixelFormatContent_Undefined),
bitsPerPixel(0)
{
}
inline PixelFormatInfo::PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
inline PixelFormatDescription::PixelFormatDescription(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
content(formatContent),
redType(subType),
greenType(subType),
@ -25,7 +25,7 @@ namespace Nz
{
}
inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
inline PixelFormatDescription::PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
content(formatContent),
redType(subType),
greenType(subType),
@ -36,12 +36,12 @@ namespace Nz
{
}
inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) :
PixelFormatInfo(formatName, formatContent, subType, rMask, subType, gMask, subType, bMask, subType, aMask)
inline PixelFormatDescription::PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) :
PixelFormatDescription(formatName, formatContent, subType, rMask, subType, gMask, subType, bMask, subType, aMask)
{
}
inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) :
inline PixelFormatDescription::PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) :
redMask(rMask),
greenMask(gMask),
blueMask(bMask),
@ -62,7 +62,7 @@ namespace Nz
RecomputeBitsPerPixel();
}
inline void PixelFormatInfo::Clear()
inline void PixelFormatDescription::Clear()
{
bitsPerPixel = 0;
alphaMask.Clear();
@ -72,7 +72,7 @@ namespace Nz
name.Clear();
}
inline bool PixelFormatInfo::IsCompressed() const
inline bool PixelFormatDescription::IsCompressed() const
{
return redType == PixelFormatSubType_Compressed ||
greenType == PixelFormatSubType_Compressed ||
@ -80,12 +80,12 @@ namespace Nz
alphaType == PixelFormatSubType_Compressed;
}
inline bool PixelFormatInfo::IsValid() const
inline bool PixelFormatDescription::IsValid() const
{
return bitsPerPixel != 0;
}
inline void PixelFormatInfo::RecomputeBitsPerPixel()
inline void PixelFormatDescription::RecomputeBitsPerPixel()
{
Bitset<> counter;
counter |= redMask;
@ -96,7 +96,7 @@ namespace Nz
bitsPerPixel = static_cast<UInt8>(counter.Count());
}
inline bool PixelFormatInfo::Validate() const
inline bool PixelFormatDescription::Validate() const
{
if (!IsValid())
return false;
@ -143,16 +143,16 @@ namespace Nz
inline std::size_t PixelFormat::ComputeSize(PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth)
inline std::size_t PixelFormatInfo::ComputeSize(PixelFormat format, unsigned int width, unsigned int height, unsigned int depth)
{
if (IsCompressed(format))
{
switch (format)
{
case PixelFormatType_DXT1:
case PixelFormatType_DXT3:
case PixelFormatType_DXT5:
return (((width + 3) / 4) * ((height + 3) / 4) * ((format == PixelFormatType_DXT1) ? 8 : 16)) * depth;
case PixelFormat_DXT1:
case PixelFormat_DXT3:
case PixelFormat_DXT5:
return (((width + 3) / 4) * ((height + 3) / 4) * ((format == PixelFormat_DXT1) ? 8 : 16)) * depth;
default:
NazaraError("Unsupported format");
@ -163,7 +163,7 @@ namespace Nz
return width * height * depth * GetBytesPerPixel(format);
}
inline bool PixelFormat::Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst)
inline bool PixelFormatInfo::Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* src, void* dst)
{
if (srcFormat == dstFormat)
{
@ -201,7 +201,7 @@ namespace Nz
return true;
}
inline bool PixelFormat::Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst)
inline bool PixelFormatInfo::Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* start, const void* end, void* dst)
{
if (srcFormat == dstFormat)
{
@ -225,42 +225,42 @@ namespace Nz
return true;
}
inline UInt8 PixelFormat::GetBitsPerPixel(PixelFormatType format)
inline UInt8 PixelFormatInfo::GetBitsPerPixel(PixelFormat format)
{
return s_pixelFormatInfos[format].bitsPerPixel;
}
inline UInt8 PixelFormat::GetBytesPerPixel(PixelFormatType format)
inline UInt8 PixelFormatInfo::GetBytesPerPixel(PixelFormat format)
{
return GetBitsPerPixel(format)/8;
}
inline PixelFormatContent PixelFormat::GetContent(PixelFormatType format)
inline PixelFormatContent PixelFormatInfo::GetContent(PixelFormat format)
{
return s_pixelFormatInfos[format].content;
}
inline const PixelFormatInfo& PixelFormat::GetInfo(PixelFormatType format)
inline const PixelFormatDescription& PixelFormatInfo::GetInfo(PixelFormat format)
{
return s_pixelFormatInfos[format];
}
inline const String& PixelFormat::GetName(PixelFormatType format)
inline const String& PixelFormatInfo::GetName(PixelFormat format)
{
return s_pixelFormatInfos[format].name;
}
inline bool PixelFormat::HasAlpha(PixelFormatType format)
inline bool PixelFormatInfo::HasAlpha(PixelFormat format)
{
return s_pixelFormatInfos[format].alphaMask.TestAny();
}
inline bool PixelFormat::IsCompressed(PixelFormatType format)
inline bool PixelFormatInfo::IsCompressed(PixelFormat format)
{
return s_pixelFormatInfos[format].IsCompressed();
}
inline bool PixelFormat::IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat)
inline bool PixelFormatInfo::IsConversionSupported(PixelFormat srcFormat, PixelFormat dstFormat)
{
if (srcFormat == dstFormat)
return true;
@ -268,17 +268,17 @@ namespace Nz
return s_convertFunctions[srcFormat][dstFormat] != nullptr;
}
inline bool PixelFormat::IsValid(PixelFormatType format)
inline bool PixelFormatInfo::IsValid(PixelFormat format)
{
return format != PixelFormatType_Undefined;
return format != PixelFormat_Undefined;
}
inline void PixelFormat::SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func)
inline void PixelFormatInfo::SetConvertFunction(PixelFormat srcFormat, PixelFormat dstFormat, ConvertFunction func)
{
s_convertFunctions[srcFormat][dstFormat] = func;
}
inline void PixelFormat::SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func)
inline void PixelFormatInfo::SetFlipFunction(PixelFlipping flipping, PixelFormat format, FlipFunction func)
{
s_flipFunctions[flipping][format] = func;
}

View File

@ -23,7 +23,7 @@ namespace Nz
VulkanTexture(VulkanTexture&&) noexcept = default;
~VulkanTexture();
PixelFormatType GetFormat() const override;
PixelFormat GetFormat() const override;
inline VkImage GetImage() const;
inline VkImageView GetImageView() const;
UInt8 GetLevelCount() const override;
@ -36,7 +36,7 @@ namespace Nz
VulkanTexture& operator=(VulkanTexture&&) = delete;
private:
static void InitForFormat(PixelFormatType pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView);
static void InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView);
VkImage m_image;
VmaAllocation m_allocation;

View File

@ -185,7 +185,7 @@ namespace Nz
m_bloomRTT.Create(true);
for (unsigned int i = 0; i < 2; ++i)
{
m_bloomTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, dimensions.x / 8, dimensions.y / 8);
m_bloomTextures[i]->Create(ImageType_2D, PixelFormat_RGBA8, dimensions.x / 8, dimensions.y / 8);
m_bloomRTT.AttachTexture(AttachmentPoint_Color, i, m_bloomTextures[i]);
}
m_bloomRTT.Unlock();

View File

@ -197,7 +197,7 @@ namespace Nz
m_dofRTT.Create(true);
for (unsigned int i = 0; i < 2; ++i)
{
m_dofTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, dimensions.x/4, dimensions.y/4);
m_dofTextures[i]->Create(ImageType_2D, PixelFormat_RGBA8, dimensions.x/4, dimensions.y/4);
m_dofRTT.AttachTexture(AttachmentPoint_Color, i, m_dofTextures[i]);
}
m_dofRTT.Unlock();

View File

@ -147,11 +147,11 @@ namespace Nz
unsigned int width = dimensions.x;
unsigned int height = dimensions.y;
m_depthStencilTexture->Create(ImageType_2D, PixelFormatType_Depth24Stencil8, width, height);
m_depthStencilTexture->Create(ImageType_2D, PixelFormat_Depth24Stencil8, width, height);
m_GBuffer[0]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); // Texture 0 : Diffuse Color + Specular
m_GBuffer[1]->Create(ImageType_2D, PixelFormatType_RG16F, width, height); // Texture 1 : Encoded normal
m_GBuffer[2]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); // Texture 2 : Depth (24bits) + Shininess
m_GBuffer[0]->Create(ImageType_2D, PixelFormat_RGBA8, width, height); // Texture 0 : Diffuse Color + Specular
m_GBuffer[1]->Create(ImageType_2D, PixelFormat_RG16F, width, height); // Texture 1 : Encoded normal
m_GBuffer[2]->Create(ImageType_2D, PixelFormat_RGBA8, width, height); // Texture 2 : Depth (24bits) + Shininess
m_GBufferRTT->Create(true);
@ -169,7 +169,7 @@ namespace Nz
for (unsigned int i = 0; i < 2; ++i)
{
m_workTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height);
m_workTextures[i]->Create(ImageType_2D, PixelFormat_RGBA8, width, height);
m_workRTT->AttachTexture(AttachmentPoint_Color, i, m_workTextures[i]);
}

View File

@ -160,13 +160,13 @@ namespace Nz
std::array<UInt8, 6> whitePixels = { { 255, 255, 255, 255, 255, 255 } };
Nz::TextureRef whiteTexture = Nz::Texture::New();
whiteTexture->Create(ImageType_2D, PixelFormatType_L8, 1, 1);
whiteTexture->Create(ImageType_2D, PixelFormat_L8, 1, 1);
whiteTexture->Update(whitePixels.data());
TextureLibrary::Register("White2D", std::move(whiteTexture));
Nz::TextureRef whiteCubemap = Nz::Texture::New();
whiteCubemap->Create(ImageType_Cubemap, PixelFormatType_L8, 1, 1);
whiteCubemap->Create(ImageType_Cubemap, PixelFormat_L8, 1, 1);
whiteCubemap->Update(whitePixels.data());
TextureLibrary::Register("WhiteCubemap", std::move(whiteCubemap));

View File

@ -37,7 +37,7 @@ namespace Nz
AbstractImage* GuillotineTextureAtlas::ResizeImage(AbstractImage* oldImage, const Vector2ui& size) const
{
std::unique_ptr<Texture> newTexture(new Texture);
if (newTexture->Create(ImageType_2D, PixelFormatType_A8, size.x, size.y, 1))
if (newTexture->Create(ImageType_2D, PixelFormat_A8, size.x, size.y, 1))
{
if (oldImage)
{

View File

@ -29,7 +29,7 @@ namespace Nz
Light::Light(LightType type) :
m_type(type),
m_shadowMapFormat(PixelFormatType_Depth16),
m_shadowMapFormat(PixelFormat_Depth16),
m_shadowMapSize(512, 512),
m_shadowCastingEnabled(false),
m_shadowMapUpdated(false)

View File

@ -13,7 +13,7 @@ namespace Nz
bool CursorImpl::Create(const Image& cursor, int hotSpotX, int hotSpotY)
{
Image windowsCursor(cursor);
if (!windowsCursor.Convert(PixelFormatType_BGRA8))
if (!windowsCursor.Convert(PixelFormat_BGRA8))
{
NazaraError("Failed to convert cursor to BGRA8");
return false;

View File

@ -12,7 +12,7 @@ namespace Nz
bool IconImpl::Create(const Image& icon)
{
Image windowsIcon(icon); // Vive le COW
if (!windowsIcon.Convert(PixelFormatType_BGRA8))
if (!windowsIcon.Convert(PixelFormat_BGRA8))
{
NazaraError("Failed to convert icon to BGRA8");
return false;

View File

@ -12,12 +12,12 @@ namespace Nz
UInt8 AbstractImage::GetBytesPerPixel() const
{
return PixelFormat::GetBytesPerPixel(GetFormat());
return PixelFormatInfo::GetBytesPerPixel(GetFormat());
}
bool AbstractImage::IsCompressed() const
{
return PixelFormat::IsCompressed(GetFormat());
return PixelFormatInfo::IsCompressed(GetFormat());
}
bool AbstractImage::IsCubemap() const

View File

@ -84,7 +84,7 @@ namespace Nz
return nullptr;
// Then the format
PixelFormatType format;
PixelFormat format;
if (!IdentifyPixelFormat(header, headerDX10, &format))
return nullptr;
@ -93,7 +93,7 @@ namespace Nz
// Read all mipmap levels
for (unsigned int i = 0; i < image->GetLevelCount(); i++)
{
std::size_t byteCount = PixelFormat::ComputeSize(format, width, height, depth);
std::size_t byteCount = PixelFormatInfo::ComputeSize(format, width, height, depth);
UInt8* ptr = image->GetPixels(0, 0, 0, i);
@ -114,7 +114,7 @@ namespace Nz
}
if (parameters.loadFormat != PixelFormatType_Undefined)
if (parameters.loadFormat != PixelFormat_Undefined)
image->Convert(parameters.loadFormat);
return image;
@ -163,11 +163,11 @@ namespace Nz
return true;
}
static bool IdentifyPixelFormat(const DDSHeader& header, const DDSHeaderDX10Ext& headerExt, PixelFormatType* format)
static bool IdentifyPixelFormat(const DDSHeader& header, const DDSHeaderDX10Ext& headerExt, PixelFormat* format)
{
if (header.format.flags & (DDPF_RGB | DDPF_ALPHA | DDPF_ALPHAPIXELS | DDPF_LUMINANCE))
{
PixelFormatInfo info(PixelFormatContent_ColorRGBA, header.format.bpp, PixelFormatSubType_Unsigned);
PixelFormatDescription info(PixelFormatContent_ColorRGBA, header.format.bpp, PixelFormatSubType_Unsigned);
if (header.format.flags & DDPF_RGB)
{
@ -182,8 +182,8 @@ namespace Nz
if (header.format.flags & (DDPF_ALPHA | DDPF_ALPHAPIXELS))
info.alphaMask = header.format.alphaMask;
*format = PixelFormat::IdentifyFormat(info);
if (!PixelFormat::IsValid(*format))
*format = PixelFormatInfo::IdentifyFormat(info);
if (!PixelFormatInfo::IsValid(*format))
return false;
}
else if (header.format.flags & DDPF_FOURCC)
@ -191,15 +191,15 @@ namespace Nz
switch (header.format.fourCC)
{
case D3DFMT_DXT1:
*format = PixelFormatType_DXT1;
*format = PixelFormat_DXT1;
break;
case D3DFMT_DXT3:
*format = PixelFormatType_DXT3;
*format = PixelFormat_DXT3;
break;
case D3DFMT_DXT5:
*format = PixelFormatType_DXT3;
*format = PixelFormat_DXT3;
break;
case D3DFMT_DX10:
@ -207,30 +207,30 @@ namespace Nz
switch (headerExt.dxgiFormat)
{
case DXGI_FORMAT_R32G32B32A32_FLOAT:
*format = PixelFormatType_RGBA32F;
*format = PixelFormat_RGBA32F;
break;
case DXGI_FORMAT_R32G32B32A32_UINT:
*format = PixelFormatType_RGBA32UI;
*format = PixelFormat_RGBA32UI;
break;
case DXGI_FORMAT_R32G32B32A32_SINT:
*format = PixelFormatType_RGBA32I;
*format = PixelFormat_RGBA32I;
break;
case DXGI_FORMAT_R32G32B32_FLOAT:
*format = PixelFormatType_RGB32F;
*format = PixelFormat_RGB32F;
break;
case DXGI_FORMAT_R32G32B32_UINT:
//*format = PixelFormatType_RGB32U;
//*format = PixelFormat_RGB32U;
return false;
case DXGI_FORMAT_R32G32B32_SINT:
*format = PixelFormatType_RGB32I;
*format = PixelFormat_RGB32I;
break;
case DXGI_FORMAT_R16G16B16A16_SNORM:
case DXGI_FORMAT_R16G16B16A16_SINT:
case DXGI_FORMAT_R16G16B16A16_UINT:
*format = PixelFormatType_RGBA16I;
*format = PixelFormat_RGBA16I;
break;
case DXGI_FORMAT_R16G16B16A16_UNORM:
*format = PixelFormatType_RGBA16UI;
*format = PixelFormat_RGBA16UI;
break;
}
break;

View File

@ -201,7 +201,7 @@ namespace Nz
if (width > 0 && height > 0)
{
dst->image.Create(ImageType_2D, PixelFormatType_A8, width, height);
dst->image.Create(ImageType_2D, PixelFormat_A8, width, height);
UInt8* pixels = dst->image.GetPixels();
const UInt8* data = bitmap.buffer;

View File

@ -92,7 +92,7 @@ namespace Nz
unsigned int height = header.ymax - header.ymin+1;
ImageRef image = Image::New();
if (!image->Create(ImageType_2D, PixelFormatType_RGB8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1))
if (!image->Create(ImageType_2D, PixelFormat_RGB8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1))
{
NazaraError("Failed to create image");
return nullptr;
@ -333,7 +333,7 @@ namespace Nz
return nullptr;
}
if (parameters.loadFormat != PixelFormatType_Undefined)
if (parameters.loadFormat != PixelFormat_Undefined)
image->Convert(parameters.loadFormat);
return image;

View File

@ -74,7 +74,7 @@ namespace Nz
});
ImageRef image = Image::New();
if (!image->Create(ImageType_2D, PixelFormatType_RGBA8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1))
if (!image->Create(ImageType_2D, PixelFormat_RGBA8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1))
{
NazaraError("Failed to create image");
return nullptr;
@ -84,7 +84,7 @@ namespace Nz
freeStbiImage.CallAndReset();
if (parameters.loadFormat != PixelFormatType_Undefined)
if (parameters.loadFormat != PixelFormat_Undefined)
image->Convert(parameters.loadFormat);
return image;

View File

@ -21,30 +21,30 @@ namespace Nz
{
switch (image.GetFormat())
{
case PixelFormatType_R32F:
case PixelFormat_R32F:
return 1;
case PixelFormatType_RG32F:
case PixelFormat_RG32F:
return 2;
case PixelFormatType_RGB32F:
case PixelFormat_RGB32F:
return 3;
case PixelFormatType_RGBA32F:
case PixelFormat_RGBA32F:
return 4;
default:
{
if (PixelFormat::HasAlpha(image.GetFormat()))
if (PixelFormatInfo::HasAlpha(image.GetFormat()))
{
if (!image.Convert(PixelFormatType_RGBA32F))
if (!image.Convert(PixelFormat_RGBA32F))
break;
return 4;
}
else
{
if (!image.Convert(PixelFormatType_RGB32F))
if (!image.Convert(PixelFormat_RGB32F))
break;
return 3;
@ -59,32 +59,32 @@ namespace Nz
{
switch (image.GetFormat())
{
case PixelFormatType_L8:
case PixelFormatType_R8:
case PixelFormat_L8:
case PixelFormat_R8:
return 1;
case PixelFormatType_LA8:
case PixelFormatType_RG8:
case PixelFormat_LA8:
case PixelFormat_RG8:
return 2;
case PixelFormatType_RGB8:
case PixelFormat_RGB8:
return 3;
case PixelFormatType_RGBA8:
case PixelFormat_RGBA8:
return 4;
default:
{
if (PixelFormat::HasAlpha(image.GetFormat()))
if (PixelFormatInfo::HasAlpha(image.GetFormat()))
{
if (!image.Convert(PixelFormatType_RGBA8))
if (!image.Convert(PixelFormat_RGBA8))
break;
return 4;
}
else
{
if (!image.Convert(PixelFormatType_RGB8))
if (!image.Convert(PixelFormat_RGB8))
break;
return 3;

View File

@ -161,7 +161,7 @@ namespace Nz
AbstractImage* GuillotineImageAtlas::ResizeImage(AbstractImage* oldImage, const Vector2ui& size) const
{
std::unique_ptr<Image> newImage(new Image(ImageType_2D, PixelFormatType_A8, size.x, size.y));
std::unique_ptr<Image> newImage(new Image(ImageType_2D, PixelFormat_A8, size.x, size.y));
if (oldImage)
{
newImage->Copy(static_cast<Image*>(oldImage), Rectui(size), Vector2ui(0, 0)); // Copie des anciennes données

View File

@ -42,7 +42,7 @@ namespace Nz
{
}
Image::Image(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) :
Image::Image(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) :
m_sharedImage(&emptyImage)
{
ErrorFlags flags(ErrorFlag_ThrowException);
@ -70,7 +70,7 @@ namespace Nz
Destroy();
}
bool Image::Convert(PixelFormatType newFormat)
bool Image::Convert(PixelFormat newFormat)
{
#if NAZARA_UTILITY_SAFE
if (m_sharedImage == &emptyImage)
@ -79,15 +79,15 @@ namespace Nz
return false;
}
if (!PixelFormat::IsValid(newFormat))
if (!PixelFormatInfo::IsValid(newFormat))
{
NazaraError("Invalid pixel format");
return false;
}
if (!PixelFormat::IsConversionSupported(m_sharedImage->format, newFormat))
if (!PixelFormatInfo::IsConversionSupported(m_sharedImage->format, newFormat))
{
NazaraError("Conversion from " + PixelFormat::GetName(m_sharedImage->format) + " to " + PixelFormat::GetName(newFormat) + " is not supported");
NazaraError("Conversion from " + PixelFormatInfo::GetName(m_sharedImage->format) + " to " + PixelFormatInfo::GetName(newFormat) + " is not supported");
return false;
}
#endif
@ -106,16 +106,16 @@ namespace Nz
for (unsigned int i = 0; i < levels.size(); ++i)
{
unsigned int pixelsPerFace = width * height;
levels[i] = std::make_unique<UInt8[]>(pixelsPerFace * depth * PixelFormat::GetBytesPerPixel(newFormat));
levels[i] = std::make_unique<UInt8[]>(pixelsPerFace * depth * PixelFormatInfo::GetBytesPerPixel(newFormat));
UInt8* dst = levels[i].get();
UInt8* src = m_sharedImage->levels[i].get();
unsigned int srcStride = pixelsPerFace * PixelFormat::GetBytesPerPixel(m_sharedImage->format);
unsigned int dstStride = pixelsPerFace * PixelFormat::GetBytesPerPixel(newFormat);
unsigned int srcStride = pixelsPerFace * PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format);
unsigned int dstStride = pixelsPerFace * PixelFormatInfo::GetBytesPerPixel(newFormat);
for (unsigned int d = 0; d < depth; ++d)
{
if (!PixelFormat::Convert(m_sharedImage->format, newFormat, src, &src[srcStride], dst))
if (!PixelFormatInfo::Convert(m_sharedImage->format, newFormat, src, &src[srcStride], dst))
{
NazaraError("Failed to convert image");
return false;
@ -158,18 +158,18 @@ namespace Nz
}
#endif
UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format);
UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format);
UInt8* dstPtr = GetPixelPtr(m_sharedImage->levels[0].get(), bpp, dstPos.x, dstPos.y, dstPos.z, m_sharedImage->width, m_sharedImage->height);
Copy(dstPtr, srcPtr, m_sharedImage->format, srcBox.width, srcBox.height, srcBox.depth, m_sharedImage->width, m_sharedImage->height, source->GetWidth(), source->GetHeight());
}
bool Image::Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount)
bool Image::Create(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount)
{
Destroy();
#if NAZARA_UTILITY_SAFE
if (!PixelFormat::IsValid(format))
if (!PixelFormatInfo::IsValid(format))
{
NazaraError("Invalid pixel format");
return false;
@ -255,7 +255,7 @@ namespace Nz
// Cette allocation est protégée car sa taille dépend directement de paramètres utilisateurs
try
{
levels[i] = std::make_unique<UInt8[]>(PixelFormat::ComputeSize(format, w, h, d));
levels[i] = std::make_unique<UInt8[]>(PixelFormatInfo::ComputeSize(format, w, h, d));
if (w > 1)
w >>= 1;
@ -298,18 +298,18 @@ namespace Nz
return false;
}
if (PixelFormat::IsCompressed(m_sharedImage->format))
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
{
NazaraError("Cannot access pixels from compressed image");
return false;
}
#endif
UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format);
UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format);
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
if (!PixelFormatInfo::Convert(PixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
{
NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format));
NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format));
return false;
}
@ -323,7 +323,7 @@ namespace Nz
for (auto & level : levels)
{
std::size_t size = PixelFormat::ComputeSize(m_sharedImage->format, width, height, depth);
std::size_t size = PixelFormatInfo::ComputeSize(m_sharedImage->format, width, height, depth);
level = std::make_unique<UInt8[]>(size);
UInt8* ptr = level.get();
@ -362,7 +362,7 @@ namespace Nz
return false;
}
if (PixelFormat::IsCompressed(m_sharedImage->format))
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
{
NazaraError("Cannot access pixels from compressed image");
return false;
@ -383,11 +383,11 @@ namespace Nz
EnsureOwnership();
UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format);
UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format);
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
if (!PixelFormatInfo::Convert(PixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
{
NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format));
NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format));
return false;
}
@ -427,7 +427,7 @@ namespace Nz
return false;
}
if (PixelFormat::IsCompressed(m_sharedImage->format))
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
{
NazaraError("Cannot access pixels from compressed image");
return false;
@ -455,11 +455,11 @@ namespace Nz
EnsureOwnership();
UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format);
UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format);
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
if (!PixelFormatInfo::Convert(PixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
{
NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format));
NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format));
return false;
}
@ -501,7 +501,7 @@ namespace Nz
for (auto& level : m_sharedImage->levels)
{
UInt8* ptr = level.get();
if (!PixelFormat::Flip(PixelFlipping_Horizontally, m_sharedImage->format, width, height, depth, ptr, ptr))
if (!PixelFormatInfo::Flip(PixelFlipping_Horizontally, m_sharedImage->format, width, height, depth, ptr, ptr))
{
NazaraError("Failed to flip image");
return false;
@ -529,7 +529,7 @@ namespace Nz
return false;
}
if (PixelFormat::IsCompressed(m_sharedImage->format))
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
{
NazaraError("Cannot flip compressed image");
return false;
@ -544,7 +544,7 @@ namespace Nz
for (auto& level : m_sharedImage->levels)
{
UInt8* ptr = level.get();
if (!PixelFormat::Flip(PixelFlipping_Vertically, m_sharedImage->format, width, height, depth, ptr, ptr))
if (!PixelFormatInfo::Flip(PixelFlipping_Vertically, m_sharedImage->format, width, height, depth, ptr, ptr))
{
NazaraError("Failed to flip image");
return false;
@ -604,7 +604,7 @@ namespace Nz
}
#endif
return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height);
return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height);
}
unsigned int Image::GetDepth(UInt8 level) const
@ -620,7 +620,7 @@ namespace Nz
return GetLevelSize(m_sharedImage->depth, level);
}
PixelFormatType Image::GetFormat() const
PixelFormat Image::GetFormat() const
{
return m_sharedImage->format;
}
@ -672,12 +672,12 @@ namespace Nz
if (m_sharedImage->type == ImageType_Cubemap)
size *= 6;
return size * PixelFormat::GetBytesPerPixel(m_sharedImage->format);
return size * PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format);
}
std::size_t Image::GetMemoryUsage(UInt8 level) const
{
return PixelFormat::ComputeSize(m_sharedImage->format, GetLevelSize(m_sharedImage->width, level), GetLevelSize(m_sharedImage->height, level), ((m_sharedImage->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_sharedImage->depth, level)));
return PixelFormatInfo::ComputeSize(m_sharedImage->format, GetLevelSize(m_sharedImage->width, level), GetLevelSize(m_sharedImage->height, level), ((m_sharedImage->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_sharedImage->depth, level)));
}
Color Image::GetPixelColor(unsigned int x, unsigned int y, unsigned int z) const
@ -689,7 +689,7 @@ namespace Nz
return Color();
}
if (PixelFormat::IsCompressed(m_sharedImage->format))
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
{
NazaraError("Cannot access pixels from compressed image");
return Color();
@ -715,10 +715,10 @@ namespace Nz
}
#endif
const UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height);
const UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height);
Color color;
if (!PixelFormat::Convert(m_sharedImage->format, PixelFormatType_RGBA8, pixel, &color.r))
if (!PixelFormatInfo::Convert(m_sharedImage->format, PixelFormat_RGBA8, pixel, &color.r))
NazaraError("Failed to convert image's format to RGBA8");
return color;
@ -773,7 +773,7 @@ namespace Nz
EnsureOwnership();
return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height);
return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height);
}
Vector3ui Image::GetSize(UInt8 level) const
@ -811,12 +811,12 @@ namespace Nz
{
NazaraAssert(m_sharedImage != &emptyImage, "Image must be valid");
if (!PixelFormat::HasAlpha(m_sharedImage->format))
if (!PixelFormatInfo::HasAlpha(m_sharedImage->format))
return false;
if (!PixelFormat::IsCompressed(m_sharedImage->format))
if (!PixelFormatInfo::IsCompressed(m_sharedImage->format))
{
const PixelFormatInfo& info = PixelFormat::GetInfo(m_sharedImage->format);
const PixelFormatDescription& info = PixelFormatInfo::GetInfo(m_sharedImage->format);
Bitset<> workingBitset;
std::size_t pixelCount = m_sharedImage->width * m_sharedImage->height * ((m_sharedImage->type == ImageType_Cubemap) ? 6 : m_sharedImage->depth);
@ -1208,7 +1208,7 @@ namespace Nz
return false;
}
if (PixelFormat::IsCompressed(m_sharedImage->format))
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
{
NazaraError("Cannot access pixels from compressed image");
return false;
@ -1234,9 +1234,9 @@ namespace Nz
}
#endif
UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height);
UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height);
if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, pixel))
if (!PixelFormatInfo::Convert(PixelFormat_RGBA8, m_sharedImage->format, &color.r, pixel))
{
NazaraError("Failed to convert RGBA8 to image's format");
return false;
@ -1322,7 +1322,7 @@ namespace Nz
EnsureOwnership();
UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format);
UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format);
UInt8* dstPixels = GetPixelPtr(m_sharedImage->levels[level].get(), bpp, box.x, box.y, box.z, width, height);
Copy(dstPixels, pixels, m_sharedImage->format,
@ -1349,7 +1349,7 @@ namespace Nz
return *this;
}
void Image::Copy(UInt8* destination, const UInt8* source, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, unsigned int dstWidth, unsigned int dstHeight, unsigned int srcWidth, unsigned int srcHeight)
void Image::Copy(UInt8* destination, const UInt8* source, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, unsigned int dstWidth, unsigned int dstHeight, unsigned int srcWidth, unsigned int srcHeight)
{
#if NAZARA_UTILITY_SAFE
if (width == 0)
@ -1373,10 +1373,10 @@ namespace Nz
srcHeight = height;
if ((height == 1 || (dstWidth == width && srcWidth == width)) && (depth == 1 || (dstHeight == height && srcHeight == height)))
std::memcpy(destination, source, PixelFormat::ComputeSize(format, width, height, depth));
std::memcpy(destination, source, PixelFormatInfo::ComputeSize(format, width, height, depth));
else
{
unsigned int bpp = PixelFormat::GetBytesPerPixel(format);
unsigned int bpp = PixelFormatInfo::GetBytesPerPixel(format);
unsigned int lineStride = width * bpp;
unsigned int dstLineStride = dstWidth * bpp;
unsigned int dstFaceStride = dstLineStride * dstHeight;
@ -1498,7 +1498,7 @@ namespace Nz
ImageLibrary::Uninitialize();
}
Image::SharedImage Image::emptyImage(0, ImageType_2D, PixelFormatType_Undefined, Image::SharedImage::PixelContainer(), 0, 0, 0);
Image::SharedImage Image::emptyImage(0, ImageType_2D, PixelFormat_Undefined, Image::SharedImage::PixelContainer(), 0, 0, 0);
ImageLibrary::LibraryMap Image::s_library;
ImageLoader::LoaderList Image::s_loaders;
ImageManager::ManagerMap Image::s_managerMap;

File diff suppressed because it is too large Load Diff

View File

@ -93,7 +93,7 @@ namespace Nz
return false;
}
if (!PixelFormat::Initialize())
if (!PixelFormatInfo::Initialize())
{
NazaraError("Failed to initialize pixel formats");
return false;
@ -176,7 +176,7 @@ namespace Nz
VertexDeclaration::Uninitialize();
Skeleton::Uninitialize();
PixelFormat::Uninitialize();
PixelFormatInfo::Uninitialize();
Mesh::Uninitialize();
Image::Uninitialize();
Font::Uninitialize();

View File

@ -94,38 +94,38 @@ namespace Nz
if (!parameters.depthFormats.empty())
{
for (PixelFormatType format : parameters.depthFormats)
for (PixelFormat format : parameters.depthFormats)
{
switch (format)
{
case PixelFormatType_Depth16:
case PixelFormat_Depth16:
m_depthStencilFormat = VK_FORMAT_D16_UNORM;
break;
case PixelFormatType_Depth24:
case PixelFormatType_Depth24Stencil8:
case PixelFormat_Depth24:
case PixelFormat_Depth24Stencil8:
m_depthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
break;
case PixelFormatType_Depth32:
case PixelFormat_Depth32:
m_depthStencilFormat = VK_FORMAT_D32_SFLOAT;
break;
case PixelFormatType_Stencil1:
case PixelFormatType_Stencil4:
case PixelFormatType_Stencil8:
case PixelFormat_Stencil1:
case PixelFormat_Stencil4:
case PixelFormat_Stencil8:
m_depthStencilFormat = VK_FORMAT_S8_UINT;
break;
case PixelFormatType_Stencil16:
case PixelFormat_Stencil16:
m_depthStencilFormat = VK_FORMAT_MAX_ENUM;
break;
default:
{
PixelFormatContent formatContent = PixelFormat::GetContent(format);
PixelFormatContent formatContent = PixelFormatInfo::GetContent(format);
if (formatContent != PixelFormatContent_DepthStencil && formatContent != PixelFormatContent_Stencil)
NazaraWarning("Invalid format " + PixelFormat::GetName(format) + " for depth-stencil attachment");
NazaraWarning("Invalid format " + PixelFormatInfo::GetName(format) + " for depth-stencil attachment");
m_depthStencilFormat = VK_FORMAT_MAX_ENUM;
break;

View File

@ -156,7 +156,7 @@ namespace Nz
vmaDestroyImage(m_device.GetMemoryAllocator(), m_image, m_allocation);
}
PixelFormatType VulkanTexture::GetFormat() const
PixelFormat VulkanTexture::GetFormat() const
{
return m_params.pixelFormat;
}
@ -178,7 +178,7 @@ namespace Nz
bool VulkanTexture::Update(const void* ptr)
{
std::size_t textureSize = m_params.width * m_params.height * m_params.depth * PixelFormat::GetBytesPerPixel(m_params.pixelFormat);
std::size_t textureSize = m_params.width * m_params.height * m_params.depth * PixelFormatInfo::GetBytesPerPixel(m_params.pixelFormat);
VkBufferCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
@ -229,7 +229,7 @@ namespace Nz
return true;
}
void VulkanTexture::InitForFormat(PixelFormatType pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView)
void VulkanTexture::InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView)
{
createImageView.components = {
VK_COMPONENT_SWIZZLE_R,
@ -240,7 +240,7 @@ namespace Nz
switch (pixelFormat)
{
case PixelFormatType_L8:
case PixelFormat_L8:
{
createImage.format = VK_FORMAT_R8_SRGB;
createImageView.format = createImage.format;
@ -253,7 +253,7 @@ namespace Nz
break;
}
case PixelFormatType_LA8:
case PixelFormat_LA8:
{
createImage.format = VK_FORMAT_R8G8_SRGB;
createImageView.format = createImage.format;
@ -266,14 +266,14 @@ namespace Nz
break;
}
case PixelFormatType_RGB8:
case PixelFormat_RGB8:
{
createImage.format = VK_FORMAT_R8G8B8_SRGB;
createImageView.format = createImage.format;
break;
}
case PixelFormatType_RGBA8:
case PixelFormat_RGBA8:
{
createImage.format = VK_FORMAT_R8G8B8A8_SRGB;
createImageView.format = createImage.format;
@ -281,7 +281,7 @@ namespace Nz
}
default:
throw std::runtime_error(("Unsupported pixel format " + PixelFormat::GetName(pixelFormat)).ToStdString());
throw std::runtime_error(("Unsupported pixel format " + PixelFormatInfo::GetName(pixelFormat)).ToStdString());
}
}
}

View File

@ -137,7 +137,7 @@ namespace Ndk
if (!m_reflectionMap)
{
m_reflectionMap = Nz::Texture::New();
if (!m_reflectionMap->Create(Nz::ImageType_Cubemap, Nz::PixelFormatType_RGB8, m_reflectionMapSize, m_reflectionMapSize))
if (!m_reflectionMap->Create(Nz::ImageType_Cubemap, Nz::PixelFormat_RGB8, m_reflectionMapSize, m_reflectionMapSize))
{
NazaraWarning("Failed to create reflection map, reflections will be disabled for this entity");
return;