MyCurry/src/gamelib/texture.hpp

61 lines
1.6 KiB
C++

/*
Copyright 2016, 2017 Michele "King_DuckZ" Santullo
This file is part of MyCurry.
MyCurry is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MyCurry is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MyCurry. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "vector.hpp"
#include "safe_ptr.hh"
#include <memory>
#include <cstdint>
struct SDL_Texture;
namespace cloonel {
class SDLMain;
} //namespace cloonel
namespace curry {
struct RGBA {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
class Texture : public Kakoune::SafeCountable {
public:
Texture();
Texture (const char* parPath, cloonel::SDLMain& parSDLMain);
Texture (Texture&&) = default;
Texture (const Texture&) = delete;
~Texture() noexcept;
void load (const char* parPath, cloonel::SDLMain& parSDLMain);
void load (const char* parPath, cloonel::SDLMain& parSDLMain, RGBA parColorKey);
void load_empty (cloonel::SDLMain& parSDLMain, const vec2us& parSize);
void unload() noexcept;
SDL_Texture* texture();
const SDL_Texture* texture() const;
vec2us width_height() const;
private:
std::unique_ptr<SDL_Texture, void(*)(SDL_Texture*)> m_texture;
};
} //namespace curry