acabat amb SDL_Log

This commit is contained in:
2025-03-27 20:56:21 +01:00
parent 8afca398e9
commit 36b3048070
11 changed files with 340 additions and 128 deletions

View File

@@ -1,3 +1,4 @@
#define STB_IMAGE_IMPLEMENTATION
#include "texture.h"
#include <SDL3/SDL_error.h> // Para SDL_GetError
#include <SDL3/SDL_log.h> // Para SDL_LogError, SDL_LogCategory, SDL_Log...
@@ -12,9 +13,6 @@
#include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_a...
#include "utils.h" // Para getFileName, Color, printWithDots
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" // Para stbi_failure_reason, stbi_image_free
// Constructor
Texture::Texture(SDL_Renderer *renderer, const std::string &path)
: renderer_(renderer),
@@ -73,7 +71,7 @@ bool Texture::loadFromFile(const std::string &file_path)
}
else
{
printWithDots("Image : ", getFileName(file_path), "[ LOADED ]");
printWithDots("Texture : ", getFileName(file_path), "[ LOADED ]");
}
int pitch;
@@ -286,7 +284,7 @@ std::shared_ptr<Surface> Texture::loadSurface(const std::string &file_path)
width_ = w;
height_ = h;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GIF %s cargado correctamente.", file_path.c_str());
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "GIF %s cargado correctamente.", file_path.c_str());
return surface;
}
@@ -331,7 +329,7 @@ std::vector<Uint32> Texture::loadPaletteFromFile(const std::string &file_path)
}
else
{
printWithDots("Image : ", getFileName(file_path), "[ LOADED ]");
printWithDots("Palette : ", getFileName(file_path), "[ LOADED ]");
}
// Obtener el tamaño del archivo y leerlo en un buffer
@@ -360,7 +358,7 @@ std::vector<Uint32> Texture::loadPaletteFromFile(const std::string &file_path)
palette.push_back((color << 8) | 0xFF); // Resultado: 0xRRGGBBAA
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Paleta cargada correctamente desde %s", file_path.c_str());
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "Paleta cargada correctamente desde %s", file_path.c_str());
return palette;
}