Split error macro into two versions (format vs non-formating) to allow format checking at compile-time
This commit is contained in:
@@ -30,13 +30,13 @@ namespace Nz
|
||||
{
|
||||
if (startFrame > endFrame)
|
||||
{
|
||||
NazaraError("Start frame index must be smaller than end frame index");
|
||||
NazaraError("start frame index must be smaller than end frame index");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!skeleton)
|
||||
{
|
||||
NazaraError("You must set a valid skeleton to load an animation");
|
||||
NazaraError("you must set a valid skeleton to load an animation");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Nz
|
||||
auto it = m_impl->sequenceMap.find(sequence.name);
|
||||
if (it != m_impl->sequenceMap.end())
|
||||
{
|
||||
NazaraError("sequence name \"{0}\" is already in use", sequence.name);
|
||||
NazaraErrorFmt("sequence name \"{0}\" is already in use", sequence.name);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -152,7 +152,7 @@ namespace Nz
|
||||
auto it = m_impl->sequenceMap.find(sequenceName);
|
||||
if (it == m_impl->sequenceMap.end())
|
||||
{
|
||||
NazaraError("Sequence not found");
|
||||
NazaraError("sequence not found");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Nz
|
||||
auto it = m_impl->sequenceMap.find(sequenceName);
|
||||
if (it == m_impl->sequenceMap.end())
|
||||
{
|
||||
NazaraError("Sequence not found");
|
||||
NazaraError("sequence not found");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Nz
|
||||
auto it = m_impl->sequenceMap.find(sequenceName);
|
||||
if (it == m_impl->sequenceMap.end())
|
||||
{
|
||||
NazaraError("Sequence not found");
|
||||
NazaraError("sequence not found");
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace Nz
|
||||
auto it = m_impl->sequenceMap.find(identifier);
|
||||
if (it == m_impl->sequenceMap.end())
|
||||
{
|
||||
NazaraError("Sequence not found");
|
||||
NazaraError("sequence not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
std::size_t jointIndex = skeletonComponent->FindJointByName(jointName);
|
||||
if (jointIndex == Skeleton::InvalidJointIndex)
|
||||
{
|
||||
NazaraError("skeleton has no joint \"{0}\"", jointName);
|
||||
NazaraErrorFmt("skeleton has no joint \"{0}\"", jointName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
{
|
||||
NazaraError("Invalid font");
|
||||
NazaraError("invalid font");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -146,8 +146,8 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
{
|
||||
NazaraError("Invalid font");
|
||||
return std::string("Invalid font");
|
||||
NazaraError("invalid font");
|
||||
return std::string("invalid font");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
{
|
||||
NazaraError("Invalid font");
|
||||
NazaraError("invalid font");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -202,7 +202,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
{
|
||||
NazaraError("Invalid font");
|
||||
NazaraError("invalid font");
|
||||
|
||||
static SizeInfo dummy;
|
||||
return dummy;
|
||||
@@ -237,8 +237,8 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!IsValid())
|
||||
{
|
||||
NazaraError("Invalid font");
|
||||
return std::string("Invalid font");
|
||||
NazaraError("invalid font");
|
||||
return std::string("invalid font");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace Nz
|
||||
{
|
||||
s_defaultFont = Font::OpenFromMemory(r_sansationRegular, sizeof(r_sansationRegular));
|
||||
if (!s_defaultFont)
|
||||
NazaraError("Failed to open default font");
|
||||
NazaraError("failed to open default font");
|
||||
}
|
||||
|
||||
return s_defaultFont;
|
||||
@@ -455,7 +455,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_atlas)
|
||||
{
|
||||
NazaraError("Font has no atlas");
|
||||
NazaraError("font has no atlas");
|
||||
return glyph;
|
||||
}
|
||||
#endif
|
||||
@@ -511,7 +511,7 @@ namespace Nz
|
||||
|
||||
if (!m_atlas->Insert(fontGlyph.image, &glyph.atlasRect, &glyph.flipped, &glyph.layerIndex))
|
||||
{
|
||||
NazaraError("Failed to insert glyph into atlas");
|
||||
NazaraError("failed to insert glyph into atlas");
|
||||
return glyph;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Nz
|
||||
|
||||
if (byteStream.Read(ptr, byteCount) != byteCount)
|
||||
{
|
||||
NazaraError("failed to read level #{0}", NumberToString(i));
|
||||
NazaraErrorFmt("failed to read level #{0}", i);
|
||||
return Nz::Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Nz
|
||||
{
|
||||
if (header.ddsCaps[1] & DDSCAPS2_CUBEMAP)
|
||||
{
|
||||
NazaraError("Cubemap arrays are not yet supported, sorry");
|
||||
NazaraError("cubemap arrays are not yet supported, sorry");
|
||||
return false;
|
||||
}
|
||||
else if (header.flags & DDSD_HEIGHT)
|
||||
@@ -125,7 +125,7 @@ namespace Nz
|
||||
{
|
||||
if ((header.ddsCaps[1] & DDSCAPS2_CUBEMAP_ALLFACES) != DDSCAPS2_CUBEMAP_ALLFACES)
|
||||
{
|
||||
NazaraError("Partial cubemap are not yet supported, sorry");
|
||||
NazaraError("partial cubemap are not yet supported, sorry");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace Nz
|
||||
}
|
||||
else if (headerExt.resourceDimension == D3D10_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
NazaraError("Texture buffers are not yet supported, sorry");
|
||||
NazaraError("texture buffers are not yet supported, sorry");
|
||||
return false;
|
||||
}
|
||||
else if (headerExt.resourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE1D)
|
||||
@@ -234,7 +234,7 @@ namespace Nz
|
||||
buf[3] = (header.format.fourCC >> 24) & 255;
|
||||
buf[4] = '\0';
|
||||
|
||||
NazaraError("unhandled format \"{0}\"", buf);
|
||||
NazaraErrorFmt("unhandled format \"{0}\"", buf);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Nz
|
||||
{
|
||||
if (FT_Stroker_New(s_freetypeLibrary, &s_freetypeStroker) != 0)
|
||||
{
|
||||
NazaraWarning("Failed to load FreeType stroker, outline will not be possible");
|
||||
NazaraWarning("failed to load FreeType stroker, outline will not be possible");
|
||||
s_freetypeStroker = nullptr; //< Just in case
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace Nz
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (!dst)
|
||||
{
|
||||
NazaraError("Glyph destination cannot be null");
|
||||
NazaraError("glyph destination cannot be null");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -123,7 +123,7 @@ namespace Nz
|
||||
|
||||
if (FT_Load_Char(m_face, character, FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_NORMAL) != 0)
|
||||
{
|
||||
NazaraError("Failed to load character");
|
||||
NazaraError("failed to load character");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Nz
|
||||
FT_Glyph glyph;
|
||||
if (FT_Get_Glyph(glyphSlot, &glyph) != 0)
|
||||
{
|
||||
NazaraError("Failed to extract glyph");
|
||||
NazaraError("failed to extract glyph");
|
||||
return false;
|
||||
}
|
||||
CallOnExit destroyGlyph([&]() { FT_Done_Glyph(glyph); });
|
||||
@@ -152,7 +152,7 @@ namespace Nz
|
||||
FT_OutlineGlyph outlineGlyph = reinterpret_cast<FT_OutlineGlyph>(glyph);
|
||||
if (FT_Outline_Embolden(&outlineGlyph->outline, boldStrength) != 0)
|
||||
{
|
||||
NazaraError("Failed to embolden glyph");
|
||||
NazaraError("failed to embolden glyph");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace Nz
|
||||
FT_Stroker_Set(s_freetypeStroker, static_cast<FT_Fixed>(s_freetypeScaleFactor * outlineThickness), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
|
||||
if (FT_Glyph_Stroke(&glyph, s_freetypeStroker, 1) != 0)
|
||||
{
|
||||
NazaraError("Failed to outline glyph");
|
||||
NazaraError("failed to outline glyph");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ namespace Nz
|
||||
|
||||
if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, 1) != 0)
|
||||
{
|
||||
NazaraError("Failed to convert glyph to bitmap");
|
||||
NazaraError("failed to convert glyph to bitmap");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ namespace Nz
|
||||
std::unique_ptr<File> file = std::make_unique<File>();
|
||||
if (!file->Open(filePath, OpenMode::ReadOnly))
|
||||
{
|
||||
NazaraError("failed to open stream from file: {0}", Error::GetLastError());
|
||||
NazaraErrorFmt("failed to open stream from file: {0}", Error::GetLastError());
|
||||
return false;
|
||||
}
|
||||
m_ownedStream = std::move(file);
|
||||
@@ -392,7 +392,7 @@ namespace Nz
|
||||
std::unique_ptr<FreeTypeStream> face = std::make_unique<FreeTypeStream>();
|
||||
if (!face->SetFile(filePath))
|
||||
{
|
||||
NazaraError("Failed to open file");
|
||||
NazaraError("failed to open file");
|
||||
return Err(ResourceLoadingError::FailedToOpenFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Nz
|
||||
}
|
||||
else if (!hasGlobalColorTable)
|
||||
{
|
||||
NazaraError("corrupt gif (no color table for image #{0}", m_frames.size() - 1);
|
||||
NazaraErrorFmt("corrupt gif (no color table for image #{0}", m_frames.size() - 1);
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace Nz
|
||||
m_byteStream >> minimumCodeSize;
|
||||
if (minimumCodeSize > 12)
|
||||
{
|
||||
NazaraError("unexpected LZW Minimum Code Size ({0})", minimumCodeSize);
|
||||
NazaraErrorFmt("unexpected LZW Minimum Code Size ({0})", minimumCodeSize);
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ namespace Nz
|
||||
break;
|
||||
|
||||
default:
|
||||
NazaraWarning("unrecognized extension label (unknown tag {0:#x})", label);
|
||||
NazaraWarningFmt("unrecognized extension label (unknown tag {0:#x})", label);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
default:
|
||||
NazaraError("corrupt gif (unknown tag {0:#x})", tag);
|
||||
NazaraErrorFmt("corrupt gif (unknown tag {0:#x})", tag);
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
}
|
||||
@@ -450,7 +450,7 @@ namespace Nz
|
||||
std::unique_ptr<File> file = std::make_unique<File>();
|
||||
if (!file->Open(filePath, OpenMode::ReadOnly))
|
||||
{
|
||||
NazaraError("failed to open stream from file: {0}", Error::GetLastError());
|
||||
NazaraErrorFmt("failed to open stream from file: {0}", Error::GetLastError());
|
||||
return false;
|
||||
}
|
||||
m_ownedStream = std::move(file);
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Nz
|
||||
|
||||
if (stream.GetSize() < header.offset_end)
|
||||
{
|
||||
NazaraError("Incomplete MD2 file");
|
||||
NazaraError("incomplete MD2 file");
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Nz
|
||||
|
||||
if (m_frameIndex != frameCount)
|
||||
{
|
||||
NazaraError("missing frame infos: [{0},{1}]", m_frameIndex, frameCount);
|
||||
NazaraErrorFmt("missing frame infos: [{0},{1}]", m_frameIndex, frameCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace Nz
|
||||
|
||||
void MD5AnimParser::Error(const std::string& message)
|
||||
{
|
||||
NazaraError("{0} at line #{1}", message, m_lineCount);
|
||||
NazaraErrorFmt("{0} at line #{1}", message, m_lineCount);
|
||||
}
|
||||
|
||||
bool MD5AnimParser::ParseBaseframe()
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Nz
|
||||
|
||||
if (!ParseMesh())
|
||||
{
|
||||
NazaraError("Failed to parse mesh");
|
||||
NazaraError("failed to parse mesh");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Nz
|
||||
|
||||
void MD5MeshParser::Error(const std::string& message)
|
||||
{
|
||||
NazaraError("{0} at line #1", message, m_lineCount);
|
||||
NazaraErrorFmt("{0} at line #1", message, m_lineCount);
|
||||
}
|
||||
|
||||
bool MD5MeshParser::ParseJoints()
|
||||
@@ -237,7 +237,7 @@ namespace Nz
|
||||
|
||||
if (pos >= 64)
|
||||
{
|
||||
NazaraError("Joint name is too long (>= 64 characters)");
|
||||
NazaraError("joint name is too long (>= 64 characters)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -420,19 +420,19 @@ namespace Nz
|
||||
|
||||
if (m_meshes[m_meshIndex].triangles.empty())
|
||||
{
|
||||
NazaraError("Mesh has no triangles");
|
||||
NazaraError("mesh has no triangles");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_meshes[m_meshIndex].vertices.empty())
|
||||
{
|
||||
NazaraError("Mesh has no vertices");
|
||||
NazaraError("mesh has no vertices");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_meshes[m_meshIndex].weights.empty())
|
||||
{
|
||||
NazaraError("Mesh has no weights");
|
||||
NazaraError("mesh has no weights");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Nz
|
||||
File file(filePath);
|
||||
if (!file.Open(OpenMode::ReadOnly | OpenMode::Text))
|
||||
{
|
||||
NazaraError("failed to open MTL file ({0})", file.GetPath());
|
||||
NazaraErrorFmt("failed to open MTL file ({0})", file.GetPath());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Nz
|
||||
const MTLParser::Material* mtlMat = materialParser.GetMaterial(matName);
|
||||
if (!mtlMat)
|
||||
{
|
||||
NazaraWarning("MTL has no material \"{0}\"", matName);
|
||||
NazaraWarningFmt("MTL has no material \"{0}\"", matName);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace Nz
|
||||
|
||||
if (m_meshes.empty())
|
||||
{
|
||||
NazaraError("No meshes");
|
||||
NazaraError("no meshes");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Nz
|
||||
|
||||
if (mesh.IsAnimable())
|
||||
{
|
||||
NazaraError("an animated mesh cannot be saved to {0} format", format);
|
||||
NazaraErrorFmt("an animated mesh cannot be saved to {0} format", format);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = std::make_shared<Image>();
|
||||
if (!image->Create(ImageType::E2D, PixelFormat::RGB8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1))
|
||||
{
|
||||
NazaraError("Failed to create image");
|
||||
NazaraError("failed to create image");
|
||||
return Err(ResourceLoadingError::Internal);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Nz
|
||||
{
|
||||
if (!stream.Read(&rleValue, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Nz
|
||||
rleCount = rleValue - 0xc0;
|
||||
if (!stream.Read(&rleValue, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ namespace Nz
|
||||
{
|
||||
if (!stream.Read(&rleValue, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Nz
|
||||
rleCount = rleValue - 0xc0;
|
||||
if (!stream.Read(&rleValue, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
}
|
||||
@@ -207,21 +207,21 @@ namespace Nz
|
||||
UInt8 magic;
|
||||
if (!stream.Read(&magic, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
/* first byte must be equal to 0x0c (12) */
|
||||
if (magic != 0x0c)
|
||||
{
|
||||
NazaraError("Colormap's first byte must be 0x0c ({0:#x})", magic);
|
||||
NazaraErrorFmt("Colormap's first byte must be 0x0c ({0:#x})", magic);
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
/* read palette */
|
||||
if (stream.Read(palette, 768) != 768)
|
||||
{
|
||||
NazaraError("Failed to read palette");
|
||||
NazaraError("failed to read palette");
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Nz
|
||||
{
|
||||
if (!stream.Read(&rleValue, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace Nz
|
||||
rleCount = rleValue - 0xc0;
|
||||
if (!stream.Read(&rleValue, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ namespace Nz
|
||||
{
|
||||
if (!stream.Read(&rleValue, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace Nz
|
||||
rleCount = rleValue - 0xc0;
|
||||
if (!stream.Read(&rleValue, 1))
|
||||
{
|
||||
NazaraError("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
NazaraErrorFmt("failed to read stream (byte {0})", stream.GetCursorPos());
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
default:
|
||||
NazaraError("unsupported {0} bitcount for pcx files", bitCount);
|
||||
NazaraErrorFmt("unsupported {0} bitcount for pcx files", bitCount);
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Nz
|
||||
UInt8* ptr = stbi_load_from_callbacks(&s_stbiCallbacks, &stream, &width, &height, &bpp, STBI_rgb_alpha);
|
||||
if (!ptr)
|
||||
{
|
||||
NazaraError("failed to load image: {0}", std::string(stbi_failure_reason()));
|
||||
NazaraErrorFmt("failed to load image: {0}", std::string(stbi_failure_reason()));
|
||||
return Err(ResourceLoadingError::DecodingError);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = std::make_shared<Image>();
|
||||
if (!image->Create(ImageType::E2D, PixelFormat::RGBA8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1))
|
||||
{
|
||||
NazaraError("Failed to create image");
|
||||
NazaraError("failed to create image");
|
||||
return Err(ResourceLoadingError::Internal);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Nz
|
||||
{
|
||||
if (!image->Convert(parameters.loadFormat))
|
||||
{
|
||||
NazaraError("Failed to convert image to required format");
|
||||
NazaraError("failed to convert image to required format");
|
||||
return Err(ResourceLoadingError::Internal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Nz
|
||||
{
|
||||
Stream* stream = static_cast<Stream*>(userdata);
|
||||
if (stream->Write(data, size) != static_cast<std::size_t>(size))
|
||||
throw std::runtime_error("Failed to write to stream");
|
||||
throw std::runtime_error("failed to write to stream");
|
||||
}
|
||||
|
||||
bool SaveBMP(const Image& image, const ImageParams& parameters, Stream& stream)
|
||||
@@ -140,7 +140,7 @@ namespace Nz
|
||||
long long imageQuality = parameters.custom.GetIntegerParameter("JPEGQuality").GetValueOr(100);
|
||||
if (imageQuality <= 0 || imageQuality > 100)
|
||||
{
|
||||
NazaraError("NativeJPEGSaver_Quality value ({0}) does not fit in bounds ]0, 100], clamping...", imageQuality);
|
||||
NazaraErrorFmt("NativeJPEGSaver_Quality value ({0}) does not fit in bounds ]0, 100], clamping...", imageQuality);
|
||||
imageQuality = Nz::Clamp(imageQuality, 1LL, 100LL);
|
||||
}
|
||||
|
||||
@@ -162,13 +162,13 @@ namespace Nz
|
||||
int componentCount = ConvertToFloatFormat(tempImage);
|
||||
if (componentCount == 0)
|
||||
{
|
||||
NazaraError("Failed to convert image to suitable format");
|
||||
NazaraError("failed to convert image to suitable format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stbi_write_hdr_to_func(&WriteToStream, &stream, tempImage.GetWidth(), tempImage.GetHeight(), componentCount, reinterpret_cast<const float*>(tempImage.GetConstPixels())))
|
||||
{
|
||||
NazaraError("Failed to write HDR to stream");
|
||||
NazaraError("failed to write HDR to stream");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -184,13 +184,13 @@ namespace Nz
|
||||
int componentCount = ConvertToIntegerFormat(tempImage);
|
||||
if (componentCount == 0)
|
||||
{
|
||||
NazaraError("Failed to convert image to suitable format");
|
||||
NazaraError("failed to convert image to suitable format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stbi_write_png_to_func(&WriteToStream, &stream, tempImage.GetWidth(), tempImage.GetHeight(), componentCount, tempImage.GetConstPixels(), 0))
|
||||
{
|
||||
NazaraError("Failed to write PNG to stream");
|
||||
NazaraError("failed to write PNG to stream");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -206,13 +206,13 @@ namespace Nz
|
||||
int componentCount = ConvertToIntegerFormat(tempImage);
|
||||
if (componentCount == 0)
|
||||
{
|
||||
NazaraError("Failed to convert image to suitable format");
|
||||
NazaraError("failed to convert image to suitable format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stbi_write_tga_to_func(&WriteToStream, &stream, tempImage.GetWidth(), tempImage.GetHeight(), componentCount, tempImage.GetConstPixels()))
|
||||
{
|
||||
NazaraError("Failed to write TGA to stream");
|
||||
NazaraError("failed to write TGA to stream");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -241,14 +241,14 @@ namespace Nz
|
||||
|
||||
if (!image.IsValid())
|
||||
{
|
||||
NazaraError("Invalid image");
|
||||
NazaraError("invalid image");
|
||||
return false;
|
||||
}
|
||||
|
||||
ImageType type = image.GetType();
|
||||
if (type != ImageType::E1D && type != ImageType::E2D)
|
||||
{
|
||||
NazaraError("Image type {0:#x}) is not in a supported format", UnderlyingCast(type));
|
||||
NazaraErrorFmt("Image type {0:#x}) is not in a supported format", UnderlyingCast(type));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (layerIndex >= m_layers.size())
|
||||
{
|
||||
NazaraError("layer index out of range ({0} >= {1})", layerIndex, m_layers.size());
|
||||
NazaraErrorFmt("layer index out of range ({0} >= {1})", layerIndex, m_layers.size());
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -139,7 +139,7 @@ namespace Nz
|
||||
if (!ResizeLayer(newLayer, newSize))
|
||||
{
|
||||
// Impossible d'allouer une nouvelle couche, nous manquons probablement de mémoire (ou le glyphe est trop grand)
|
||||
NazaraError("Failed to allocate new layer, we are probably out of memory");
|
||||
NazaraError("failed to allocate new layer, we are probably out of memory");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,19 +82,19 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PixelFormatInfo::IsValid(newFormat))
|
||||
{
|
||||
NazaraError("Invalid pixel format");
|
||||
NazaraError("invalid pixel format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PixelFormatInfo::IsConversionSupported(m_sharedImage->format, newFormat))
|
||||
{
|
||||
NazaraError("Conversion from {0} to {1} is not supported", PixelFormatInfo::GetName(m_sharedImage->format), PixelFormatInfo::GetName(newFormat));
|
||||
NazaraErrorFmt("conversion from {0} to {1} is not supported", PixelFormatInfo::GetName(m_sharedImage->format), PixelFormatInfo::GetName(newFormat));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -124,7 +124,7 @@ namespace Nz
|
||||
{
|
||||
if (!PixelFormatInfo::Convert(m_sharedImage->format, newFormat, src, &src[srcStride], dst))
|
||||
{
|
||||
NazaraError("Failed to convert image");
|
||||
NazaraError("failed to convert image");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!srcPtr)
|
||||
{
|
||||
NazaraError("Failed to access pixels");
|
||||
NazaraError("failed to access pixels");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -178,25 +178,25 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!PixelFormatInfo::IsValid(format))
|
||||
{
|
||||
NazaraError("Invalid pixel format");
|
||||
NazaraError("invalid pixel format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (width == 0)
|
||||
{
|
||||
NazaraError("Width must be at least 1 (0)");
|
||||
NazaraError("width must be at least 1 (0)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (height == 0)
|
||||
{
|
||||
NazaraError("Height must be at least 1 (0)");
|
||||
NazaraError("height must be at least 1 (0)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (depth == 0)
|
||||
{
|
||||
NazaraError("Depth must be at least 1 (0)");
|
||||
NazaraError("depth must be at least 1 (0)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -232,13 +232,13 @@ namespace Nz
|
||||
case ImageType::Cubemap:
|
||||
if (depth > 1)
|
||||
{
|
||||
NazaraError("Cubemaps must be 1 deep");
|
||||
NazaraError("cubemaps must be 1 deep");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (width != height)
|
||||
{
|
||||
NazaraError("Cubemaps must have square dimensions");
|
||||
NazaraError("cubemaps must have square dimensions");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -275,7 +275,7 @@ namespace Nz
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraError("Failed to allocate image's level {0} ({1})", i, e.what());
|
||||
NazaraErrorFmt("failed to allocate image's level {0} ({1})", i, e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -298,13 +298,13 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
|
||||
{
|
||||
NazaraError("Cannot access pixels from compressed image");
|
||||
NazaraError("cannot access pixels from compressed image");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -313,7 +313,7 @@ namespace Nz
|
||||
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
||||
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
||||
{
|
||||
NazaraError("failed to convert RGBA8 to {0}", std::string(PixelFormatInfo::GetName(m_sharedImage->format)));
|
||||
NazaraErrorFmt("failed to convert RGBA8 to {0}", PixelFormatInfo::GetName(m_sharedImage->format));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -362,25 +362,25 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
|
||||
{
|
||||
NazaraError("Cannot access pixels from compressed image");
|
||||
NazaraError("cannot access pixels from compressed image");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!box.IsValid())
|
||||
{
|
||||
NazaraError("Invalid rectangle");
|
||||
NazaraError("invalid rectangle");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (box.x+box.width > m_sharedImage->width || box.y+box.height > m_sharedImage->height || box.z+box.depth > m_sharedImage->depth)
|
||||
{
|
||||
NazaraError("Box dimensions are out of bounds");
|
||||
NazaraError("box dimensions are out of bounds");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -391,7 +391,7 @@ namespace Nz
|
||||
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
||||
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
||||
{
|
||||
NazaraError("failed to convert RGBA8 to {0}", std::string(PixelFormatInfo::GetName(m_sharedImage->format)));
|
||||
NazaraErrorFmt("failed to convert RGBA8 to {0}", PixelFormatInfo::GetName(m_sharedImage->format));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -427,32 +427,32 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
|
||||
{
|
||||
NazaraError("Cannot access pixels from compressed image");
|
||||
NazaraError("cannot access pixels from compressed image");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!rect.IsValid())
|
||||
{
|
||||
NazaraError("Invalid rectangle");
|
||||
NazaraError("invalid rectangle");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rect.x + rect.width > m_sharedImage->width || rect.y + rect.height > m_sharedImage->height)
|
||||
{
|
||||
NazaraError("Rectangle dimensions are out of bounds");
|
||||
NazaraError("rectangle dimensions are out of bounds");
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int depth = (m_sharedImage->type == ImageType::Cubemap) ? 6 : m_sharedImage->depth;
|
||||
if (z >= depth)
|
||||
{
|
||||
NazaraError("Z value exceeds depth ({0} >= {1})", NumberToString(z), NumberToString(depth));
|
||||
NazaraErrorFmt("z value exceeds depth ({0} >= {1})", z, depth);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -463,7 +463,7 @@ namespace Nz
|
||||
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
||||
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
||||
{
|
||||
NazaraError("failed to convert RGBA8 to {0}", std::string(PixelFormatInfo::GetName(m_sharedImage->format)));
|
||||
NazaraErrorFmt("failed to convert RGBA8 to {0}", PixelFormatInfo::GetName(m_sharedImage->format));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -507,7 +507,7 @@ namespace Nz
|
||||
UInt8* ptr = level.get();
|
||||
if (!PixelFormatInfo::Flip(PixelFlipping::Horizontally, m_sharedImage->format, width, height, depth, ptr, ptr))
|
||||
{
|
||||
NazaraError("Failed to flip image");
|
||||
NazaraError("failed to flip image");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -529,13 +529,13 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
|
||||
{
|
||||
NazaraError("Cannot flip compressed image");
|
||||
NazaraError("cannot flip compressed image");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -550,7 +550,7 @@ namespace Nz
|
||||
UInt8* ptr = level.get();
|
||||
if (!PixelFormatInfo::Flip(PixelFlipping::Vertically, m_sharedImage->format, width, height, depth, ptr, ptr))
|
||||
{
|
||||
NazaraError("Failed to flip image");
|
||||
NazaraError("failed to flip image");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -572,13 +572,13 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (level >= m_sharedImage->levels.size())
|
||||
{
|
||||
NazaraError("Level out of bounds ({0} >= {1})", NumberToString(level), NumberToString(m_sharedImage->levels.size()));
|
||||
NazaraErrorFmt("level out of bounds ({0} >= {1})", level, m_sharedImage->levels.size());
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -587,7 +587,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (x >= width)
|
||||
{
|
||||
NazaraError("X value exceeds width ({0} >= {1})", NumberToString(x), NumberToString(width));
|
||||
NazaraErrorFmt("x value exceeds width ({0} >= {1})", x, width);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -596,14 +596,14 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (y >= height)
|
||||
{
|
||||
NazaraError("Y value exceeds height ({0} >= {1})", NumberToString(y), NumberToString(height));
|
||||
NazaraErrorFmt("y value exceeds height ({0} >= {1})", y, height);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned int depth = (m_sharedImage->type == ImageType::Cubemap) ? 6 : GetImageLevelSize(m_sharedImage->depth, level);
|
||||
if (z >= depth)
|
||||
{
|
||||
NazaraError("Z value exceeds depth ({0} >= {1})", NumberToString(z), NumberToString(depth));
|
||||
NazaraErrorFmt("z value exceeds depth ({0} >= {1})", z, depth);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -616,7 +616,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (level >= m_sharedImage->levels.size())
|
||||
{
|
||||
NazaraError("Level out of bounds ({0} >= {1})", NumberToString(level), NumberToString(m_sharedImage->levels.size()));
|
||||
NazaraErrorFmt("level out of bounds ({0} >= {1})", level, m_sharedImage->levels.size());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -634,7 +634,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (level >= m_sharedImage->levels.size())
|
||||
{
|
||||
NazaraError("Level out of bounds ({0} >= {1})", NumberToString(level), NumberToString(m_sharedImage->levels.size()));
|
||||
NazaraErrorFmt("level out of bounds ({0} >= {1})", level, m_sharedImage->levels.size());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -689,32 +689,32 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return Color();
|
||||
}
|
||||
|
||||
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
|
||||
{
|
||||
NazaraError("Cannot access pixels from compressed image");
|
||||
NazaraError("cannot access pixels from compressed image");
|
||||
return Color();
|
||||
}
|
||||
|
||||
if (x >= m_sharedImage->width)
|
||||
{
|
||||
NazaraError("X value exceeds width ({0} >= {1})", NumberToString(x), NumberToString(m_sharedImage->width));
|
||||
NazaraErrorFmt("x value exceeds width ({0} >= {1})", x, m_sharedImage->width);
|
||||
return Color();
|
||||
}
|
||||
|
||||
if (y >= m_sharedImage->height)
|
||||
{
|
||||
NazaraError("Y value exceeds height ({0} >= {1})", NumberToString(y), NumberToString(m_sharedImage->height));
|
||||
NazaraErrorFmt("y value exceeds height ({0} >= {1})", y, m_sharedImage->height);
|
||||
return Color();
|
||||
}
|
||||
|
||||
unsigned int depth = (m_sharedImage->type == ImageType::Cubemap) ? 6 : m_sharedImage->depth;
|
||||
if (z >= depth)
|
||||
{
|
||||
NazaraError("Z value exceeds depth ({0} >= {1})", NumberToString(z), NumberToString(depth));
|
||||
NazaraErrorFmt("z value exceeds depth ({0} >= {1})", z, depth);
|
||||
return Color();
|
||||
}
|
||||
#endif
|
||||
@@ -723,7 +723,7 @@ namespace Nz
|
||||
|
||||
Color color;
|
||||
if (!PixelFormatInfo::Convert(m_sharedImage->format, PixelFormat::RGBA32F, pixel, &color.r))
|
||||
NazaraError("Failed to convert image's format to RGBA8");
|
||||
NazaraError("failed to convert image's format to RGBA8");
|
||||
|
||||
return color;
|
||||
}
|
||||
@@ -733,13 +733,13 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (level >= m_sharedImage->levels.size())
|
||||
{
|
||||
NazaraError("Level out of bounds ({0} >= {1})", NumberToString(level), NumberToString(m_sharedImage->levels.size()));
|
||||
NazaraErrorFmt("level out of bounds ({0} >= {1})", level, m_sharedImage->levels.size());
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -748,7 +748,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (x >= width)
|
||||
{
|
||||
NazaraError("X value exceeds width ({0} >= {1})", NumberToString(x), NumberToString(width));
|
||||
NazaraErrorFmt("x value exceeds width ({0} >= {1})", x, width);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -757,20 +757,20 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (y >= height)
|
||||
{
|
||||
NazaraError("Y value exceeds height ({0} >= {1})", NumberToString(y), NumberToString(height));
|
||||
NazaraErrorFmt("y value exceeds height ({0} >= {1})", y, height);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned int depth = (m_sharedImage->type == ImageType::Cubemap) ? 6 : GetImageLevelSize(m_sharedImage->depth, level);
|
||||
if (z >= depth)
|
||||
{
|
||||
NazaraError("Z value exceeds depth ({0} >= {1})", NumberToString(z), NumberToString(depth));
|
||||
NazaraErrorFmt("z value exceeds depth ({0} >= {1})", z, depth);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (level >= m_sharedImage->levels.size())
|
||||
{
|
||||
NazaraError("Level out of bounds ({0} >= {1})", NumberToString(level), NumberToString(m_sharedImage->levels.size()));
|
||||
NazaraErrorFmt("level out of bounds ({0} >= {1})", level, m_sharedImage->levels.size());
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -785,7 +785,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (level >= m_sharedImage->levels.size())
|
||||
{
|
||||
NazaraError("Level out of bounds ({0} >= {1})", NumberToString(level), NumberToString(m_sharedImage->levels.size()));
|
||||
NazaraErrorFmt("level out of bounds ({0} >= {1})", level, m_sharedImage->levels.size());
|
||||
return Vector3ui::Zero();
|
||||
}
|
||||
#endif
|
||||
@@ -803,7 +803,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (level >= m_sharedImage->levels.size())
|
||||
{
|
||||
NazaraError("Level out of bounds ({0} >= {1})", NumberToString(level), NumberToString(m_sharedImage->levels.size()));
|
||||
NazaraErrorFmt("level out of bounds ({0} >= {1})", level, m_sharedImage->levels.size());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -859,7 +859,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromFile(filePath, imageParams);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -868,18 +868,18 @@ namespace Nz
|
||||
|
||||
std::shared_ptr<Image> Image::LoadFromImage(const Image& image, const Vector2ui& atlasSize)
|
||||
{
|
||||
NazaraAssert(image.IsValid(), "Invalid image");
|
||||
NazaraAssert(image.IsValid(), "invalid image");
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (atlasSize.x == 0)
|
||||
{
|
||||
NazaraError("Atlas width must be over zero");
|
||||
NazaraError("atlas width must be over zero");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (atlasSize.y == 0)
|
||||
{
|
||||
NazaraError("Atlas height must be over zero");
|
||||
NazaraError("atlas height must be over zero");
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -889,7 +889,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (type != ImageType::E1D && type != ImageType::E2D)
|
||||
{
|
||||
NazaraError("Image type not handled ({0:#x})", UnderlyingCast(type));
|
||||
NazaraErrorFmt("image type not handled ({0:#x})", UnderlyingCast(type));
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -897,14 +897,10 @@ namespace Nz
|
||||
Vector2ui imageSize(image.GetWidth(), image.GetHeight());
|
||||
|
||||
if (imageSize.x % atlasSize.x != 0)
|
||||
{
|
||||
NazaraWarning("Image width is not divisible by atlas width (" + NumberToString(imageSize.x) + " mod " + NumberToString(atlasSize.x) + " != 0)");
|
||||
}
|
||||
NazaraWarningFmt("Image width is not divisible by atlas width ({0} mod {1} != 0)", imageSize.x, atlasSize.x);
|
||||
|
||||
if (imageSize.y % atlasSize.y != 0)
|
||||
{
|
||||
NazaraWarning("Image height is not divisible by atlas height (" + NumberToString(imageSize.y) + " mod " + NumberToString(atlasSize.y) + " != 0)");
|
||||
}
|
||||
NazaraWarningFmt("Image height is not divisible by atlas height ({0} mod {1} != 0)", imageSize.y, atlasSize.y);
|
||||
|
||||
Vector2ui faceSize = imageSize/atlasSize;
|
||||
|
||||
@@ -919,7 +915,7 @@ namespace Nz
|
||||
|
||||
if (!arrayImage->IsValid())
|
||||
{
|
||||
NazaraError("Failed to create image");
|
||||
NazaraError("failed to create image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -936,7 +932,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromMemory(data, size, imageParams);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -948,7 +944,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromStream(stream, imageParams);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -960,7 +956,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromFile(filePath, imageParams);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -969,13 +965,13 @@ namespace Nz
|
||||
|
||||
std::shared_ptr<Image> Image::LoadFromImage(const Image& image, const CubemapParams& params)
|
||||
{
|
||||
NazaraAssert(image.IsValid(), "Invalid image");
|
||||
NazaraAssert(image.IsValid(), "invalid image");
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
ImageType type = image.GetType();
|
||||
if (type != ImageType::E2D)
|
||||
{
|
||||
NazaraError("Image type not handled ({0:#x})", UnderlyingCast(type));
|
||||
NazaraErrorFmt("image type not handled ({0:#x})", UnderlyingCast(type));
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
@@ -987,7 +983,7 @@ namespace Nz
|
||||
// Sans cette vérification, celles des rectangles pourrait réussir via un overflow
|
||||
if (width < faceSize || height < faceSize)
|
||||
{
|
||||
NazaraError("Image is too small for this face size");
|
||||
NazaraError("image is too small for this face size");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -998,49 +994,49 @@ namespace Nz
|
||||
Vector2ui backPos = params.backPosition * faceSize;
|
||||
if (backPos.x > limitX || backPos.y > limitY)
|
||||
{
|
||||
NazaraError("Back rectangle is out of image");
|
||||
NazaraError("back rectangle is out of image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector2ui downPos = params.downPosition * faceSize;
|
||||
if (downPos.x > limitX || downPos.y > limitY)
|
||||
{
|
||||
NazaraError("Down rectangle is out of image");
|
||||
NazaraError("down rectangle is out of image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector2ui forwardPos = params.forwardPosition * faceSize;
|
||||
if (forwardPos.x > limitX || forwardPos.y > limitY)
|
||||
{
|
||||
NazaraError("Forward rectangle is out of image");
|
||||
NazaraError("forward rectangle is out of image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector2ui leftPos = params.leftPosition * faceSize;
|
||||
if (leftPos.x > limitX || leftPos.y > limitY)
|
||||
{
|
||||
NazaraError("Left rectangle is out of image");
|
||||
NazaraError("left rectangle is out of image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector2ui rightPos = params.rightPosition * faceSize;
|
||||
if (rightPos.x > limitX || rightPos.y > limitY)
|
||||
{
|
||||
NazaraError("Right rectangle is out of image");
|
||||
NazaraError("right rectangle is out of image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vector2ui upPos = params.upPosition * faceSize;
|
||||
if (upPos.x > limitX || upPos.y > limitY)
|
||||
{
|
||||
NazaraError("Up rectangle is out of image");
|
||||
NazaraError("up rectangle is out of image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Image> cubemap = std::make_shared<Image>();
|
||||
if (!cubemap->Create(ImageType::Cubemap, image.GetFormat(), faceSize, faceSize))
|
||||
{
|
||||
NazaraError("Failed to create cubemap");
|
||||
NazaraError("failed to create cubemap");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1059,7 +1055,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromMemory(data, size, imageParams);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1071,7 +1067,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromStream(stream, imageParams);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1083,7 +1079,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromFile(filePath, params);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1097,7 +1093,7 @@ namespace Nz
|
||||
unsigned int faceSize = GetWidth();
|
||||
if (image.GetWidth() != faceSize || image.GetHeight() != faceSize)
|
||||
{
|
||||
NazaraError("Image size must match cubemap face size");
|
||||
NazaraError("image size must match cubemap face size");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1106,7 +1102,7 @@ namespace Nz
|
||||
|
||||
if (!convertedImage.Convert(GetFormat()))
|
||||
{
|
||||
NazaraError("Failed to convert image to cubemap format");
|
||||
NazaraError("failed to convert image to cubemap format");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1119,7 +1115,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromMemory(data, size, params);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1131,7 +1127,7 @@ namespace Nz
|
||||
std::shared_ptr<Image> image = Image::LoadFromStream(stream, params);
|
||||
if (!image)
|
||||
{
|
||||
NazaraError("Failed to load image");
|
||||
NazaraError("failed to load image");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1190,32 +1186,32 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PixelFormatInfo::IsCompressed(m_sharedImage->format))
|
||||
{
|
||||
NazaraError("Cannot access pixels from compressed image");
|
||||
NazaraError("cannot access pixels from compressed image");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (x >= m_sharedImage->width)
|
||||
{
|
||||
NazaraError("X value exceeds width ({0} >= {1})", NumberToString(x), NumberToString(m_sharedImage->width));
|
||||
NazaraErrorFmt("x value exceeds width ({0} >= {1})", x, m_sharedImage->width);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (y >= m_sharedImage->height)
|
||||
{
|
||||
NazaraError("Y value exceeds height ({0} >= {1})", NumberToString(y), NumberToString(m_sharedImage->height));
|
||||
NazaraErrorFmt("y value exceeds height ({0} >= {1})", y, m_sharedImage->height);
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int depth = (m_sharedImage->type == ImageType::Cubemap) ? 6 : m_sharedImage->depth;
|
||||
if (z >= depth)
|
||||
{
|
||||
NazaraError("Z value exceeds depth ({0} >= {1})", NumberToString(z), NumberToString(depth));
|
||||
NazaraErrorFmt("z value exceeds depth ({0} >= {1})", z, depth);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -1224,7 +1220,7 @@ namespace Nz
|
||||
|
||||
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, pixel))
|
||||
{
|
||||
NazaraError("Failed to convert RGBA8 to image's format");
|
||||
NazaraError("failed to convert RGBA8 to image's format");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1236,19 +1232,19 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
NazaraError("image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pixels)
|
||||
{
|
||||
NazaraError("Invalid pixel source");
|
||||
NazaraError("invalid pixel source");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (level >= m_sharedImage->levels.size())
|
||||
{
|
||||
NazaraError("Level out of bounds ({0} >= {1})", NumberToString(level), NumberToString(m_sharedImage->levels.size()));
|
||||
NazaraErrorFmt("level out of bounds ({0} >= {1})", level, m_sharedImage->levels.size());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -1259,15 +1255,15 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!box.IsValid())
|
||||
{
|
||||
NazaraError("Invalid box");
|
||||
NazaraError("invalid box");
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int depth = (m_sharedImage->type == ImageType::Cubemap) ? 6 : GetImageLevelSize(m_sharedImage->depth, level);
|
||||
if (box.x+box.width > width || box.y+box.height > height || box.z+box.depth > depth ||
|
||||
(m_sharedImage->type == ImageType::Cubemap && box.depth > 1)) // Nous n'autorisons pas de modifier plus d'une face du cubemap à la fois
|
||||
(m_sharedImage->type == ImageType::Cubemap && box.depth > 1)) // We don't allow to update more than one face of the cubemap at once
|
||||
{
|
||||
NazaraError("Box dimensions are out of bounds");
|
||||
NazaraError("box dimensions are out of bounds");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -1300,11 +1296,11 @@ namespace Nz
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (width == 0)
|
||||
NazaraError("Width must be greater than zero");
|
||||
NazaraError("width must be greater than zero");
|
||||
if (height == 0)
|
||||
NazaraError("Height must be greater than zero");
|
||||
NazaraError("height must be greater than zero");
|
||||
if (depth == 0)
|
||||
NazaraError("Depth must be greater than zero");
|
||||
NazaraError("depth must be greater than zero");
|
||||
#endif
|
||||
|
||||
if (dstWidth == 0)
|
||||
@@ -1372,7 +1368,7 @@ namespace Nz
|
||||
return GetMaxLevel(width, height, depth);
|
||||
}
|
||||
|
||||
NazaraError("Image type not handled ({0:#x})", UnderlyingCast(type));
|
||||
NazaraErrorFmt("Image type not handled ({0:#x})", UnderlyingCast(type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Nz
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!m_mapper.Map(indexBuffer, 0, m_indexCount))
|
||||
NazaraError("Failed to map buffer"); ///TODO: Unexcepted
|
||||
NazaraError("failed to map buffer"); ///TODO: Unexcepted
|
||||
|
||||
Getter rightGetter = nullptr;
|
||||
Setter rightSetter = nullptr;
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace Nz
|
||||
{
|
||||
if (!vertexDeclaration)
|
||||
{
|
||||
NazaraError("The vertex declaration can't be null");
|
||||
NazaraError("the vertex declaration can't be null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!vertexDeclaration->HasComponent(VertexComponent::Position))
|
||||
{
|
||||
NazaraError("Vertex declaration must contains a vertex position");
|
||||
NazaraError("vertex declaration must contains a vertex position");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace Nz
|
||||
m_jointCount = jointCount;
|
||||
if (!m_skeleton.Create(jointCount))
|
||||
{
|
||||
NazaraError("Failed to create skeleton");
|
||||
NazaraError("failed to create skeleton");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Nz
|
||||
{
|
||||
if (parentNode == this)
|
||||
{
|
||||
NazaraError("A node cannot be it's own parent");
|
||||
NazaraError("a node cannot be it's own parent");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1391,7 +1391,7 @@ namespace Nz
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (IsCompressed(format))
|
||||
{
|
||||
NazaraError("No function to flip compressed format");
|
||||
NazaraError("no function to flip compressed format");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -1558,7 +1558,7 @@ namespace Nz
|
||||
for (auto&& [pixelFormat, pixelFormatInfo] : s_pixelFormatInfos.iter_kv())
|
||||
{
|
||||
if (!pixelFormatInfo.Validate())
|
||||
NazaraWarning("Pixel format {0:#x} {1} failed validation tests", UnderlyingCast(pixelFormat), GetName(pixelFormat));
|
||||
NazaraWarningFmt("Pixel format {0:#x} {1} failed validation tests", UnderlyingCast(pixelFormat), GetName(pixelFormat));
|
||||
}
|
||||
|
||||
/***********************************A8************************************/
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Nz
|
||||
return indexCount - 2;
|
||||
}
|
||||
|
||||
NazaraError("Primitive mode not handled ({0:#x})", UnderlyingCast(m_primitiveMode));
|
||||
NazaraErrorFmt("primitive mode not handled ({0:#x})", UnderlyingCast(m_primitiveMode));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Nz
|
||||
for (const Component& component : m_components)
|
||||
{
|
||||
if (component.component == entry.component && component.componentIndex == entry.componentIndex)
|
||||
NazaraError("Duplicate component type found");
|
||||
NazaraError("duplicate component type found");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
NazaraError("Component type not handled ({0:#x})", UnderlyingCast(type));
|
||||
NazaraErrorFmt("Component type not handled ({0:#x})", UnderlyingCast(type));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace Nz
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
NazaraError("failed to initialize vertex declaration: {0}", std::string(e.what()));
|
||||
NazaraErrorFmt("failed to initialize vertex declaration: {0}", e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Nz
|
||||
|
||||
if (!buffer)
|
||||
{
|
||||
NazaraInternalError("Animation type not handled ({0:#x})", UnderlyingCast(subMesh.GetAnimationType()));
|
||||
NazaraInternalErrorFmt("animation type not handled ({0:#x})", UnderlyingCast(subMesh.GetAnimationType()));
|
||||
}
|
||||
|
||||
m_mapper.Map(*buffer, 0, buffer->GetVertexCount());
|
||||
|
||||
Reference in New Issue
Block a user