Bomberman
Texture.hpp
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2021
3 ** Bomberman
4 ** File description:
5 ** Texture
6 */
7 
8 #ifndef TEXTURE_HPP_
9 #define TEXTURE_HPP_
10 
11 #include <raylib.h>
12 #include <string>
13 #include "Utils/Cache.hpp"
15 
16 namespace RAY
17 {
20  public:
24  explicit Texture(const std::string &filename, bool lonely = false, float scale = 1, float rotation = 0);
25 
27  Texture();
28 
30  Texture(const Texture &) = default;
31 
33  Texture(const Image &);
34 
36  Texture &operator=(const Texture &) = default;
37 
39  ~Texture() override = default;
40 
42  void drawOn(RAY::Window &) override;
43 
45  Texture &use(const std::string &filename);
46 
48  void unload();
49 
51  const std::string &getResourcePath() const;
52 
53  protected:
54  private:
56  std::shared_ptr<::Texture> _texture;
57 
59  std::string _resourcePath;
60 
62 
63  INTERNAL:
65  operator ::Texture() const;
66  };
67 }
68 
69 #endif /* !IMAGE_HPP_ */
Rectangle.hpp
RAY::Texture
Object representation of a texture.
Definition: Texture.hpp:19
RAY::Texture::_texturesCache
static Cache<::Texture > _texturesCache
Definition: Texture.hpp:61
Cache.hpp
RAY::Window
Definition: Window.hpp:32
RAY::Texture::operator=
Texture & operator=(const Texture &)=default
An texture is assignable.
RAY::Texture::_resourcePath
std::string _resourcePath
path to the file the texture is loaded from
Definition: Texture.hpp:59
RAY::Texture::~Texture
~Texture() override=default
Texture destructor, will not unload ressources.
RAY
Definition: IAudio.hpp:12
RAY::Texture::use
Texture & use(const std::string &filename)
Load texture from file, lets one use one entity for multiple files.
Definition: Texture.cpp:41
RAY::Texture::getResourcePath
const std::string & getResourcePath() const
Definition: Texture.cpp:51
RAY::Texture::unload
void unload()
Unload the current texture (calls to drawOn will no-op).
Definition: Texture.cpp:68
RAY::Texture::Texture
Texture()
Create an empty texture.
Definition: Texture.cpp:22
RAY::Drawables::Drawables2D::Rectangle
Rectangle in a two-dimensional space.
Definition: Rectangle.hpp:17
RAY::Image
Object representation of a framebuffer.
Definition: Image.hpp:20
RAY::Texture::_texture
std::shared_ptr<::Texture > _texture
Texture, really, that's just it...
Definition: Texture.hpp:56
RAY::Texture::drawOn
void drawOn(RAY::Window &) override
draw texture on a window
Definition: Texture.cpp:61
RAY::Cache
A templated class used to cache ressources, indexed with a string.
Definition: Cache.hpp:23