8#include <entt/locator/locator.hpp>
28 auto& lua = entt::locator<sol::state>::value();
72 lua.new_usertype<
Colour>(
"Colour", sol::constructors<Colour(), Colour(const std::uint8_t, const std::uint8_t, const std::uint8_t, const std::uint8_t)>());
78 colour_type[
"set_r"] = sol::resolve<void(const std::uint8_t)>(&
Colour::r);
79 colour_type[
"set_g"] = sol::resolve<void(const std::uint8_t)>(&
Colour::g);
80 colour_type[
"set_b"] = sol::resolve<void(const std::uint8_t)>(&
Colour::b);
81 colour_type[
"set_a"] = sol::resolve<void(const std::uint8_t)>(&
Colour::a);
82 colour_type[
"get_r"] = sol::resolve<std::uint8_t() const>(&
Colour::r);
83 colour_type[
"get_g"] = sol::resolve<std::uint8_t() const>(&
Colour::g);
84 colour_type[
"get_b"] = sol::resolve<std::uint8_t() const>(&
Colour::b);
85 colour_type[
"get_a"] = sol::resolve<std::uint8_t() const>(&
Colour::a);
87 auto shader_type = lua.new_usertype<
Shader>(
"Shader", sol::constructors<Shader()>());
92 shader_type[
"load"] = sol::resolve<bool(const std::string&, const std::string&)>(&
Shader::load);
93 shader_type[
"load_combined"] = sol::resolve<bool(const std::string&)>(&
Shader::load);
94 shader_type[
"parse"] = sol::resolve<bool(const std::string&, const std::string&)>(&
Shader::parse);
95 shader_type[
"parse_combined"] = sol::resolve<bool(const std::string&)>(&
Shader::parse);
98 auto vertex_type = lua.new_usertype<
Vertex>(
"Vertex", sol::constructors<Vertex()>());
102 auto vertexbuffer_type = lua.new_usertype<
VertexBuffer>(
"VertexBuffer", sol::constructors<VertexBuffer()>());
103 vertexbuffer_type[
"buffer"] = sol::resolve<void(std::span<Vertex>, std::span<unsigned int>)>(&
VertexBuffer::buffer);
104 vertexbuffer_type[
"buffer_no_upload"] = sol::resolve<void(
const int, std::span<unsigned int>)>(&
VertexBuffer::buffer);
111 auto vertexarray_type = lua.new_usertype<
VertexArray>(
"VertexArray", sol::constructors<VertexArray()>());
113 vertexarray_type[
"buffer"] = sol::resolve<void(std::span<Vertex>, std::span<unsigned int>)>(&
VertexArray::buffer);
114 vertexarray_type[
"buffer_no_upload"] = sol::resolve<void(
const int, std::span<unsigned int>)>(&
VertexArray::buffer);
122 auto texture_type = lua.new_usertype<
Texture>(
"Texture", sol::constructors<Texture()>());
135 auto ssbo_type = lua.new_usertype<
ShaderStorageBuffer>(
"ShaderStorageBuffer", sol::constructors<ShaderStorageBuffer(const int)>());
Represents an RGBA colour.
std::array< std::uint8_t, 4 > array() noexcept
Get as array.
std::uint8_t a() const noexcept
Get alpha.
glm::vec4 normalize() noexcept
Get normalized rgba vec4.
void set_from_norm(const glm::vec4 &rgba) noexcept
Set RGBA from normalizaed values.
std::uint8_t b() const noexcept
Get blue.
std::uint8_t r() const noexcept
Get red.
std::uint8_t g() const noexcept
Get green.
static void inject_graphics() noexcept
Injects graphics module into Lua.
void bind() const
Bind buffer.
void destroy()
Destroy shader.
void clear() const
Clears data from buffer.
void unbind() const
Unbind buffer.
unsigned int id() const noexcept
Get OpenGL handle.
unsigned int id() const noexcept
Get program id.
void compile()
Compiles shader into GPU mem.
void unbind() const
Unbind.
bool parse(const std::string &src) noexcept
Loads a combined raw shader.
bool load(const std::string &file) noexcept
Loads a combined shader.
void bind() const
Make active shader.
void destroy()
Destroys shader program.
Bindless OpenGL 2D Texture.
void unbind() const noexcept
Deactivate sampler.
bool load(const std::string &file)
Load a texture from vfs.
bool load_mem(std::span< std::uint8_t > buffer)
Loads texture from memory.
void save(std::string_view file)
Saves texture to file on disk.
void bind() const noexcept
Bind to sampler.
void destroy()
Destroy texture.
float height() const noexcept
Get texture height.
unsigned int id() const noexcept
Get OpenGL texture id.
void recreate()
Deletes texture data and configuration in OpenGL.
std::uint64_t handle() const noexcept
Get OpenGL bindless handle.
float width() const noexcept
Get texture width.
Abstraction for OpenGL vertex array objects.
void sub_buffer(const unsigned int index, std::span< Vertex > vertices)
Sub-buffer vertex array.
void bind() const
Bind this vertex array.
VertexBuffer & vbo() noexcept
Get vertex buffer.
int count() const noexcept
Get the index count.
void buffer(std::span< Vertex > vertices, std::span< unsigned int > indicies)
Create vertex array object.
void unbind() const
Unbind this vertex array.
unsigned int id() const noexcept
Get vertex array handle.
void * offset() noexcept
Gets index offset.
Abstraction for OpenGL vertex buffer objects.
void buffer(std::span< Vertex > vertices, std::span< unsigned int > indicies)
Create vertex buffer object.
int count() const noexcept
Get the index count.
void * offset() noexcept
Gets index offset.
void clear()
Clear buffer data.
void sub_buffer(const unsigned int index, std::span< Vertex > vertices)
Sub-buffer vertex object.
unsigned int id() const noexcept
Get OpenGL handle.
float map_y_texel(const Type y, const float height) noexcept
Takes in a y positon texture coord and maps it to a texel.
std::array< Vertex, 4 > gen_quad_vertices(const float width, const float height) noexcept
Generate some default verticies.
std::array< unsigned int, 6 > gen_default_indices() noexcept
Generate some default indicies.
float map_x_texel(const Type x, const float width) noexcept
Takes in a x positon texture coord and maps it to a texel.
GLAttributeBinding
Stores the location of shader attribute binding point for the VAO.
@ OFFSET_POINT
Instance offset data.
@ POSITION_POINT
Position data.
GLTextureFilter
Mipmap filtering.
@ NEAREST
Nearest-neighbour.
GLDrawHint
OpenGL driver data buffer storage flags.
GLBufferBinding
Stores the location of a buffer's binding point for the VAO.
@ INSTANCE_BUFFER_POINT
Instance offsets.
@ VERTEX_BUFFER_POINT
Normal VBO.
GLTextureMode
Texture wrapping modes.
@ CLAMP_TO_EDGE
GL_CLAMP_TO_EDGE.
@ MIRRORED_REPEAT
GL_MIRRORED_REPEAT.
@ CLAMP_TO_BORDER
GL_CLAMP_TO_BORDER.
Represents a single vertex point.
glm::vec2 m_texels
Texture coords (uv).