8#include <entt/locator/locator.hpp>
37 auto& lua = entt::locator<sol::state>::value();
99 auto sampler_type = lua.new_usertype<
Sampler>(
"Sampler", sol::constructors<Colour()>());
106 auto shader_type = lua.new_usertype<
Shader>(
"Shader", sol::constructors<Shader()>());
111 shader_type[
"load"] = sol::resolve<bool(const std::string&, const std::string&)>(&
Shader::load);
112 shader_type[
"load_combined"] = sol::resolve<bool(const std::string&)>(&
Shader::load);
113 shader_type[
"parse"] = sol::resolve<bool(const std::string&, const std::string&)>(&
Shader::parse);
114 shader_type[
"parse_combined"] = sol::resolve<bool(const std::string&)>(&
Shader::parse);
121 shader_type[
"set_uniform_mat4"] = &Shader::set_uniform<glm::mat4>;
122 shader_type[
"set_uniform_vec2"] = &Shader::set_uniform<glm::vec2>;
123 shader_type[
"set_uniform_vec3"] = &Shader::set_uniform<glm::vec3>;
124 shader_type[
"set_uniform_vec4"] = &Shader::set_uniform<glm::vec4>;
127 auto shaderbuffer_type = lua.new_usertype<
ShaderBuffer>(
"ShaderBuffer", sol::constructors<ShaderBuffer(), ShaderBuffer(const GLBufferBinding)>());
137 auto texture_type = lua.new_usertype<
Texture>(
"Texture", sol::constructors<Texture()>());
150 auto textureview_type = lua.new_usertype<
TextureView>(
152 sol::constructors<TextureView(const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int)>()
156 auto vertex_type = lua.new_usertype<
Vertex>(
"Vertex", sol::constructors<Vertex()>());
168 auto vertexbuffer_type = lua.new_usertype<
VertexBuffer>(
"VertexBuffer", sol::constructors<VertexBuffer()>());
180 auto vertexarray_type = lua.new_usertype<
VertexArray>(
"VertexArray", sol::constructors<VertexArray()>());
195 auto cameradata_type = lua.new_usertype<
Camera::Data>(
"CameraData", sol::no_constructor);
199 auto camera_type = lua.new_usertype<
Camera>(
"Camera", sol::constructors<Camera()>());
227 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)>());
231 colour_type[
"set_r"] = sol::resolve<void(const std::uint8_t)>(&
Colour::r);
232 colour_type[
"set_g"] = sol::resolve<void(const std::uint8_t)>(&
Colour::g);
233 colour_type[
"set_b"] = sol::resolve<void(const std::uint8_t)>(&
Colour::b);
234 colour_type[
"set_a"] = sol::resolve<void(const std::uint8_t)>(&
Colour::a);
235 colour_type[
"get_r"] = sol::resolve<std::uint8_t() const>(&
Colour::r);
236 colour_type[
"get_g"] = sol::resolve<std::uint8_t() const>(&
Colour::g);
237 colour_type[
"get_b"] = sol::resolve<std::uint8_t() const>(&
Colour::b);
238 colour_type[
"get_a"] = sol::resolve<std::uint8_t() const>(&
Colour::a);
245 auto rendercmd_type = lua.new_usertype<
RenderCmd>(
"RenderCmd", sol::constructors<RenderCmd()>());
251 auto renderdata_type = lua.new_usertype<
RenderData>(
"RenderData", sol::constructors<RenderData()>());
258 auto renderer_type = lua.new_usertype<
Renderer>(
"Renderer", sol::no_constructor);
267 auto renderpipe_type = lua.new_usertype<
RenderPipeline>(
"RenderPipeline", sol::constructors<RenderPipeline()>());
276 auto vertexbatch_type = lua.new_usertype<
VertexBatch>(
"VertexBatch", sol::constructors<
VertexBatch(
const int,
const int,
const std::vector<unsigned int>&)>());
void set_positon(const float x, const float y) noexcept
Set postion of camera.
void move(const float x, const float y) noexcept
Move position.
void set_scale_vertical(const float y) noexcept
Set entity scale.
void scale(const float scale) noexcept
Set entity scale.
void reset() noexcept
Reset transform.
void move_x(const float x) noexcept
Move on x axis.
bool m_allow_rotation
Allow camera to rotate.
float m_translation_speed
Movement speed.
const glm::mat4 & get_model_view() noexcept
Retrieve internal transformation matrix.
void set_positon_vertical(const float y) noexcept
Set postion of camera.
void set_rotation(const float degrees) noexcept
Set camera rotation.
glm::mat4 & get_transform() noexcept
Retrieve internal transformation matrix.
void set_origin(const float x, const float y) noexcept
Set the origin point.
void move_y(const float y) noexcept
Move on y axis.
const glm::vec2 & get_scale() const noexcept
Get stored scale.
const glm::vec2 & get_pos() const noexcept
Get stored position.
void rotate(const float degrees) noexcept
Rotate entity.
void set_positon_horizontal(const float x) noexcept
Set postion of camera.
const glm::mat4 & get_proj() noexcept
Get the Camera projection.
float get_rotation() const noexcept
Get stored rotation.
Data & get_data() noexcept
Get camera view and proj.
float m_rotation_speed
Rotational speed.
const glm::vec2 & get_origin() const noexcept
Get origin point.
void set_scale_horizontal(const float x) noexcept
Set entity scale.
void set_projection(const float left, const float right, const float bottom, const float top) noexcept
Set camera projection.
Represents an RGBA colour.
std::array< std::uint8_t, 4 > array() noexcept
Get as array.
std::uint8_t a() const noexcept
Get alpha.
static const constexpr std::uint8_t TRANSPARENT
Transparent colour.
static const constexpr std::uint8_t UPPER
Colour upper bounds.
glm::vec4 normalize() noexcept
Get normalized rgba vec4.
static const constexpr std::uint8_t OPAQUE
Opaque colour.
void set_from_norm(const glm::vec4 &rgba) noexcept
Set RGBA from normalizaed values.
static const constexpr std::uint8_t LOWER
Colour lower bounds.
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 const constexpr std::uint8_t OFFSET
Colour offsets for normalization.
static void inject_graphics() noexcept
Injects graphics module into Lua.
void end_pass(Camera &camera)
void push_cmd(RenderCmd &&cmd)
Try not to push too many non-quads, only quads are batched.
void bind_pipeline(RenderPipeline &pipeline)
void begin_pass(RenderPass &pass)
void prepare()
Called only in the update loop when we need to refresh data to render.
Texture sampler definitions.
void set(const unsigned int param, const int value) const
Set a sampler field.
unsigned int id() const noexcept
Get program id.
void bind(const unsigned int texture_unit) const
Bind sampler.
void setf(const unsigned int param, const float value) const
Set a float sampler field.
void unbind(const unsigned int texture_unit) const
Unbind sampler.
OpenGL Shader storage buffer.
void bind() const
Bind buffer.
void clear() const
Clears data from buffer.
void unbind() const
Unbind buffer.
unsigned int id() const noexcept
Get OpenGL handle.
void set_index(const GLBufferBinding index)
Set vertex shader binding point.
void destroy()
Destroy shader.
unsigned int id() const noexcept
Get program id.
void compile()
Compiles shader into GPU mem.
void unbind() const
Unbind.
void set_uniform(const std::string &name, const Uniforms &... args)
Specialized variadic template for setting shader uniforms.
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.
unsigned int id() const noexcept
Get OpenGL texture id.
Bindless OpenGL 2D Texture.
void unbind() const noexcept
Unbind 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.
TextureView get_view(const unsigned int minlevel, const unsigned int numlevels, const unsigned int minlayer, const unsigned int numlayers) const noexcept
Generate a texture view handle.
std::uint64_t handle() const noexcept
Get OpenGL bindless handle.
float width() const noexcept
Get texture width.
Abstraction for OpenGL vertex array objects.
void bind() const
Bind this vertex array.
VertexBuffer & vbo() noexcept
Get vertex buffer.
void buffer(std::span< Vertex > vertices, std::span< unsigned int > indices)
Create vertex buffer.
void sub_buffer(const unsigned int vi, const int vertex_size, const std::span< Vertex > vertices, const unsigned int ei, const int index_size, std::span< unsigned int > indices)
Sub-buffer vertex buffer.
int count() const noexcept
Get the index count.
void sub_buffer_indices(const unsigned int ei, const int index_size, std::span< unsigned int > indices) const
Sub-buffer element/index buffer.
void erase(const unsigned int vi, const int vertex_count, const unsigned int ei, const int index_count)
Erase a specfic segment of data.
void unbind() const
Unbind this vertex array.
unsigned int id() const noexcept
Get vertex array handle.
void * offset() noexcept
Gets index offset.
void clear()
Clear buffer data.
void reserve(const int vertex_count, const int index_count)
Create vertex buffer without uploading.
void sub_buffer_vertices(const unsigned int vi, const int vertex_size, const std::span< Vertex > vertices) const
Sub-buffer vertex buffer.
A group of vertices for multiple renderables batched together.
void bind() const noexcept
Bind this batchs vertex array object.
void push(const std::vector< Vertex > &vertices) noexcept
Add vertex and index data to batch.
void flush() noexcept
Copy all data to GPU.
int count() const noexcept
Get the index count.
void prepare() noexcept
Sets up counters to begin pushing vertices.
void * offset() noexcept
Gets index offset.
VertexArray & vao() noexcept
Gets internal VAO.
Abstraction for OpenGL vertex buffer objects.
void buffer(std::span< Vertex > vertices, std::span< unsigned int > indices)
Create vertex buffer.
int count() const noexcept
Get the index count.
void sub_buffer_indices(const unsigned int ei, const int index_size, std::span< unsigned int > indices) const
Sub-buffer element/index buffer.
void sub_buffer_vertices(const unsigned int vi, const int vertex_size, const std::span< Vertex > vertices) const
Sub-buffer vertex buffer.
void sub_buffer(const unsigned int vi, const int vertex_size, const std::span< Vertex > vertices, const unsigned int ei, const int index_size, std::span< unsigned int > indices) const
Sub-buffer vertex buffer.
void clear() const
Clear buffer data.
void erase(const unsigned int vi, const int vertex_count, const unsigned int ei, const int index_count) const
Erase a specfic segment of data.
void * offset() noexcept
Gets index offset.
void reserve(const int vertex_count, const int index_count)
Create vertex buffer without uploading.
unsigned int id() const noexcept
Get OpenGL handle.
std::vector< Vertex > gen_quad_vertices(const float width, const float height, float depth) noexcept
Generate some default verticies.
std::vector< unsigned int > gen_default_indices() noexcept
Generate some default indices.
float map_y_texel(const Type y, const float height) noexcept
Takes in a y positon texture coord and maps it to a texel.
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.
@ INDEX_POINT
Renderable uniform data index.
@ POSITION_POINT
Position data.
GLTextureFilter
Mipmap filtering.
@ NEAREST
Nearest-neighbour.
GLRenderMode
Rendering modes.
GLDrawHint
OpenGL driver data buffer storage flags.
GLTextureMode
Texture wrapping modes.
@ CLAMP_TO_EDGE
GL_CLAMP_TO_EDGE.
@ MIRRORED_REPEAT
GL_MIRRORED_REPEAT.
@ CLAMP_TO_BORDER
GL_CLAMP_TO_BORDER.
GLBufferBinding
Binding point for GPU buffers.
@ UNIFORMS
Shader uniforms.
@ TEXTURE_HANDLES
Bindless texture handle array.
@ CAMERA
Camera transform data.
GLBufferLocation
Stores the location of a buffer's location point for the VAO.
@ VERTEX_BUFFER_POINT
Normal VBO.
glm::mat4 m_projection
Camera projection matrix.
glm::mat4 m_model_view
Combined transformation matrix.
Data required to draw an object.
std::vector< Vertex > vertices
Vertices if type is quad for batch rendering.
RenderData data
Uniform data for this command.
VertexArray * vao
Vertex array object if type is not quad. Not used by batch renderer.
GLRenderMode type
OpenGL rendering mode/type. Required.
Uniform data passed to shader about an entity.
std::uint64_t handle
Texture handle.
glm::mat4 transform
Orthographic transform.
glm::vec4 colour
Colour / tint.
bool point
Is this being rendered with GL_POINTS.
unsigned int blend_equation
glBlendEquation.
unsigned int cull_face
glCullFace.
std::vector< unsigned int > enabled
glEnable features.
unsigned int blend_function
glBlendFunc for GL_SRC_ALPHA.
unsigned int depth_func
glDepthFunc.
std::vector< unsigned int > disabled
glDisable features.
unsigned int shader
Pipeline Ubershader.
Represents a single vertex point.
glm::vec2 m_texels
Texture coords (uv).
unsigned int m_index
Uniform data index.