Practical Tools for Simple Design
Loading...
Searching...
No Matches
Image.hpp
1#ifndef UTIL_IMAGE_HPP
2#define UTIL_IMAGE_HPP
3
4#include "pch.hpp" // IWYU pragma: export
5
6#include <glm/fwd.hpp>
7
8#include "Core/Drawable.hpp"
9#include "Core/Program.hpp"
10#include "Core/Texture.hpp"
11#include "Core/UniformBuffer.hpp"
12#include "Core/VertexArray.hpp"
13
14#include "Util/AssetStore.hpp"
15#include "Util/Transform.hpp"
16
17namespace Util {
26class Image : public Core::Drawable {
27public:
33 explicit Image(const std::string &filepath);
34
42 glm::vec2 GetSize() const override { return m_Size; };
43
51 void SetImage(const std::string &filepath);
52
62 void Draw(const Core::Matrices &data) override;
63
64private:
65 void InitProgram();
66 void InitVertexArray();
67 void InitUniformBuffer();
68
69 static constexpr int UNIFORM_SURFACE_LOCATION = 0;
70
71 static std::unique_ptr<Core::Program> s_Program;
72 static std::unique_ptr<Core::VertexArray> s_VertexArray;
73 std::unique_ptr<Core::UniformBuffer<Core::Matrices>> m_UniformBuffer;
74
76
77private:
78 std::unique_ptr<Core::Texture> m_Texture = nullptr;
79
80 std::string m_Path;
81 glm::vec2 m_Size;
82};
83} // namespace Util
84
85#endif
Definition Drawable.hpp:14
A class template for managing assets.
Definition AssetStore.hpp:20
glm::vec2 GetSize() const override
Retrieves the size of the image.
Definition Image.hpp:42
void Draw(const Core::Matrices &data) override
Draws the image with a given transform and z-index.
void SetImage(const std::string &filepath)
Sets the image to the specified file path.
Image(const std::string &filepath)
Constructor that takes a file path to the image.
Useful tools for development.
Definition Animation.hpp:12
Definition Drawable.hpp:9