35 #include <unordered_map>
40 #include "eng3d/ttf.hpp"
41 #include "eng3d/binary_image.hpp"
42 #include "eng3d/color.hpp"
67 }
target = Eng3D::TextureOptions::Target::TEXTURE_2D;
71 }
wrap_s = Eng3D::TextureOptions::Wrap::REPEAT;
88 }
format = Eng3D::TextureOptions::Format::RGBA;
92 }
type = Eng3D::TextureOptions::Type::UNSIGNED_BYTE;
105 void _upload(SDL_Surface* surface);
118 Texture(
size_t _width,
size_t _height,
size_t _bpp = 32)
129 this->_upload(options);
137 this->_upload(surface);
144 void to_file(
const std::string& filename)
override;
154 TextureArray(
const std::string& path,
size_t _tiles_x,
size_t _tiles_y)
171 s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
176 inline std::size_t
operator()(
const std::pair<std::string, TextureOptions>& key)
const {
204 std::unordered_map<std::pair<std::string, TextureOptions>, std::shared_ptr<Eng3D::Texture>,
TextureMapHash> textures;
205 std::vector<TextureUploadRequest> unuploaded_textures;
206 std::mutex unuploaded_lock;
207 std::shared_ptr<Eng3D::Texture> white;
210 std::unordered_map<std::string, std::shared_ptr<Eng3D::Texture>> text_textures;
223 std::shared_ptr<Eng3D::Texture>
get_white();
TextureArray(const std::string &path, size_t _tiles_x, size_t _tiles_y)
void upload()
Uploads the TextureArray to the driver.
TextureException(const std::string &filename, const std::string &message)
void bind() const
Binds the texture to the current OpenGL context.
void to_file(const std::string &filename) override
void create_dummy()
This dummy texture helps to avoid crashes due to missing buffers or so, and also gives visual aid of ...
void upload(SDL_Surface *surface)
Uploads a text texture (shceduled or not) if it's scheduled, the surface is handed ownership over to ...
Texture(const std::string &path)
void upload(TextureOptions options=default_options)
Frontend for uploading (schedules or instantly uploads)
Texture(const Eng3D::IO::Asset::Base *asset)
Texture(size_t _width, size_t _height, size_t _bpp=32)
void delete_gputex()
Deletes the OpenGL representation of this texture.
void guillotine(const Eng3D::Texture &map, int x, int y, int w, int h)
General manager for textures, caches textures into the memory instead of reading them off the disk ev...
TextureManager(Eng3D::State &_s)
std::shared_ptr< Eng3D::Texture > load(const std::string &path, TextureOptions options=default_options)
Finds a texture in the list of a texture manager if the texture is already in the list we load the sa...
std::shared_ptr< Eng3D::Texture > get_white()
std::shared_ptr< Eng3D::Texture > gen_text(Eng3D::TrueType::Font &font, Eng3D::Color color, const std::string &msg)
enum Eng3D::TextureOptions::Filter min_filter
enum Eng3D::TextureOptions::Target target
enum Eng3D::TextureOptions::Wrap wrap_s
constexpr bool operator==(const TextureOptions &o) const
enum Eng3D::TextureOptions::Type type
enum Eng3D::TextureOptions::Format format
const TextureOptions default_options
void hash_combine(std::size_t &s, const T &v)
This binary image class helps load images and visual resources from the disk; the binary image IS NOT...
Primitive color type used through the engine.
Texture map has implementation.
std::size_t operator()(const std::pair< std::string, TextureOptions > &key) const