netejant capçaleres

This commit is contained in:
2025-11-12 13:47:19 +01:00
parent e626ec9763
commit 9cf45062a3
21 changed files with 198 additions and 1224 deletions

View File

@@ -7,7 +7,30 @@
struct Color; // lines 11-11
class Texture {
public:
explicit Texture(SDL_Renderer* renderer, std::string path = std::string()); // Constructor
~Texture(); // Destructor
auto loadFromFile(const std::string& path) -> bool; // Carga una imagen desde un fichero
auto createBlank(int width, int height, SDL_PixelFormat format = SDL_PIXELFORMAT_RGBA8888, SDL_TextureAccess access = SDL_TEXTUREACCESS_STREAMING) -> bool; // Crea una textura en blanco
auto reLoad() -> bool; // Recarga la textura
void setColor(Uint8 red, Uint8 green, Uint8 blue); // Establece el color para la modulacion
void setColor(Color color); // Establece el color para la modulacion
void setBlendMode(SDL_BlendMode blending); // Establece el blending
void setAlpha(Uint8 alpha); // Establece el alpha para la modulación
void setAsRenderTarget(SDL_Renderer* renderer); // Establece la textura como objetivo de renderizado
void render(float x, float y, SDL_FRect* clip = nullptr, float zoom_w = 1, float zoom_h = 1, double angle = 0.0, SDL_FPoint* center = nullptr, SDL_FlipMode flip = SDL_FLIP_NONE); // Renderiza la textura en un punto específico
[[nodiscard]] auto getWidth() const -> int { return width_; } // Obtiene el ancho de la imagen
[[nodiscard]] auto getHeight() const -> int { return height_; } // Obtiene el alto de la imagen
auto getSDLTexture() -> SDL_Texture*; // Obtiene la textura
auto getRenderer() -> SDL_Renderer*; // Obtiene el renderizador
private:
void unloadTexture(); // Libera la memoria de la textura
// Objetos y punteros
SDL_Renderer* renderer_; // Renderizador donde dibujar la textura
SDL_Texture* texture_ = nullptr; // La textura
@@ -17,51 +40,4 @@ class Texture {
float width_ = 0.0F; // Ancho de la imagen
float height_ = 0.0F; // Alto de la imagen
std::vector<std::vector<Uint32>> palettes_; // Vector con las diferentes paletas
// Libera la memoria de la textura
void unloadTexture();
public:
// Constructor
explicit Texture(SDL_Renderer* renderer, std::string path = std::string());
// Destructor
~Texture();
// Carga una imagen desde un fichero
auto loadFromFile(const std::string& path) -> bool;
// Crea una textura en blanco
auto createBlank(int width, int height, SDL_PixelFormat format = SDL_PIXELFORMAT_RGBA8888, SDL_TextureAccess access = SDL_TEXTUREACCESS_STREAMING) -> bool;
// Establece el color para la modulacion
void setColor(Uint8 red, Uint8 green, Uint8 blue);
void setColor(Color color);
// Establece el blending
void setBlendMode(SDL_BlendMode blending);
// Establece el alpha para la modulación
void setAlpha(Uint8 alpha);
// Renderiza la textura en un punto específico
void render(float x, float y, SDL_FRect* clip = nullptr, float zoom_w = 1, float zoom_h = 1, double angle = 0.0, SDL_FPoint* center = nullptr, SDL_FlipMode flip = SDL_FLIP_NONE);
// Establece la textura como objetivo de renderizado
void setAsRenderTarget(SDL_Renderer* renderer);
// Obtiene el ancho de la imagen
[[nodiscard]] auto getWidth() const -> int { return width_; }
// Obtiene el alto de la imagen
[[nodiscard]] auto getHeight() const -> int { return height_; }
// Recarga la textura
auto reLoad() -> bool;
// Obtiene la textura
auto getSDLTexture() -> SDL_Texture*;
// Obtiene el renderizador
auto getRenderer() -> SDL_Renderer*;
};