Split error macro into two versions (format vs non-formating) to allow format checking at compile-time

This commit is contained in:
SirLynix
2023-11-02 15:18:03 +01:00
parent 8fb53f467b
commit 4b8a475bbd
133 changed files with 570 additions and 557 deletions

View File

@@ -72,7 +72,7 @@ namespace Nz
if (!config.allowDummyDevice)
throw;
NazaraError("failed to open default OpenAL device: {0}", e.what());
NazaraErrorFmt("failed to open default OpenAL device: {0}", e.what());
}
}

View File

@@ -65,7 +65,7 @@ namespace Nz
std::optional<AudioFormat> formatOpt = GuessAudioFormat(wav.channels);
if (!formatOpt)
{
NazaraError("unexpected channel count: {0}", wav.channels);
NazaraErrorFmt("unexpected channel count: {0}", wav.channels);
return Err(ResourceLoadingError::Unsupported);
}
@@ -138,7 +138,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 Err(ResourceLoadingError::FailedToOpenFile);
}
@@ -166,7 +166,7 @@ namespace Nz
std::optional<AudioFormat> formatOpt = GuessAudioFormat(m_decoder.channels);
if (!formatOpt)
{
NazaraError("unexpected channel count: {0}", m_decoder.channels);
NazaraErrorFmt("unexpected channel count: {0}", m_decoder.channels);
return Err(ResourceLoadingError::Unsupported);
}

View File

@@ -229,7 +229,7 @@ namespace Nz
std::optional<AudioFormat> formatOpt = GuessAudioFormat(channelCount);
if (!formatOpt)
{
NazaraError("unexpected channel count: {0}", channelCount);
NazaraErrorFmt("unexpected channel count: {0}", channelCount);
return Err(ResourceLoadingError::Unsupported);
}
@@ -298,7 +298,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 Err(ResourceLoadingError::FailedToOpenFile);
}
@@ -351,7 +351,7 @@ namespace Nz
std::optional<AudioFormat> formatOpt = GuessAudioFormat(m_channelCount);
if (!formatOpt)
{
NazaraError("unexpected channel count: {0}", m_channelCount);
NazaraErrorFmt("unexpected channel count: {0}", m_channelCount);
return Err(ResourceLoadingError::Unrecognized);
}

View File

@@ -103,7 +103,7 @@ namespace Nz
if (readBytes < 0)
{
NazaraError("an error occurred while reading file: {0}", VorbisErrToString(readBytes));
NazaraErrorFmt("an error occurred while reading file: {0}", VorbisErrToString(readBytes));
return 0;
}
@@ -139,7 +139,7 @@ namespace Nz
std::optional<AudioFormat> formatOpt = GuessAudioFormat(info->channels);
if (!formatOpt)
{
NazaraError("unexpected channel count: {0}", info->channels);
NazaraErrorFmt("unexpected channel count: {0}", info->channels);
return Err(ResourceLoadingError::Unsupported);
}
@@ -217,7 +217,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 Err(ResourceLoadingError::FailedToOpenFile);
}
@@ -249,7 +249,7 @@ namespace Nz
std::optional<AudioFormat> formatOpt = GuessAudioFormat(info->channels);
if (!formatOpt)
{
NazaraError("unexpected channel count: {0}", info->channels);
NazaraErrorFmt("unexpected channel count: {0}", info->channels);
return Err(ResourceLoadingError::Unsupported);
}

View File

@@ -96,7 +96,7 @@ namespace Nz
std::optional<AudioFormat> formatOpt = GuessAudioFormat(info.channels);
if (!formatOpt)
{
NazaraError("unexpected channel count: {0}", info.channels);
NazaraErrorFmt("unexpected channel count: {0}", info.channels);
return Err(ResourceLoadingError::Unsupported);
}
@@ -163,7 +163,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 Err(ResourceLoadingError::FailedToOpenFile);
}
@@ -208,7 +208,7 @@ namespace Nz
std::optional<AudioFormat> formatOpt = GuessAudioFormat(m_decoder.info.channels);
if (!formatOpt)
{
NazaraError("unexpected channel count: {0}", m_decoder.info.channels);
NazaraErrorFmt("unexpected channel count: {0}", m_decoder.info.channels);
return Err(ResourceLoadingError::Unsupported);
}

View File

@@ -78,7 +78,7 @@ namespace Nz
if (ALenum lastError = m_library.alGetError(); lastError != AL_NO_ERROR)
{
NazaraError("failed to reset OpenAL buffer: {0}", std::to_string(lastError));
NazaraErrorFmt("failed to reset OpenAL buffer: {0}", std::to_string(lastError));
return false;
}

View File

@@ -147,7 +147,7 @@ namespace Nz
std::shared_ptr<SoundBuffer> buffer = SoundBuffer::LoadFromFile(filePath, params);
if (!buffer)
{
NazaraError("Failed to load buffer from file ({0})", filePath);
NazaraErrorFmt("failed to load buffer from file ({0})", filePath);
return false;
}
@@ -170,7 +170,7 @@ namespace Nz
std::shared_ptr<SoundBuffer> buffer = SoundBuffer::LoadFromMemory(data, size, params);
if (!buffer)
{
NazaraError("failed to load buffer from memory ({0})", PointerToString(data));
NazaraErrorFmt("failed to load buffer from memory ({0})", PointerToString(data));
return false;
}
@@ -192,7 +192,7 @@ namespace Nz
std::shared_ptr<SoundBuffer> buffer = SoundBuffer::LoadFromStream(stream, params);
if (!buffer)
{
NazaraError("Failed to load buffer from stream");
NazaraError("failed to load buffer from stream");
return false;
}

View File

@@ -108,7 +108,7 @@ namespace Nz
return std::make_shared<BulletSphereCollider3D>(primitive.sphere.size);
}
NazaraError("Primitive type not handled ({0:#x})", UnderlyingCast(primitive.type));
NazaraErrorFmt("Primitive type not handled ({0:#x})", UnderlyingCast(primitive.type));
return std::shared_ptr<BulletCollider3D>();
}

View File

@@ -76,7 +76,7 @@ namespace Nz
return std::make_unique<WhirlpoolHasher>();
}
NazaraInternalError("Hash type not handled ({0:#x})", UnderlyingCast(type));
NazaraInternalErrorFmt("Hash type not handled ({0:#x})", UnderlyingCast(type));
return nullptr;
}
}

View File

@@ -119,6 +119,6 @@ namespace Nz
void ByteStream::OnEmptyStream()
{
NazaraError("No stream");
NazaraError("no stream");
}
}

View File

@@ -76,7 +76,7 @@ namespace Nz
auto impl = std::make_unique<DynLibImpl>();
if (!impl->Load(libraryPath, &m_lastError))
{
NazaraError("failed to load library: {0}", m_lastError);
NazaraErrorFmt("failed to load library: {0}", m_lastError);
return false;
}

View File

