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
16namespace Util {
25class Image : public Core::Drawable {
26public:
34 Image(const std::string &filepath, bool useAA = true);
35
43 glm::vec2 GetSize() const override { return m_Size; };
44
52 void SetImage(const std::string &filepath);
53
66 void UseAntiAliasing(bool useAA);
67
77 void Draw(const Core::Matrices &data) override;
78
79private:
80 void InitProgram();
81 void InitVertexArray();
82 void InitUniformBuffer();
83
84 static constexpr int UNIFORM_SURFACE_LOCATION = 0;
85
86 static std::unique_ptr<Core::Program> s_Program;
87 static std::unique_ptr<Core::VertexArray> s_VertexArray;
88 std::unique_ptr<Core::UniformBuffer<Core::Matrices>> m_UniformBuffer;
89
91
92private:
93 std::unique_ptr<Core::Texture> m_Texture = nullptr;
94
95 std::string m_Path;
96 glm::vec2 m_Size;
97};
98} // namespace Util
99
100#endif
Definition: Drawable.hpp:14
A class template for managing assets.
Definition: AssetStore.hpp:20
A class representing an image.
Definition: Image.hpp:25
glm::vec2 GetSize() const override
Retrieves the size of the image.
Definition: Image.hpp:43
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.
void UseAntiAliasing(bool useAA)
Sets whether anti-aliasing (AA) should be enabled or disabled.
Image(const std::string &filepath, bool useAA=true)
Constructor that takes a file path to the image.
Useful tools for development.
Definition: Animation.hpp:12
Definition: Drawable.hpp:9