10#include "galaxy/core/ServiceLocator.hpp"
30 auto& lua = core::ServiceLocator<sol::state>::ref();
32 auto animation_type = lua.new_usertype<
graphics::Animation>(
"Animation", sol::constructors<graphics::Animation()>());
45 auto frame_type = lua.new_usertype<
graphics::Frame>(
"Frame", sol::constructors<graphics::Frame()>());
53 auto camera_type = lua.new_usertype<
graphics::Camera>(
"Camera", sol::constructors<graphics::Camera()>());
80 auto colour_type = lua.new_usertype<
graphics::Colour>(
"Colour", sol::constructors<graphics::Colour()>());
95 auto rendercommand_type = lua.new_usertype<
graphics::RenderCommand>(
"RenderCommand", sol::constructors<graphics::RenderCommand()>());
105 auto renderdata_type = lua.new_usertype<
graphics::RenderData>(
"RenderData", sol::constructors<graphics::RenderData()>());
112 auto transform_type = lua.new_usertype<
graphics::Transform>(
"Transform", sol::constructors<graphics::Transform()>());
137 auto font_type = lua.new_usertype<
graphics::Font>(
"Font", sol::constructors<graphics::Font()>());
141 font_type[
"load_mem"] = sol::resolve<bool(unsigned char*, const unsigned int)>(&
graphics::Font::load);
147 auto text_type = lua.new_usertype<
graphics::Text>(
"Text", sol::constructors<graphics::Font()>());
157 text_type[
"update_alignment"] = sol::resolve<void(const graphics::Text::Alignment)>(&
graphics::Text::update);
161 auto circle_type = lua.new_usertype<
graphics::Circle>(
"Circle", sol::constructors<graphics::Circle()>());
170 auto ellipse_type = lua.new_usertype<
graphics::Ellipse>(
"Ellipse", sol::constructors<graphics::Ellipse()>());
179 auto point_type = lua.new_usertype<
graphics::Point>(
"Point", sol::constructors<graphics::Point()>());
187 auto polygon_type = lua.new_usertype<
graphics::Polygon>(
"Polygon", sol::constructors<graphics::Polygon()>());
195 auto polyline_type = lua.new_usertype<
graphics::Polyline>(
"Polyline", sol::constructors<graphics::Polyline()>());
2D animation information.
double m_speed
Speed of the animation. Multiplier, so 1.0f is regular speed.
void prev()
Go back to the previous frame.
bool load(const std::string &file)
Load a json file from VFS and set frames from that.
std::size_t index() const
Get current frame index.
meta::vector< Frame > & frames()
Get the frames.
std::string m_name
Animation name.
std::size_t total() const
Get total frames.
void restart()
Sets animation back to beginning.
void next()
Advance to the next frame.
Frame & current()
Get currently active frame.
const glm::mat4 & get_proj()
Get the Camera projection.
void set_viewport(const float width, const float height)
Set Viewport.
const glm::vec2 & get_viewport() const
Get camera viewport.
float m_translation_speed
Movement speed.
void translate(const float x, const float y) override
Translate (move) position.
Data & get_data()
Get camera view and proj.
void rotate(const float degrees) override
Rotate entity.
bool m_allow_rotation
Allow camera to rotate.
const glm::mat4 & get_model_view()
Retrieve internal transformation matrix.
float m_rotation_speed
Rotational speed.
float radius() const
Get radius.
float fragments() const
Get fragments.
void create(const float fragments, const float radius)
Create the circle.
Represents an RGBA colour.
void set_g(const std::uint8_t g)
Green.
static const constexpr std::uint8_t OPAQUE
Opaque colour.
void set_r(const std::uint8_t r)
Red.
void set_rgba(const glm::vec4 &rgba)
Set RGBA.
void set_b(const std::uint8_t b)
Blue.
void set_a(const std::uint8_t a)
Alpha.
static const constexpr std::uint8_t TRANSPARENT
Transparent colour.
float fragments() const
Get fragments.
const glm::vec2 & radii() const
Get radii.
void create(const float fragments, const glm::vec2 &radii)
Create the ellipse.
MSDF OpenGL configuration.
void set_dpi(const float x, const float y) const
Set font DPI.
A font is a MSDF atlas of glyphs.
void build()
Build the font atlas.
bool load(const std::string &file)
Loads the font and sets up characters.
glm::vec2 get_text_size(const std::string &text, const float size)
Query text size with font.
float vertical_advance(const float size) const
Get vertical advance for drawing multiline text.
void create(const glm::vec2 &pos)
Initial point positon.
const glm::vec2 & pos() const
Get pos.
A closed loop line collection of points. I.e. A square, triangle, etc.
void create(const meta::vector< glm::vec2 > &points)
Create shape.
const meta::vector< glm::vec2 > & points() const
Get list of points.
An open looped line of points.
void create(const meta::vector< glm::vec2 > &points)
List of points to create a line from.
const meta::vector< glm::vec2 > & points() const
Get list of points.
Colour m_colour
Used by all primitives.
float height() const
Get texture height.
unsigned int mode() const
Get OpenGL rendering mode.
float width() const
Get texture width.
String of glyphs rendered with a font.
const std::string & get_font() const
Get font ID.
const std::string & get_text() const
Get text.
Alignment get_alignment() const
Get the text alignment.
void create(std::string_view text, const float size, const std::string &font, const graphics::Colour &colour, Alignment alignment=Alignment::LEFT)
Creates the rendered text.
void set_font(std::string_view font)
Update the font used.
graphics::Colour m_colour
Text colour.
float height() const
Get text height.
void update()
Update the rendered text.
float get_size() const
Get text em size.
float width() const
Get text width.
glm::mat4 m_model_view
Combined transformation matrix.
glm::mat4 m_projection
Camera projection matrix.
Single frame of an animation.
math::fRect m_bounds
Texture bounds.
double m_duration
Time to spend on this frame in milliseconds.
Data to be passed to the renderer.
unsigned int mode
Type to render i.e. GL_LINES, GL_TRIANGLES, etc.
unsigned int vao
OpenGL vertex array object.
unsigned int count
OpenGL index (element) buffer count.
void * offset
Offset in vertex buffer marking beginning of element data.
unsigned int texture
Texture.
int instances
Number of instances to render.
int layer
Layer to render on.
RenderData uniforms
Shader uniform data.
Uniform data passed to shader from entity.
glm::mat4 transform
Orthographic transform.
bool textured
Are we rendering as a texture.
glm::vec4 colour
Colour / tint.
bool point
Is this being rendered with GL_POINTS.