@@ -192,7 +192,7 @@ namespace Nz
if (!impl->Open(m_filePath, openMode))
{
ErrorFlags flags(ErrorMode::Silent); // Silent by default
NazaraError("failed to open \"{0}\": {1}", m_filePath, Error::GetLastSystemError());
NazaraErrorFmt("failed to open \"{0}\": {1}", m_filePath, Error::GetLastSystemError());
return false;
}
@@ -243,7 +243,7 @@ namespace Nz
std::unique_ptr<FileImpl> impl = std::make_unique<FileImpl>(this);
if (!impl->Open(filePath, m_openMode))
{
NazaraError("failed to open new file; {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to open new file; {0}", Error::GetLastSystemError());
return false;
}
@@ -268,8 +268,8 @@ namespace Nz
if (!CheckFileOpening())
return false;
NazaraAssert(IsOpen(), "File is not open");
NazaraAssert(IsWritable(), "File is not writable");
NazaraAssert(IsOpen(), "file is not open");
NazaraAssert(IsWritable(), "file is not writable");
return m_impl->SetSize(size);
}
@@ -281,7 +281,7 @@ namespace Nz
File file(path);
if (!file.Open(OpenMode::ReadOnly | OpenMode::Unbuffered)) //< unbuffered since we will read all the file at once
{
NazaraError("failed to open \"{0}\"", path);
NazaraErrorFmt("failed to open \"{0}\"", path);
return std::nullopt;
}
@@ -301,7 +301,7 @@ namespace Nz
File file(path);
if (!file.Open(OpenMode::WriteOnly | OpenMode::Unbuffered)) //< unbuffered since we will write all the file at once
{
NazaraError("failed to open \"{0}\"", path);
NazaraErrorFmt("failed to open \"{0}\"", path);
return false;
}
@@ -455,7 +455,7 @@ namespace Nz
File file(originalFile.GetPath());
if (!file.Open(OpenMode::ReadOnly))
{
NazaraError("Unable to open file");
NazaraError("unable to open file");
return false;
}
@@ -467,7 +467,7 @@ namespace Nz
std::size_t size = std::min<std::size_t>(static_cast<std::size_t>(remainingSize), NAZARA_CORE_FILE_BUFFERSIZE);
if (file.Read(&buffer[0], size) != size)
{
NazaraError("Unable to read file");
NazaraError("unable to read file");
return false;
}

View File

@@ -113,7 +113,7 @@ namespace Nz
m_outputFile.open(m_outputPath, std::ios_base::trunc | std::ios_base::out);
if (!m_outputFile.is_open())
{
NazaraError("Failed to open output file");
NazaraError("failed to open output file");
return;
}
}

View File

@@ -613,7 +613,7 @@ namespace Nz
break;
default:
NazaraError("Split heuristic out of enum ({0:#x})", UnderlyingCast(method));
NazaraErrorFmt("split heuristic out of enum ({0:#x})", UnderlyingCast(method));
splitHorizontal = true;
}
@@ -658,7 +658,7 @@ namespace Nz
return ScoreWorstShortSideFit(width, height, freeRect);
}
NazaraError("Rect choice heuristic out of enum ({0:#x})", UnderlyingCast(rectChoice));
NazaraErrorFmt("Rect choice heuristic out of enum ({0:#x})", UnderlyingCast(rectChoice));
return std::numeric_limits<int>::max();
}
}

View File

@@ -46,7 +46,7 @@ namespace Nz
void FileImpl::Flush()
{
if (fsync(m_fileDescriptor) == -1)
NazaraError("Unable to flush file: {0}", Error::GetLastSystemError());
NazaraErrorFmt("unable to flush file: {0}", Error::GetLastSystemError());
}
UInt64 FileImpl::GetCursorPos() const
@@ -81,7 +81,7 @@ namespace Nz
int fileDescriptor = Open_def(filePath.generic_u8string().data(), flags, permissions);
if (fileDescriptor == -1)
{
NazaraError("Failed to open \"{0}\": {1}", filePath, Error::GetLastSystemError());
NazaraErrorFmt("failed to open \"{0}\": {1}", filePath, Error::GetLastSystemError());
return false;
}
@@ -101,14 +101,14 @@ namespace Nz
if (fcntl(fileDescriptor, F_GETLK, &lock) == -1)
{
close(fileDescriptor);
NazaraError("Unable to detect presence of lock on the file");
NazaraError("unable to detect presence of lock on the file");
return false;
}
if (lock.l_type != F_UNLCK)
{
close(fileDescriptor);
NazaraError("A lock is present on the file");
NazaraError("a lock is present on the file");
return false;
}
@@ -119,7 +119,7 @@ namespace Nz
if (fcntl(fileDescriptor, F_SETLK, &lock) == -1)
{
close(fileDescriptor);
NazaraError("Unable to place a lock on the file");
NazaraError("unable to place a lock on the file");
return false;
}
}
@@ -161,7 +161,7 @@ namespace Nz
break;
default:
NazaraInternalError("Cursor position not handled ({0:#x})", UnderlyingCast(pos));
NazaraInternalErrorFmt("cursor position not handled ({0:#x})", UnderlyingCast(pos));
return false;
}

View File

@@ -20,7 +20,7 @@ namespace Nz
#if NAZARA_CORE_SAFE
if (workerCount == 0)
{
NazaraError("Invalid worker count ! (0)");
NazaraError("invalid worker count ! (0)");
return false;
}
#endif
@@ -74,7 +74,7 @@ namespace Nz
#ifdef NAZARA_CORE_SAFE
if (s_workerCount == 0)
{
NazaraError("Task scheduler is not initialized");
NazaraError("task scheduler is not initialized");
return;
}
#endif
@@ -106,7 +106,7 @@ namespace Nz
#ifdef NAZARA_CORE_SAFE
if (s_workerCount == 0)
{
NazaraError("Task scheduler is not initialized");
NazaraError("task scheduler is not initialized");
return;
}
#endif

View File

@@ -82,7 +82,7 @@ namespace Nz
#if NAZARA_CORE_SAFE
if (m_referenceCount == 0)
{
NazaraError("Impossible to remove reference (Ref. counter is already 0)");
NazaraError("impossible to remove reference (Ref. counter is already 0)");
return false;
}
#endif

View File

@@ -278,7 +278,7 @@ namespace Nz
void* Stream::GetMemoryMappedPointer() const
{
NazaraError("Stream set the MemoryMapped option but did not implement GetMemoryMappedPointer");
NazaraError("stream set the MemoryMapped option but did not implement GetMemoryMappedPointer");
return nullptr;
}

View File

