raylibstarter 0.1.0
texture2d.h
Go to the documentation of this file.
1#pragma once
2
3#include <raylib.h>
4
5namespace game::core {
6 /**
7 * @note A Raylib Texture2D structure contains width and height information as well as the ID of the associated graphics
8 * texture in VRAM. Copy and assignment operators of this class are therefore deleted, since a copy of an object of
9 * this class should correctly also mean a copy of the VRAM texture, which is not normally wanted.
10 * Of course, it still makes sense to use one texture for several use cases (e.g. two sprite objects that use the
11 * same texture) and to keep it in VRAM only once. The Texture2D class should therefore preferably be used with
12 * smart pointers. With the last release of the object, the texture is then unloaded from the VRAM via the destructor.
13 *
14 * @brief The class Texture2D encapsulates the Raylib structure Texture2D and takes care of the correct loading and unloading of the texture into the VRAM.
15 */
16 class Texture2D final {
17 public:
18 Texture2D() = delete;
19
20 /**
21 * Creates a new Texture2D object and loads the image file specified as parameter as texture into the VRAM.
22 * @brief Constructor.
23 * @param filename File name of the image file to load. All Raylib compatible file types are supported.
24 */
25 explicit Texture2D(const char *filename);
26
28
29 Texture2D &operator=(const Texture2D &) = delete;
30
31 /**
32 * Defines if the mouse support should be activated
33 * @brief Destructor
34 */
35 ~Texture2D();
36
37 /**
38 * @return A reference to the embedded Raylib Texture2D structure.
39 */
40 [[nodiscard]] const ::Texture2D &texture() const;
41
42 /**
43 * @return The width of the associated texture.
44 */
45 [[nodiscard]] const int &width() const;
46
47 /**
48 * @return The height of the associated texture.
49 */
50 [[nodiscard]] const int &height() const;
51
52 private:
53 /// Raylib Texture2D structure which contains width, height and the ID of the associated VRAM texture.
55 };
56
57}
The class Texture2D encapsulates the Raylib structure Texture2D and takes care of the correct loading...
Definition: texture2d.h:16
const ::Texture2D & texture() const
Definition: texture2d.cpp:15
const int & width() const
Definition: texture2d.cpp:19
::Texture2D texture_
Raylib Texture2D structure which contains width, height and the ID of the associated VRAM texture.
Definition: texture2d.h:54
Texture2D & operator=(const Texture2D &)=delete
const int & height() const
Definition: texture2d.cpp:23
~Texture2D()
Destructor.
Definition: texture2d.cpp:10
Texture2D(const game::core::Texture2D &texture)=delete