49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#pragma once
|
|
#include <SDL_render.h>
|
|
#include <string>
|
|
|
|
namespace KapitanGame {
|
|
//Texture wrapper class
|
|
class KTexture {
|
|
public:
|
|
KTexture();
|
|
|
|
~KTexture();
|
|
|
|
|
|
KTexture(const KTexture& other) = delete;
|
|
|
|
KTexture(KTexture&& other) noexcept;
|
|
|
|
KTexture& operator=(const KTexture& other) = delete;
|
|
|
|
KTexture& operator=(KTexture&& other) noexcept;
|
|
|
|
//Loads image at specified path
|
|
bool LoadFromFile(const std::string& path, SDL_Renderer* renderer);
|
|
|
|
bool LoadFromSurface(SDL_Surface* surface, SDL_Renderer* renderer);
|
|
|
|
//Deallocates texture
|
|
void Free();
|
|
|
|
//Renders texture at given point
|
|
void Render(SDL_Renderer* renderer, float x, float y, SDL_Rect* clip = nullptr, float scale = 1.f) const;
|
|
|
|
void RenderEx(SDL_Renderer* renderer, float x, float y, double degrees = 0, SDL_Rect* clip = nullptr, float scale = 1.f, SDL_RendererFlip flip = SDL_FLIP_NONE) const;
|
|
|
|
//Gets image dimensions
|
|
int GetWidth() const;
|
|
int GetHeight() const;
|
|
|
|
private:
|
|
//The actual hardware texture
|
|
SDL_Texture* Texture;
|
|
|
|
//Image dimensions
|
|
int Width;
|
|
int Height;
|
|
};
|
|
|
|
}
|