@@ -202,7 +202,7 @@ namespace Nz
}
catch (utf8::exception& e)
{
NazaraError("UTF-8 error: {0}", e.what());
NazaraErrorFmt("UTF-8 error: {0}", e.what());
}
catch (std::exception& e)
{

View File

@@ -62,7 +62,7 @@ namespace Nz
{
if (!Initialize())
{
NazaraError("Failed to initialize Task Scheduler");
NazaraError("failed to initialize Task Scheduler");
return;
}
@@ -86,7 +86,7 @@ namespace Nz
#ifdef NAZARA_CORE_SAFE
if (TaskSchedulerImpl::IsInitialized())
{
NazaraError("Worker count cannot be set while initialized");
NazaraError("worker count cannot be set while initialized");
return;
}
#endif
@@ -114,7 +114,7 @@ namespace Nz
{
if (!Initialize())
{
NazaraError("Failed to initialize Task Scheduler");
NazaraError("failed to initialize Task Scheduler");
return;
}
@@ -134,7 +134,7 @@ namespace Nz
{
if (!Initialize())
{
NazaraError("Failed to initialize Task Scheduler");
NazaraError("failed to initialize Task Scheduler");
return;
}

View File

@@ -43,7 +43,7 @@ namespace Nz
void FileImpl::Flush()
{
if (!FlushFileBuffers(m_handle))
NazaraError("Unable to flush file: {0}", Error::GetLastSystemError());
NazaraErrorFmt("Unable to flush file: {0}", Error::GetLastSystemError());
}
UInt64 FileImpl::GetCursorPos() const
@@ -153,7 +153,7 @@ namespace Nz
break;
default:
NazaraInternalError("Cursor position not handled ({0:#x})", UnderlyingCast(pos));
NazaraInternalErrorFmt("cursor position not handled ({0:#x})", UnderlyingCast(pos));
return false;
}
@@ -172,18 +172,18 @@ namespace Nz
CallOnExit resetCursor([this, cursorPos] ()
{
if (!SetCursorPos(CursorPosition::AtBegin, cursorPos))
NazaraWarning("Failed to reset cursor position to previous position: " + Error::GetLastSystemError());
NazaraWarningFmt("Failed to reset cursor position to previous position: {0}", Error::GetLastSystemError());
});
if (!SetCursorPos(CursorPosition::AtBegin, size))
{
NazaraError("failed to set file size: failed to move cursor position: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to set file size: failed to move cursor position: {0}", Error::GetLastSystemError());
return false;
}
if (!SetEndOfFile(m_handle))
{
NazaraError("failed to set file size: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to set file size: {0}", Error::GetLastSystemError());
return false;
}

View File

@@ -19,7 +19,7 @@ namespace Nz
#if NAZARA_CORE_SAFE
if (workerCount == 0)
{
NazaraError("Invalid worker count ! (0)");
NazaraError("invalid worker count ! (0)");
return false;
}
#endif
@@ -90,7 +90,7 @@ namespace Nz
#ifdef NAZARA_CORE_SAFE
if (s_workerCount == 0)
{
NazaraError("Task scheduler is not initialized");
NazaraError("task scheduler is not initialized");
return;
}
#endif
@@ -137,7 +137,7 @@ namespace Nz
#ifdef NAZARA_CORE_SAFE
if (s_workerCount == 0)
{
NazaraError("Task scheduler is not initialized");
NazaraError("task scheduler is not initialized");
return;
}
#endif

View File

@@ -51,7 +51,7 @@ namespace Nz
}
catch (const std::exception& e)
{
NazaraError("failed to instantiate texture: {0}", e.what());
NazaraErrorFmt("failed to instantiate texture: {0}", e.what());
return nullptr;
}

View File

@@ -35,7 +35,7 @@ namespace Nz
if (textureProperty.type != textureData.imageType)
{
// TODO: Use EnumToString to show image type as string
NazaraError("unmatching texture type: material property is of type {0} but shader sampler is of type {1}", UnderlyingCast(textureProperty.type), UnderlyingCast(textureData.imageType));
NazaraErrorFmt("unmatching texture type: material property is of type {0} but shader sampler is of type {1}", UnderlyingCast(textureProperty.type), UnderlyingCast(textureData.imageType));
return;
}
@@ -50,7 +50,7 @@ namespace Nz
m_optionHash = optionData->hash;
}
else
NazaraError("option {0} is not a boolean option (got {1})", m_optionName, nzsl::Ast::ToString(optionData->type));
NazaraErrorFmt("option {0} is not a boolean option (got {1})", m_optionName, nzsl::Ast::ToString(optionData->type));
}
}

View File

@@ -31,7 +31,7 @@ namespace Nz
}
catch (const std::exception& e)
{
NazaraError("failed to compile ubershader {0}: {1}", moduleName, e.what());
NazaraErrorFmt("failed to compile ubershader {0}: {1}", moduleName, e.what());
throw;
}
@@ -43,7 +43,7 @@ namespace Nz
nzsl::Ast::ModulePtr newShaderModule = resolver->Resolve(name);
if (!newShaderModule)
{
NazaraError("failed to retrieve updated shader module {0}", name);
NazaraErrorFmt("failed to retrieve updated shader module {0}", name);
return;
}
@@ -53,7 +53,7 @@ namespace Nz
}
catch (const std::exception& e)
{
NazaraError("failed to retrieve updated shader module {0}: {1}", name, e.what());
NazaraErrorFmt("failed to retrieve updated shader module {0}: {1}", name, e.what());
return;
}
@@ -76,7 +76,7 @@ namespace Nz
}
catch (const std::exception& e)
{
NazaraError("failed to compile ubershader: {0}", e.what());
NazaraErrorFmt("failed to compile ubershader: {0}", e.what());
throw;
}
}
@@ -98,6 +98,7 @@ namespace Nz
}, optionValue);
}
states.shaderModuleResolver = Graphics::Instance()->GetShaderModuleResolver();
states.debugLevel = nzsl::DebugLevel::Regular;
std::shared_ptr<ShaderModule> stage = Graphics::Instance()->GetRenderDevice()->InstantiateShaderModule(m_shaderStages, *m_shaderModule, std::move(states));

View File

