aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Texture.h
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-09 15:35:36 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-09 15:35:36 +0100
commit33cd5566909ac089cdf56db38a3d1daf0cb7dd10 (patch)
tree1d684595d5e8ef88c6c874ced36e616786231dd0 /src/crepe/api/Texture.h
parent519cc5d16e65ff501d330c03eeb35d2d095ead29 (diff)
fixed the aspect ratio and removed the ratio from sprite and give it to texture. however the problem still lies with if animator is given the aspect ratio is then off
Diffstat (limited to 'src/crepe/api/Texture.h')
-rw-r--r--src/crepe/api/Texture.h34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h
index 4eb1058..c33d9e5 100644
--- a/src/crepe/api/Texture.h
+++ b/src/crepe/api/Texture.h
@@ -4,7 +4,6 @@
// headers won't be bundled with crepe. Why is this facade in the API namespace?
#include <SDL2/SDL_render.h>
-#include <functional>
#include <memory>
#include "Asset.h"
@@ -13,8 +12,6 @@
namespace crepe {
-class SDLContext;
-class Animator;
class Mediator;
/**
@@ -30,14 +27,36 @@ public:
/**
* \brief Constructs a Texture from an Asset resource.
* \param src Asset with texture data to load.
+ * \param mediator use the SDLContext reference to load the image
*/
Texture(const Asset & src, Mediator & mediator);
/**
- * \brief Destroys the Texture instance, freeing associated resources.
+ * \brief Destroys the Texture instance
*/
~Texture();
+ /**
+ * \brief get width and height of image in pixels
+ * \return pixel size width and height
+ *
+ */
+ const ivec2 & get_size() const noexcept;
+
+ /**
+ * \brief aspect_ratio of image
+ * \return ratio
+ *
+ */
+ const float & get_ratio() const noexcept;
+
+ /**
+ * \brief get the image texture
+ * \return SDL_Texture
+ *
+ */
+ SDL_Texture * get_img() const noexcept;
+
private:
//! The texture of the class from the library
std::unique_ptr<SDL_Texture, std::function<void(SDL_Texture *)>> texture;
@@ -45,11 +64,8 @@ private:
// texture size in pixel
ivec2 size;
- //! Grants SDLContext access to private members.
- friend class SDLContext;
-
- //! Grants Animator access to private members.
- friend class Animator;
+ //! ratio of image
+ float aspect_ratio;
};
} // namespace crepe