Files
demo4_sprites/source/texture.h
2024-08-21 07:35:52 +02:00

41 lines
767 B
C++

#pragma once
#include <SDL2/SDL.h>
#include <iostream>
// Texture wrapper class
class Texture
{
private:
SDL_Renderer *renderer;
SDL_Texture *texture;
// Image dimensions
int width;
int height;
public:
// Initializes variables
Texture(SDL_Renderer *renderer);
Texture(SDL_Renderer *renderer, std::string filepath);
// Deallocates memory
~Texture();
// Loads image at specified path
bool loadFromFile(std::string path);
// Deallocates texture
void free();
// Renders texture at given point
void render(SDL_Rect *src = nullptr, SDL_Rect *dst = nullptr);
// Gets image dimensions
int getWidth();
int getHeight();
// Modulación de color
void setColor(int r, int g, int b);
};