@@ -101,7 +101,7 @@ namespace Nz
return std::make_shared<JoltSphereCollider3D>(primitive.sphere.size);
}
NazaraError("Primitive type not handled ({0:#x})", UnderlyingCast(primitive.type));
NazaraErrorFmt("Primitive type not handled ({0:#x})", UnderlyingCast(primitive.type));
return std::shared_ptr<JoltCollider3D>();
}
@@ -333,10 +333,10 @@ namespace Nz
unsigned int vertexCount = shape->GetFaceVertices(i, maxVerticesInFace, faceVertices.data());
if NAZARA_LIKELY(vertexCount >= 2)
{
for (unsigned int i = 1; i < vertexCount; ++i)
for (unsigned int j = 1; j < vertexCount; ++j)
{
indices.push_back(InsertVertex(faceVertices[i - 1]));
indices.push_back(InsertVertex(faceVertices[i]));
indices.push_back(InsertVertex(faceVertices[j - 1]));
indices.push_back(InsertVertex(faceVertices[j]));
}
if NAZARA_LIKELY(vertexCount > 2)

View File

@@ -179,7 +179,7 @@ namespace Nz
{
SocketError errorCode;
if (!SocketImpl::SetBlocking(m_handle, m_isBlockingEnabled, &errorCode))
NazaraWarning("failed to set socket blocking mode ({0:#x})", UnderlyingCast(errorCode));
NazaraWarningFmt("failed to set socket blocking mode ({0:#x})", UnderlyingCast(errorCode));
}
/*!
@@ -201,7 +201,7 @@ namespace Nz
{
SocketImpl::Close(handle);
NazaraError("failed to open a dual-stack socket: {0}", std::string(ErrorToString(m_lastError)));
NazaraErrorFmt("failed to open a dual-stack socket: {0}", ErrorToString(m_lastError));
return false;
}

View File

@@ -39,7 +39,7 @@ namespace Nz
if (!m_library.IsLoaded())
{
NazaraError("failed to load libcurl: {0}", m_library.GetLastError());
NazaraErrorFmt("failed to load libcurl: {0}", m_library.GetLastError());
return false;
}

View File

@@ -168,7 +168,7 @@ namespace Nz
if (peerCount > ENetConstants::ENetProtocol_MaximumPeerId)
{
NazaraError("peer count exceeds maximum peer count supported by protocol ({0})", UnderlyingCast(ENetConstants::ENetProtocol_MaximumPeerId));
NazaraErrorFmt("peer count exceeds maximum peer count supported by protocol ({0})", UnderlyingCast(ENetConstants::ENetProtocol_MaximumPeerId));
return false;
}
@@ -245,7 +245,7 @@ namespace Nz
return 1;
case -1:
NazaraError("Error sending outgoing packets");
NazaraError("error sending outgoing packets");
return -1;
default:
@@ -262,7 +262,7 @@ namespace Nz
return 1;
case -1:
//NazaraError("Error receiving incoming packets");
//NazaraError("error receiving incoming packets");
return -1;
default:
@@ -275,7 +275,7 @@ namespace Nz
return 1;
case -1:
NazaraError("Error sending outgoing packets");
NazaraError("error sending outgoing packets");
return -1;
@@ -338,7 +338,7 @@ namespace Nz
{
if (m_socket.Bind(address) != SocketState::Bound)
{
NazaraError("failed to bind address {0}", address.ToString());
NazaraErrorFmt("failed to bind address {0}", address.ToString());
return false;
}
}

View File

@@ -94,7 +94,7 @@ namespace Nz
return m_ipv6 == LoopbackIpV6.m_ipv6; // Only compare the ip value
}
NazaraInternalError("Invalid protocol for IpAddress ({0:#x})", UnderlyingCast(m_protocol));
NazaraInternalErrorFmt("invalid protocol for IpAddress ({0:#x})", UnderlyingCast(m_protocol));
return false;
}

View File

@@ -61,7 +61,7 @@ namespace Nz
if (epoll_ctl(m_handle, EPOLL_CTL_ADD, socket, &entry) != 0)
{
NazaraError("failed to add socket to epoll structure (errno {0}: {1})", errno, Error::GetLastSystemError());
NazaraErrorFmt("failed to add socket to epoll structure (errno {0}: {1})", errno, Error::GetLastSystemError());
return false;
}

View File

@@ -46,7 +46,7 @@ namespace Nz
std::size_t size = m_buffer->GetSize();
if (!EncodeHeader(m_buffer->GetBuffer(), static_cast<UInt32>(size), m_netCode))
{
NazaraError("Failed to encode packet header");
NazaraError("failed to encode packet header");
return nullptr;
}

View File

@@ -178,12 +178,12 @@ namespace Nz
}
default:
NazaraInternalError("Unhandled ip protocol ({0:#x})", UnderlyingCast(ipAddress.GetProtocol()));
NazaraInternalErrorFmt("unhandled ip protocol ({0:#x})", UnderlyingCast(ipAddress.GetProtocol()));
break;
}
}
NazaraError("Invalid ip address");
NazaraError("invalid ip address");
return 0;
}

View File

@@ -198,7 +198,7 @@ namespace Nz
if (waitError != SocketError::NoError)
{
if (waitError != SocketError::Interrupted) //< Do not log interrupted error
NazaraError("SocketPoller encountered an error (code: {0:#x}): {1}", UnderlyingCast(waitError), ErrorToString(waitError));
NazaraErrorFmt("SocketPoller encountered an error (code: {0:#x}): {1}", UnderlyingCast(waitError), ErrorToString(waitError));
return 0;
}

View File

@@ -187,7 +187,7 @@ namespace Nz
break;
}
NazaraInternalError("Unexpected socket state ({0:#x})", UnderlyingCast(m_state));
NazaraInternalErrorFmt("unexpected socket state ({0:#x})", UnderlyingCast(m_state));
return m_state;
}
@@ -426,7 +426,7 @@ namespace Nz
if (!ptr)
{
m_lastError = SocketError::Packet;
NazaraError("Failed to prepare packet");
NazaraError("failed to prepare packet");
return false;
}
@@ -479,7 +479,7 @@ namespace Nz
break;
}
NazaraInternalError("Unhandled socket state ({0:#x})", UnderlyingCast(m_state));
NazaraInternalErrorFmt("unhandled socket state ({0:#x})", UnderlyingCast(m_state));
return m_state;
}
@@ -516,10 +516,10 @@ namespace Nz
SocketError errorCode;
if (!SocketImpl::SetNoDelay(m_handle, m_isLowDelayEnabled, &errorCode))
NazaraWarning("failed to set socket no delay mode ({0:#x})", UnderlyingCast(errorCode));
NazaraWarningFmt("failed to set socket no delay mode ({0:#x})", UnderlyingCast(errorCode));
if (!SocketImpl::SetKeepAlive(m_handle, m_isKeepAliveEnabled, m_keepAliveTime, m_keepAliveInterval, &errorCode))
NazaraWarning("failed to set socket keep alive mode ({0:#x})", UnderlyingCast(errorCode));
NazaraWarningFmt("failed to set socket keep alive mode ({0:#x})", UnderlyingCast(errorCode));
m_peerAddress = IpAddress::Invalid;
m_openMode = OpenMode_ReadWrite;

View File

@@ -275,7 +275,7 @@ namespace Nz
if (!ptr)
{
m_lastError = SocketError::Packet;
NazaraError("Failed to prepare packet");
NazaraError("failed to prepare packet");
return false;
}

View File

@@ -277,7 +277,7 @@ namespace Nz
}
}
NazaraError("Invalid ip address");
NazaraError("invalid ip address");
return 0;
}

View File

@@ -160,7 +160,7 @@ namespace Nz
int errorCode = WSAStartup(MAKEWORD(2, 2), &s_WSA);
if (errorCode != 0)
{
NazaraError("failed to initialize Windows Socket 2.2: {0}", Error::GetLastSystemError(errorCode));
NazaraErrorFmt("failed to initialize Windows Socket 2.2: {0}", Error::GetLastSystemError(errorCode));
return false;
}

View File

@@ -91,7 +91,7 @@ namespace Nz
fd_set& targetSet = (i == 0) ? m_readSockets : m_writeSockets;
if (targetSet.fd_count > FD_SETSIZE)
{
NazaraError("Socket count exceeding hard-coded FD_SETSIZE ({0})", FD_SETSIZE);
NazaraErrorFmt("socket count exceeding hard-coded FD_SETSIZE ({0})", FD_SETSIZE);
return false;
}

View File

@@ -50,7 +50,7 @@ namespace Nz
std::unique_ptr<GL::Loader> loader = SelectLoader(config);
if (!loader)
{
NazaraError("Failed to initialize OpenGL loader");
NazaraError("failed to initialize OpenGL loader");
return false;
}

View File

@@ -369,13 +369,13 @@ namespace Nz::GL
// Validate framebuffer completeness
if (GLenum checkResult = m_blitFramebuffers->drawFBO.Check(); checkResult != GL_FRAMEBUFFER_COMPLETE)
{
NazaraError("Blit draw FBO is incomplete: {0}", TranslateOpenGLError(checkResult));
NazaraErrorFmt("blit draw FBO is incomplete: {0}", TranslateOpenGLError(checkResult));
return false;
}
if (GLenum checkResult = m_blitFramebuffers->readFBO.Check(); checkResult != GL_FRAMEBUFFER_COMPLETE)
{
NazaraError("Blit read FBO is incomplete: {0}", TranslateOpenGLError(checkResult));
NazaraErrorFmt("blit read FBO is incomplete: {0}", TranslateOpenGLError(checkResult));
return false;
}
@@ -628,14 +628,14 @@ namespace Nz::GL
unsigned int maxTextureUnits = GetInteger<unsigned int>(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
if (maxTextureUnits < 32) //< OpenGL ES 3.0 requires at least 32 textures units
NazaraWarning("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is " + std::to_string(maxTextureUnits) + ", expected >= 32");
NazaraWarningFmt("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is {0}, expected >= 32", maxTextureUnits);
assert(maxTextureUnits > 0);
m_state.textureUnits.resize(maxTextureUnits);
unsigned int maxUniformBufferUnits = GetInteger<unsigned int>(GL_MAX_UNIFORM_BUFFER_BINDINGS);
if (maxUniformBufferUnits < 24) //< OpenGL ES 3.0 requires at least 24 uniform buffers units
NazaraWarning("GL_MAX_UNIFORM_BUFFER_BINDINGS is " + std::to_string(maxUniformBufferUnits) + ", expected >= 24");
NazaraWarningFmt("GL_MAX_UNIFORM_BUFFER_BINDINGS is {0}, expected >= 24", maxUniformBufferUnits);
assert(maxUniformBufferUnits > 0);
m_state.uboUnits.resize(maxUniformBufferUnits);
@@ -651,7 +651,7 @@ namespace Nz::GL
{
unsigned int maxStorageBufferUnits = GetInteger<unsigned int>(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS);
if (maxStorageBufferUnits < 8) //< OpenGL ES 3.1 requires at least 8 storage buffers units
NazaraWarning("GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS is " + std::to_string(maxUniformBufferUnits) + ", expected >= 8");
NazaraWarningFmt("GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS is {0}, expected >= 8", maxUniformBufferUnits);
assert(maxStorageBufferUnits > 0);
m_state.storageUnits.resize(maxStorageBufferUnits);
@@ -710,7 +710,7 @@ namespace Nz::GL
{
hasAnyError = true;
NazaraError("OpenGL error: {0}", TranslateOpenGLError(lastError));
NazaraErrorFmt("OpenGL error: {0}", TranslateOpenGLError(lastError));
}
m_didCollectErrors = true;

View File

@@ -53,7 +53,7 @@ namespace Nz::GL
bool EGLContextBase::Create(const ContextParams& /*params*/, WindowHandle /*window*/, const EGLContextBase* /*shareContext*/)
{
NazaraError("Unexpected context creation call");
NazaraError("unexpected context creation call");
return false;
}
@@ -166,7 +166,7 @@ namespace Nz::GL
EGLint numConfig = 0;
if (m_loader.eglChooseConfig(m_display, configAttributes, configs, EGLint(maxConfigCount), &numConfig) != GL_TRUE)
{
NazaraError("failed to retrieve compatible EGL configurations: {0}", EGLLoader::TranslateError(m_loader.eglGetError()));
NazaraErrorFmt("failed to retrieve compatible EGL configurations: {0}", EGLLoader::TranslateError(m_loader.eglGetError()));
return false;
}
@@ -267,7 +267,7 @@ namespace Nz::GL
if (!m_handle)
{
NazaraError("failed to create EGL context: {0}", EGLLoader::TranslateError(m_loader.eglGetError()));
NazaraErrorFmt("failed to create EGL context: {0}", EGLLoader::TranslateError(m_loader.eglGetError()));
return false;
}

