2dkg/2dgk_5/2dgk_5/KTexture.h

44 lines
830 B
C++

#pragma once
#include <SDL_render.h>
#include <string>
namespace KapitanGame {
//Texture wrapper class
class KTexture {
public:
KTexture();
~KTexture();
KTexture(const KTexture& other) = default;
KTexture(KTexture&& other) noexcept;
KTexture& operator=(const KTexture& other);
KTexture& operator=(KTexture&& other) noexcept;
//Loads image at specified path
bool LoadFromFile(const std::string& path, SDL_Renderer* renderer);
//Deallocates texture
void Free();
//Renders texture at given point
void Render(SDL_Renderer* renderer, int x, int y, SDL_Rect* clip = nullptr, float scale = 1.f) const;
//Gets image dimensions
int GetWidth() const;
int GetHeight() const;
private:
//The actual hardware texture
SDL_Texture* Texture;
//Image dimensions
int Width;
int Height;
};
}