8#include <nlohmann/json.hpp>
10#include "galaxy/core/ServiceLocator.hpp"
41 this->
m_vao = std::move(s.m_vao);
42 this->
m_tint = std::move(s.m_tint);
43 this->
m_name = std::move(s.m_name);
47 s.m_texture =
nullptr;
61 this->
m_vao = std::move(s.m_vao);
62 this->
m_tint = std::move(s.m_tint);
63 this->
m_name = std::move(s.m_name);
67 s.m_texture =
nullptr;
84 auto& cache = core::ServiceLocator<resource::Textures>::ref();
85 auto tex = cache.get(texture);
98 auto indices = graphics::gen_default_indices();
114 auto& cache = core::ServiceLocator<resource::Textures>::ref();
115 auto tex = cache.get(texture);
140 m_vertices[2].m_texels.y = graphics::map_y_texel(rect.y + rect.height,
m_texture->height());
145 m_vertices[3].m_texels.y = graphics::map_y_texel(rect.y + rect.height,
m_texture->height());
147 auto indices = graphics::gen_default_indices();
180 m_vertices[2].m_texels.y = graphics::map_y_texel(rect.y + rect.height,
m_texture->height());
185 m_vertices[3].m_texels.y = graphics::map_y_texel(rect.y + rect.height,
m_texture->height());
210 nlohmann::json json =
"{}"_json;
212 json[
"tint"][
"r"] =
m_tint.r<std::uint8_t>();
213 json[
"tint"][
"g"] =
m_tint.g<std::uint8_t>();
214 json[
"tint"][
"b"] =
m_tint.b<std::uint8_t>();
215 json[
"tint"][
"a"] =
m_tint.a<std::uint8_t>();
222 const auto& tint = json.at(
"tint");
223 m_tint.set_r(tint.at(
"r").get<std::uint8_t>());
224 m_tint.set_g(tint.at(
"g").get<std::uint8_t>());
225 m_tint.set_b(tint.at(
"b").get<std::uint8_t>());
226 m_tint.set_a(tint.at(
"a").get<std::uint8_t>());
#define GALAXY_LOG(level, msg,...)
A sprite is a texture with vertex data.
const math::fRect & get_clip() const
Get texture clip.
math::fRect m_clip
Texture clip.
void deserialize(const nlohmann::json &json) override
Deserializes from object.
graphics::Colour m_tint
Texture tint.
const std::string & get_texture_name() const
Texture name.
void set_clip(const math::fRect &rect)
Set texture clip.
graphics::Texture2D * get_texture()
Get texture.
graphics::VertexArray m_vao
Vertex Array Object.
Sprite & operator=(Sprite &&)
Move assignment operator.
nlohmann::json serialize() override
Serializes object.
std::array< graphics::Vertex, 4 > m_vertices
Vertex data.
std::string m_name
Texture debug name.
virtual ~Sprite()
Destructor.
void set_texture(const std::string &texture)
Sets the texture and vertex data.
graphics::Texture2D * m_texture
Texture.