Treballant en la caché de les paletes

This commit is contained in:
2025-03-05 22:58:26 +01:00
parent 5cc163dd14
commit 10debde847
11 changed files with 150 additions and 323 deletions

View File

@@ -9,47 +9,22 @@
#include <vector> // for vector
struct Color; // lines 11-11
// Definiciones de tipos
/*struct Surface
{
std::shared_ptr<Uint8[]> data;
Uint16 w, h;
// Constructor
Surface(Uint16 width, Uint16 height, std::shared_ptr<Uint8[]> pixels)
: data(pixels), w(width), h(height) {}
};*/
class Texture
{
private:
// Objetos y punteros
SDL_Renderer *renderer_; // Renderizador donde dibujar la textura
SDL_Texture *texture_ = nullptr; // La textura
//std::shared_ptr<Surface> surface_ = nullptr; // Surface para usar imagenes en formato gif con paleta
// Variables
std::string path_; // Ruta de la imagen de la textura
int width_ = 0; // Ancho de la imagen
int height_ = 0; // Alto de la imagen
std::vector<std::vector<Uint32>> palettes_; // Vector con las diferentes paletas
int current_palette_ = 0; // Indice de la paleta en uso
// Crea una surface desde un fichero .gif
// std::shared_ptr<Surface> loadSurface(const std::string &file_name);
// Vuelca la surface en la textura
// void flipSurface();
// Carga una paleta desde un fichero
// std::vector<Uint32> loadPaletteFromFile(const std::string &file_name);
// Libera la memoria de la textura
void unloadTexture();
// Desencadenar la superficie actual
// void unloadSurface();
public:
// Constructor
explicit Texture(SDL_Renderer *renderer, const std::string &path = std::string());
@@ -91,15 +66,6 @@ public:
// Obtiene la textura
SDL_Texture *getSDLTexture();
// Añade una paleta a la lista
// void addPaletteFromFile(const std::string &path);
// Establece un color de la paleta
// void setPaletteColor(int palette, int index, Uint32 color);
// Cambia la paleta de la textura
// void setPalette(int palette);
// Obtiene el renderizador
SDL_Renderer *getRenderer();
};