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);
114 auto& cache = core::ServiceLocator<resource::Textures>::ref();
115 auto tex = cache.get(texture);
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");
#define GALAXY_LOG(level, msg,...)
thread_local const unsigned int indices[]
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.
void set_g(const std::uint8_t g)
Green.
void set_r(const std::uint8_t r)
Red.
void set_b(const std::uint8_t b)
Blue.
void set_a(const std::uint8_t a)
Alpha.
float width() const
Get texture width.
float height() const
Get texture height.
void buffer(std::span< Vertex > vertices, std::span< unsigned int > indicies)
Create vertex array object.
void sub_buffer(const unsigned int index, std::span< Vertex > vertices)
Sub-buffer vertex array.
std::array< Vertex, 4 > gen_quad_vertices(const float width, const float height)
Generate some default verticies.
float map_y_texel(const Type y, const float height)
Takes in a y positon texture coord and maps it to a texel.
float map_x_texel(const Type x, const float width)
Takes in a x positon texture coord and maps it to a texel.
std::array< unsigned int, 6 > gen_default_indices()
Generate some default indicies.