PixelFormat rename
PixelFormatInfo => PixelFormatDescription PixelFormat => PixelFormatInfo PixelFormatType => PixelFormat
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user