View File

@@ -25,7 +25,7 @@ namespace Nz::GL
HWNDHandle window(::CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr));
if (!window)
{
NazaraError("failed to create dummy window: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to create dummy window: {0}", Error::GetLastSystemError());
return false;
}
@@ -34,7 +34,7 @@ namespace Nz::GL
m_deviceContext = ::GetDC(window.get());
if (!m_deviceContext)
{
NazaraError("failed to retrieve dummy window device context: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to retrieve dummy window device context: {0}", Error::GetLastSystemError());
return false;
}
@@ -54,7 +54,7 @@ namespace Nz::GL
m_deviceContext = ::GetDC(static_cast<HWND>(window.windows.window));
if (!m_deviceContext)
{
NazaraError("failed to retrieve window device context: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to retrieve window device context: {0}", Error::GetLastSystemError());
return false;
}
@@ -208,7 +208,7 @@ namespace Nz::GL
if (!m_handle)
{
NazaraError("failed to create WGL context: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to create WGL context: {0}", Error::GetLastSystemError());
return false;
}
}
@@ -217,7 +217,7 @@ namespace Nz::GL
m_handle = m_loader.wglCreateContext(m_deviceContext);
if (!m_handle)
{
NazaraError("failed to create WGL context: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to create WGL context: {0}", Error::GetLastSystemError());
return false;
}
@@ -225,7 +225,7 @@ namespace Nz::GL
{
if (!m_loader.wglShareLists(shareContext->m_handle, m_handle))
{
NazaraError("failed to share context objects: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to share context objects: {0}", Error::GetLastSystemError());
return false;
}
}
@@ -268,7 +268,7 @@ namespace Nz::GL
bool succeeded = m_loader.wglMakeCurrent(m_deviceContext, m_handle);
if (!succeeded)
{
NazaraError("failed to activate context: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to activate context: {0}", Error::GetLastSystemError());
return false;
}
@@ -389,14 +389,14 @@ namespace Nz::GL
pixelFormat = m_loader.ChoosePixelFormat(m_deviceContext, &descriptor);
if (pixelFormat == 0)
{
NazaraError("failed to choose pixel format: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to choose pixel format: {0}", Error::GetLastSystemError());
return false;
}
}
if (!m_loader.SetPixelFormat(m_deviceContext, pixelFormat, &descriptor))
{
NazaraError("failed to choose pixel format: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to choose pixel format: {0}", Error::GetLastSystemError());
return false;
}

View File

@@ -132,7 +132,7 @@ namespace Nz::GL
if (m_handle <= 0)
{
NazaraError("failed to create Web context: {0}", WebLoader::TranslateError(static_cast<EMSCRIPTEN_RESULT>(m_handle)));
NazaraErrorFmt("failed to create Web context: {0}", WebLoader::TranslateError(static_cast<EMSCRIPTEN_RESULT>(m_handle)));
return false;
}

View File

