fixing error message

This commit is contained in:
Kbz-8
2025-01-24 20:23:28 +01:00
parent 04294418b7
commit cd9d2dde95
3 changed files with 13 additions and 12 deletions

View File

@@ -4,6 +4,7 @@
#include <Core/SDLManager.h> #include <Core/SDLManager.h>
#include <Renderer/RenderCore.h> #include <Renderer/RenderCore.h>
#include <mlx.h> #include <mlx.h>
#include <mlx_extended.h>
#include <Core/Memory.h> #include <Core/Memory.h>
#include <Core/Handles.h> #include <Core/Handles.h>
@@ -224,7 +225,7 @@ extern "C"
MLX_CHECK_APPLICATION_POINTER(mlx); MLX_CHECK_APPLICATION_POINTER(mlx);
if (filename == nullptr) if (filename == nullptr)
{ {
mlx::Error("PNG loader: filename is NULL"); mlx::Error("Image loader: filename is NULL");
return nullptr; return nullptr;
} }
std::filesystem::path file(filename); std::filesystem::path file(filename);
@@ -234,7 +235,7 @@ extern "C"
file.extension() != ".bmp" && file.extension() != ".bmp" &&
file.extension() != ".dib") file.extension() != ".dib")
{ {
mlx::Error("PNG loader: not a valid file format '%'", filename); mlx::Error("Image loader: not a valid file format '%'", filename);
return nullptr; return nullptr;
} }
return mlx->app->NewStbTexture(filename, width, height); return mlx->app->NewStbTexture(filename, width, height);

View File

@@ -21,14 +21,14 @@ namespace mlx
void* MemManager::AlignedMalloc(std::size_t alignment, std::size_t size) void* MemManager::AlignedMalloc(std::size_t alignment, std::size_t size)
{ {
#ifdef MLX_COMPILER_MSVC
void* ptr = _aligned_malloc(size, alignment);
#else
if(alignment < sizeof(void*)) if(alignment < sizeof(void*))
alignment = sizeof(void*); alignment = sizeof(void*);
if(size % alignment != 0) if(size % alignment != 0)
size += alignment - (size % alignment); size += alignment - (size % alignment);
#ifdef MLX_COMPILER_MSVC
void* ptr = _aligned_malloc(alignment, size);
#else
void* ptr = std::aligned_alloc(alignment, size); void* ptr = std::aligned_alloc(alignment, size);
#endif #endif
if(ptr != nullptr) if(ptr != nullptr)
@@ -67,7 +67,7 @@ namespace mlx
auto it = std::find_if(s_blocks.begin(), s_blocks.end(), [=](const Descriptor& rhs){ return ptr == rhs.ptr; }); auto it = std::find_if(s_blocks.begin(), s_blocks.end(), [=](const Descriptor& rhs){ return ptr == rhs.ptr; });
#ifdef MLX_COMPILER_MSVC #ifdef MLX_COMPILER_MSVC
void* ptr2 = _aligned_realloc(ptr, alignment, size); void* ptr2 = _aligned_realloc(ptr, size, alignment);
if(it != s_blocks.end()) if(it != s_blocks.end())
s_blocks.erase(it); s_blocks.erase(it);
#else #else

View File

@@ -392,12 +392,12 @@ namespace mlx
if(!std::filesystem::exists(file)) if(!std::filesystem::exists(file))
{ {
Error("Image: file not found %", file); Error("Image loader: file not found %", file);
return nullptr; return nullptr;
} }
if(stbi_is_hdr(filename.c_str())) if(stbi_is_hdr(filename.c_str()))
{ {
Error("Texture: unsupported image format from % (HDR image)", file); Error("Image loader: unsupported image format from % (HDR image)", file);
return nullptr; return nullptr;
} }