lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
image.hpp
Go to the documentation of this file.
1
11
12#pragma once
13
18
19#include <glm/glm.hpp>
20#include <memory>
21
22namespace lmgl {
23
24namespace ui {
25
32class Image : public UIElement {
33 public:
39 Image(const std::string &name = "Image");
40
44 ~Image() override = default;
45
51 inline void set_texture(std::shared_ptr<renderer::Texture> texture) { m_texture = texture; }
52
58 inline std::shared_ptr<renderer::Texture> get_texture() const { return m_texture; }
59
65 inline void set_tint(const glm::vec4 &color) { m_tint = color; }
66
72 inline const glm::vec4 &get_tint() const { return m_tint; }
73
81 void render(float canvas_width, float canvas_height, const glm::mat4 &projection) override;
82
83 private:
85 std::shared_ptr<renderer::Texture> m_texture;
86
88 glm::vec4 m_tint{1.0f, 1.0f, 1.0f, 1.0f};
89
91 static std::shared_ptr<renderer::Shader> s_shader;
92
94 static std::shared_ptr<renderer::VertexArray> s_vao;
95
97 static void initialize_resources();
98
100 static bool s_initialized;
101};
102
103} // namespace ui
104
105} // namespace lmgl
void set_tint(const glm::vec4 &color)
Set the tint color for the image.
Definition image.hpp:65
~Image() override=default
Destructor for Image.
Image(const std::string &name="Image")
Constructor for Image.
Definition image.cpp:26
std::shared_ptr< renderer::Texture > get_texture() const
Get the current texture.
Definition image.hpp:58
void render(float canvas_width, float canvas_height, const glm::mat4 &projection) override
Render the image.
Definition image.cpp:63
const glm::vec4 & get_tint() const
Get the tint color.
Definition image.hpp:72
void set_texture(std::shared_ptr< renderer::Texture > texture)
Set the texture to display.
Definition image.hpp:51
UIElement(const std::string &name="UIElement")
Constructor for UIElement.
Definition ui_element.cpp:10
Definition button.cpp:15
Forward declarations for Assimp Material structure.
Definition model_loader.cpp:12
Declaration of the Shader class for managing shader programs in OpenGL.
Texture class for managing OpenGL textures.
Base class for all UI elements.
Declaration of the VertexArray class for managing Vertex Array Objects (VAOs) in OpenGL.