@@ -14,7 +14,7 @@ namespace Nz::GL
HWNDHandle window(::CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr));
if (!window)
{
NazaraError("failed to create dummy window: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to create dummy window: {0}", Error::GetLastSystemError());
return false;
}
@@ -47,7 +47,7 @@ namespace Nz::GL
/*HDC deviceContext = ::GetDC(windowHandle);
if (!deviceContext)
{
NazaraError("failed to retrieve window device context: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to retrieve window device context: {0}", Error::GetLastSystemError());
return false;
}

View File

@@ -43,7 +43,7 @@ namespace Nz
m_cursorImage = cursor;
if (!m_cursorImage.Convert(PixelFormat::BGRA8))
NazaraError("Failed to convert icon to BGRA8");
NazaraError("failed to convert icon to BGRA8");
m_surface = SDL_CreateRGBSurfaceWithFormatFrom(
m_cursorImage.GetPixels(),
@@ -55,7 +55,7 @@ namespace Nz
);
if (!m_surface)
NazaraError("failed to create SDL Surface for cursor: {0}", std::string(SDL_GetError()));
NazaraErrorFmt("failed to create SDL Surface for cursor: {0}", SDL_GetError());
m_cursor = SDL_CreateColorCursor(m_surface, hotSpot.x, hotSpot.y);
if (!m_cursor)
@@ -63,7 +63,7 @@ namespace Nz
if (m_surface) //< Just in case exceptions were disabled
SDL_FreeSurface(m_surface);
NazaraError("failed to create SDL cursor: {0}", std::string(SDL_GetError()));
NazaraErrorFmt("failed to create SDL cursor: {0}", SDL_GetError());
}
}
@@ -77,7 +77,7 @@ namespace Nz
{
m_cursor = SDL_CreateSystemCursor(s_systemCursorIds[cursor]);
if (!m_cursor)
NazaraError("failed to create SDL cursor: {0}", std::string(SDL_GetError()));
NazaraErrorFmt("failed to create SDL cursor: {0}", SDL_GetError());
}
}

View File

@@ -16,7 +16,7 @@ namespace Nz
m_iconImage = icon;
if (!m_iconImage.Convert(PixelFormat::BGRA8))
NazaraError("Failed to convert icon to BGRA8");
NazaraError("failed to convert icon to BGRA8");
m_icon = SDL_CreateRGBSurfaceWithFormatFrom(
m_iconImage.GetPixels(),
@@ -28,7 +28,7 @@ namespace Nz
);
if (!m_icon)
NazaraError("failed to create SDL Surface for icon: {0}", std::string(SDL_GetError()));
NazaraErrorFmt("failed to create SDL Surface for icon: {0}", SDL_GetError());
}
IconImpl::~IconImpl()

View File

@@ -122,7 +122,7 @@ namespace Nz
if (handle)
SDL_WarpMouseInWindow(handle, x, y);
else
NazaraError("Invalid window handle");
NazaraError("invalid window handle");
}
void InputImpl::StartTextInput()

View File

@@ -91,7 +91,7 @@ namespace Nz
m_handle = SDL_CreateWindow(title.c_str(), x, y, width, height, winStyle);
if (!m_handle)
{
NazaraError("failed to create window: {0}", Error::GetLastSystemError());
NazaraErrorFmt("failed to create window: {0}", Error::GetLastSystemError());
return false;
}
@@ -133,7 +133,7 @@ namespace Nz
m_handle = SDL_CreateWindowFrom(systemHandle);
if (!m_handle)
{
NazaraError("Invalid handle");
NazaraError("invalid handle");
return false;
}
@@ -213,7 +213,7 @@ namespace Nz
{
#ifndef NAZARA_PLATFORM_WEB
ErrorFlags flags(ErrorMode::ThrowException);
NazaraError("failed to retrieve window manager info: {0}", SDL_GetError());
NazaraErrorFmt("failed to retrieve window manager info: {0}", SDL_GetError());
#endif
}
@@ -556,7 +556,7 @@ namespace Nz
}
catch (...) // Don't let any exceptions go through C calls
{
NazaraError("An unknown error happened");
NazaraError("an unknown error happened");
}
return 0;

View File

@@ -60,7 +60,7 @@ namespace Nz
m_impl = std::make_unique<WindowImpl>(this);
if (!m_impl->Create(mode, title, style))
{
NazaraError("Failed to create window implementation");
NazaraError("failed to create window implementation");
return false;
}
@@ -97,7 +97,7 @@ namespace Nz
m_impl = std::make_unique<WindowImpl>(this);
if (!m_impl->Create(handle))
{
NazaraError("Unable to create window implementation");
NazaraError("unable to create window implementation");
m_impl.reset();
return false;
}
@@ -174,7 +174,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return false;
}
#endif
@@ -187,7 +187,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return false;
}
#endif
@@ -200,7 +200,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return false;
}
#endif
@@ -222,7 +222,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -244,7 +244,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -257,7 +257,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -270,7 +270,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -283,7 +283,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -296,7 +296,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -309,7 +309,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -322,7 +322,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -335,7 +335,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -348,7 +348,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -361,7 +361,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -374,7 +374,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif
@@ -429,7 +429,7 @@ namespace Nz
#if NAZARA_PLATFORM_SAFE
if (!m_impl)
{
NazaraError("Window not created");
NazaraError("window not created");
return;
}
#endif

View File

@@ -16,7 +16,7 @@ namespace Nz
File file(sourcePath);
if (!file.Open(OpenMode::ReadOnly | OpenMode::Text))
{
NazaraError("Failed to open \"{0}\"", sourcePath);
NazaraErrorFmt("failed to open \"{0}\"", sourcePath);
return {};
}
@@ -25,7 +25,7 @@ namespace Nz
std::vector<Nz::UInt8> source(length);
if (file.Read(&source[0], length) != length)
{
NazaraError("Failed to read program file");
NazaraError("failed to read program file");
return {};
}

View File

@@ -189,7 +189,7 @@ namespace Nz
#endif
if (!impl || !impl->Prepare(config))
{
NazaraError("Failed to create renderer implementation");
NazaraError("failed to create renderer implementation");
continue;
}
@@ -235,7 +235,7 @@ namespace Nz
if (auto it = renderAPIStr.find(value); it != renderAPIStr.end())
preferredAPI = it->second;
else
NazaraError("unknown render API \"{0}\"", value);
NazaraErrorFmt("unknown render API \"{0}\"", value);
}
if (parameters.GetParameter("render-api-validation", &value))
@@ -251,7 +251,7 @@ namespace Nz
if (auto it = validationStr.find(value); it != validationStr.end())
validationLevel = it->second;
else
NazaraError("unknown validation level \"{0}\"", value);
NazaraErrorFmt("unknown validation level \"{0}\"", value);
}
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -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);

View 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);
}

View File

@@ -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()

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -478,7 +478,7 @@ namespace Nz
if (m_meshes.empty())
{
NazaraError("No meshes");
NazaraError("no meshes");
return false;
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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************************************/

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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());

View File

