Surface usa std::vector en lloc de shared_ptr<Uint8[]>
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
#include <SDL3/SDL.h> // Para SDL_LogError, SDL_LogCategory, Uint8, SDL_...
|
#include <SDL3/SDL.h> // Para SDL_LogError, SDL_LogCategory, Uint8, SDL_...
|
||||||
|
|
||||||
#include <cstdint> // Para uint32_t
|
#include <cstdint> // Para uint32_t
|
||||||
#include <cstring> // Para memcpy
|
|
||||||
#include <fstream> // Para basic_ifstream, basic_istream, basic_ios
|
#include <fstream> // Para basic_ifstream, basic_istream, basic_ios
|
||||||
#include <iostream> // Para std::cout
|
#include <iostream> // Para std::cout
|
||||||
#include <sstream> // Para basic_istringstream
|
#include <sstream> // Para basic_istringstream
|
||||||
@@ -259,12 +258,7 @@ auto Texture::loadSurface(const std::string& file_path) -> std::shared_ptr<Surfa
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si el constructor de Surface espera un std::shared_ptr<Uint8[]>:
|
auto surface = std::make_shared<Surface>(w, h, std::move(raw_pixels));
|
||||||
size_t pixel_count = raw_pixels.size();
|
|
||||||
auto pixels = std::shared_ptr<Uint8[]>(new Uint8[pixel_count], std::default_delete<Uint8[]>()); // NOLINT(modernize-avoid-c-arrays)
|
|
||||||
std::memcpy(pixels.get(), raw_pixels.data(), pixel_count);
|
|
||||||
|
|
||||||
auto surface = std::make_shared<Surface>(w, h, pixels);
|
|
||||||
|
|
||||||
// Actualizar las dimensiones
|
// Actualizar las dimensiones
|
||||||
width_ = w;
|
width_ = w;
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ using Palette = std::array<Uint32, 256>;
|
|||||||
|
|
||||||
// Definición de Surface para imágenes con paleta
|
// Definición de Surface para imágenes con paleta
|
||||||
struct Surface {
|
struct Surface {
|
||||||
std::shared_ptr<Uint8[]> data; // NOLINT(modernize-avoid-c-arrays)
|
std::vector<Uint8> data;
|
||||||
Uint16 w, h;
|
Uint16 w, h;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Surface(Uint16 width, Uint16 height, std::shared_ptr<Uint8[]> pixels) // NOLINT(modernize-avoid-c-arrays)
|
Surface(Uint16 width, Uint16 height, std::vector<Uint8> pixels)
|
||||||
: data(std::move(pixels)),
|
: data(std::move(pixels)),
|
||||||
w(width),
|
w(width),
|
||||||
h(height) {}
|
h(height) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user