@@ -92,7 +92,7 @@ namespace Nz
break;
default:
NazaraWarning("Device {0} has handled device type ({1:#x})", deviceInfo.name, UnderlyingCast(physDevice.properties.deviceType));
NazaraWarningFmt("Device {0} has handled device type ({1:#x})", deviceInfo.name, UnderlyingCast(physDevice.properties.deviceType));
[[fallthrough]];
case VK_PHYSICAL_DEVICE_TYPE_OTHER:
deviceInfo.type = RenderDeviceType::Unknown;
@@ -121,7 +121,7 @@ namespace Nz
}
// This cannot happen if physDevice is valid, as we retrieved every physical device
NazaraInternalError("Invalid physical device: {0}", static_cast<void*>(physDevice));
NazaraInternalErrorFmt("Invalid physical device: {0}", static_cast<void*>(physDevice));
static Vk::PhysicalDevice dummy;
return dummy;
@@ -206,7 +206,7 @@ namespace Nz
enabledLayers.push_back(additionalLayers.back().c_str());
}
else
NazaraWarning("missing parameter {0}", parameterName);
NazaraWarningFmt("missing parameter {0}", parameterName);
}
}
@@ -269,7 +269,7 @@ namespace Nz
enabledExtensions.push_back(additionalExtensions.back().c_str());
}
else
NazaraWarning("missing parameter {0}", parameterName);
NazaraWarningFmt("missing parameter {0}", parameterName);
}
}
@@ -323,7 +323,7 @@ namespace Nz
if (!s_instance.Create(validationLevel, instanceInfo))
{
NazaraError("failed to create instance: {0}", TranslateVulkanError(s_instance.GetLastErrorCode()));
NazaraErrorFmt("failed to create instance: {0}", TranslateVulkanError(s_instance.GetLastErrorCode()));
return false;
}
@@ -340,7 +340,7 @@ namespace Nz
Vk::PhysicalDevice deviceInfo;
if (!s_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queueFamilies))
{
NazaraWarning("failed to query physical device queue family properties for {0} ({1:#x})", deviceInfo.properties.deviceName, deviceInfo.properties.deviceID);
NazaraWarningFmt("failed to query physical device queue family properties for {0} ({1:#x})", deviceInfo.properties.deviceName, deviceInfo.properties.deviceID);
continue;
}
@@ -357,7 +357,7 @@ namespace Nz
deviceInfo.extensions.emplace(extProperty.extensionName);
}
else
NazaraWarning("failed to query physical device extensions for {0} ({1:#x})", deviceInfo.properties.deviceName, deviceInfo.properties.deviceID);
NazaraWarningFmt("failed to query physical device extensions for {0} ({1:#x})", deviceInfo.properties.deviceName, deviceInfo.properties.deviceID);
s_physDevices.emplace_back(std::move(deviceInfo));
}
@@ -430,7 +430,7 @@ namespace Nz
{
bool supportPresentation = false;
if (!surface.GetSupportPresentation(deviceInfo.physDevice, i, &supportPresentation))
NazaraWarning("failed to get presentation support of queue family #{0}", i);
NazaraWarningFmt("failed to get presentation support of queue family #{0}", i);
if (deviceInfo.queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
{
@@ -540,7 +540,7 @@ namespace Nz
enabledLayers.push_back(additionalLayers.back().c_str());
}
else
NazaraWarning("missing parameter {0}", parameterName);
NazaraWarningFmt("missing parameter {0}", parameterName);
}
}
@@ -577,7 +577,7 @@ namespace Nz
enabledExtensions.push_back(additionalExtensions.back().c_str());
}
else
NazaraWarning("missing parameter {0}", parameterName);
NazaraWarningFmt("missing parameter {0}", parameterName);
}
}
@@ -607,7 +607,7 @@ namespace Nz
std::shared_ptr<VulkanDevice> device = std::make_shared<VulkanDevice>(s_instance, enabledFeatures, BuildRenderDeviceInfo(deviceInfo));
if (!device->Create(deviceInfo, createInfo))
{
NazaraError("failed to create Vulkan Device: {0}", TranslateVulkanError(device->GetLastErrorCode()));
NazaraErrorFmt("failed to create Vulkan Device: {0}", TranslateVulkanError(device->GetLastErrorCode()));
return {};
}

View File

@@ -79,7 +79,7 @@ namespace Nz
VkResult result = vmaMapMemory(m_device.GetMemoryAllocator(), m_allocation, &mappedPtr);
if (result != VK_SUCCESS)
{
NazaraError("failed to map buffer: {0}", TranslateVulkanError(result));
NazaraErrorFmt("failed to map buffer: {0}", TranslateVulkanError(result));
return nullptr;
}
@@ -101,7 +101,7 @@ namespace Nz
VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_stagingBuffer, &m_stagingAllocation, &allocationInfo);
if (result != VK_SUCCESS)
{
NazaraError("failed to allocate staging buffer: {0}", TranslateVulkanError(result));
NazaraErrorFmt("failed to allocate staging buffer: {0}", TranslateVulkanError(result));
return nullptr;
}

View File

@@ -274,13 +274,13 @@ namespace Nz
{
if (!SetupSwapchain(m_device.GetPhysicalDeviceInfo()))
{
NazaraError("Failed to create swapchain");
NazaraError("failed to create swapchain");
return false;
}
if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer())
{
NazaraError("Failed to create depth buffer");
NazaraError("failed to create depth buffer");
return false;
}
@@ -402,20 +402,20 @@ namespace Nz
if (!m_depthBuffer.Create(m_device, imageCreateInfo))
{
NazaraError("Failed to create depth buffer");
NazaraError("failed to create depth buffer");
return false;
}
VkMemoryRequirements memoryReq = m_depthBuffer.GetMemoryRequirements();
if (!m_depthBufferMemory.Create(m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT))
{
NazaraError("Failed to allocate depth buffer memory");
NazaraError("failed to allocate depth buffer memory");
return false;
}
if (!m_depthBuffer.BindImageMemory(m_depthBufferMemory))
{
NazaraError("Failed to bind depth buffer to buffer");
NazaraError("failed to bind depth buffer to buffer");
return false;
}
@@ -451,7 +451,7 @@ namespace Nz
if (!m_depthBufferView.Create(m_device, imageViewCreateInfo))
{
NazaraError("Failed to create depth buffer view");
NazaraError("failed to create depth buffer view");
return false;
}
@@ -484,7 +484,7 @@ namespace Nz
if (!framebuffer.Create(*m_swapchain.GetDevice(), frameBufferCreate))
{
NazaraError("failed to create framebuffer for image #{0}: {1}", i, TranslateVulkanError(framebuffer.GetLastErrorCode()));
NazaraErrorFmt("failed to create framebuffer for image #{0}: {1}", i, TranslateVulkanError(framebuffer.GetLastErrorCode()));
return false;
}
@@ -499,7 +499,7 @@ namespace Nz
std::optional<PixelFormat> colorFormat = FromVulkan(m_surfaceFormat.format);
if (!colorFormat)
{
NazaraError("unhandled vulkan pixel format ({0:#x})", UnderlyingCast(m_surfaceFormat.format));
NazaraErrorFmt("unhandled vulkan pixel format ({0:#x})", UnderlyingCast(m_surfaceFormat.format));
return false;
}
@@ -509,7 +509,7 @@ namespace Nz
depthStencilFormat = FromVulkan(m_depthStencilFormat);
if (!depthStencilFormat)
{
NazaraError("unhandled vulkan pixel format ({0:#x})", UnderlyingCast(m_depthStencilFormat));
NazaraErrorFmt("unhandled vulkan pixel format ({0:#x})", UnderlyingCast(m_depthStencilFormat));
return false;
}
}
@@ -580,7 +580,7 @@ namespace Nz
if (!success)
{
NazaraError("failed to create Vulkan surface: {0}", TranslateVulkanError(m_surface.GetLastErrorCode()));
NazaraErrorFmt("failed to create Vulkan surface: {0}", TranslateVulkanError(m_surface.GetLastErrorCode()));
return false;
}
@@ -592,7 +592,7 @@ namespace Nz
VkSurfaceCapabilitiesKHR surfaceCapabilities;
if (!m_surface.GetCapabilities(deviceInfo.physDevice, &surfaceCapabilities))
{
NazaraError("Failed to query surface capabilities");
NazaraError("failed to query surface capabilities");
return false;
}
@@ -641,7 +641,7 @@ namespace Nz
Vk::Swapchain newSwapchain;
if (!newSwapchain.Create(m_device, swapchainInfo))
{
NazaraError("failed to create swapchain: {0}", TranslateVulkanError(newSwapchain.GetLastErrorCode()));
NazaraErrorFmt("failed to create swapchain: {0}", TranslateVulkanError(newSwapchain.GetLastErrorCode()));
return false;
}

View File

@@ -57,7 +57,7 @@ namespace Nz
m_lastErrorCode = m_instance.vkCreateDevice(deviceInfo.physDevice, &createInfo, allocator, &m_device);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to create Vulkan device: {0}", TranslateVulkanError(m_lastErrorCode));
NazaraErrorFmt("failed to create Vulkan device: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -103,7 +103,7 @@ namespace Nz
}
catch (const std::exception& e)
{
NazaraError("Failed to query device function: {0}", e.what());
NazaraErrorFmt("Failed to query device function: {0}", e.what());
return false;
}
@@ -173,7 +173,7 @@ namespace Nz
Vk::CommandPool& commandPool = m_internalData->commandPools[queueType];
if (!commandPool.Create(*this, m_defaultQueues[queueType], VK_COMMAND_POOL_CREATE_TRANSIENT_BIT))
{
NazaraError("failed to create command pool: {0}", TranslateVulkanError(commandPool.GetLastErrorCode()));
NazaraErrorFmt("failed to create command pool: {0}", TranslateVulkanError(commandPool.GetLastErrorCode()));
return false;
}
}
@@ -237,7 +237,7 @@ namespace Nz
m_lastErrorCode = vmaCreateAllocator(&allocatorInfo, &m_memAllocator);
if (m_lastErrorCode != VK_SUCCESS)
{
NazaraError("failed to initialize Vulkan Memory Allocator (VMA): {0}", TranslateVulkanError(m_lastErrorCode));
NazaraErrorFmt("failed to initialize Vulkan Memory Allocator (VMA): {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -131,7 +131,7 @@ namespace Nz::Vk
m_lastErrorCode = Loader::vkCreateInstance(&createInfo, allocator, &m_instance);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to create Vulkan instance: {0}", TranslateVulkanError(m_lastErrorCode));
NazaraErrorFmt("failed to create Vulkan instance: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -173,7 +173,7 @@ namespace Nz::Vk
}
catch (const std::exception& e)
{
NazaraError("Failed to query instance function: {0}", e.what());
NazaraErrorFmt("Failed to query instance function: {0}", e.what());
return false;
}
@@ -192,7 +192,7 @@ namespace Nz::Vk
m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, nullptr);
if (m_lastErrorCode != VkResult::VK_SUCCESS || deviceCount == 0)
{
NazaraError("failed to query physical device count: {0}", TranslateVulkanError(m_lastErrorCode));
NazaraErrorFmt("failed to query physical device count: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -201,7 +201,7 @@ namespace Nz::Vk
m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, devices->data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to query physical devices: {0}", TranslateVulkanError(m_lastErrorCode));
NazaraErrorFmt("failed to query physical devices: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -217,7 +217,7 @@ namespace Nz::Vk
m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, nullptr);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to query extension properties count: {0}", TranslateVulkanError(m_lastErrorCode));
NazaraErrorFmt("failed to query extension properties count: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -229,7 +229,7 @@ namespace Nz::Vk
m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, extensionProperties->data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to query extension properties count: {0}", TranslateVulkanError(m_lastErrorCode));
NazaraErrorFmt("failed to query extension properties count: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -21,7 +21,7 @@ namespace Nz
s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, nullptr);
if (s_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to get instance extension properties count: {0}", TranslateVulkanError(s_lastErrorCode));
NazaraErrorFmt("failed to get instance extension properties count: {0}", TranslateVulkanError(s_lastErrorCode));
return false;
}
@@ -30,7 +30,7 @@ namespace Nz
s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data());
if (s_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to enumerate instance extension properties: {0}", TranslateVulkanError(s_lastErrorCode));
NazaraErrorFmt("failed to enumerate instance extension properties: {0}", TranslateVulkanError(s_lastErrorCode));
return false;
}
@@ -46,7 +46,7 @@ namespace Nz
s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, nullptr);
if (s_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to get instance layer properties count: {0}", TranslateVulkanError(s_lastErrorCode));
NazaraErrorFmt("failed to get instance layer properties count: {0}", TranslateVulkanError(s_lastErrorCode));
return false;
}
@@ -55,7 +55,7 @@ namespace Nz
s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data());
if (s_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("failed to enumerate instance layer properties: {0}", TranslateVulkanError(s_lastErrorCode));
NazaraErrorFmt("failed to enumerate instance layer properties: {0}", TranslateVulkanError(s_lastErrorCode));
return false;
}
@@ -97,7 +97,7 @@ namespace Nz
vkGetInstanceProcAddr = reinterpret_cast<PFN_vkGetInstanceProcAddr>(s_vulkanLib.GetSymbol("vkGetInstanceProcAddr"));
if (!vkGetInstanceProcAddr)
{
NazaraError("Failed to get symbol \"vkGetInstanceProcAddr\": {0}", s_vulkanLib.GetLastError());
NazaraErrorFmt("Failed to get symbol \"vkGetInstanceProcAddr\": {0}", s_vulkanLib.GetLastError());
continue;
}
@@ -105,7 +105,7 @@ namespace Nz
{
PFN_vkVoidFunction func = vkGetInstanceProcAddr(nullptr, name);
if (!func && !opt)
NazaraError("Failed to get {0} address", name);
NazaraErrorFmt("Failed to get {0} address", name);
return func;
};
@@ -123,7 +123,7 @@ namespace Nz
}
catch (const std::exception& e)
{
NazaraError("Failed to query device function: {0}", e.what());
NazaraErrorFmt("Failed to query device function: {0}", e.what());
return false;
}
}