galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
LuaGraphics.cpp
Go to the documentation of this file.
1
7
8#include <entt/locator/locator.hpp>
9#include <sol/sol.hpp>
10
20
30
31#include "../Lua.hpp"
32
33namespace galaxy
34{
35 void Lua::inject_graphics() noexcept
36 {
37 auto& lua = entt::locator<sol::state>::value();
38
39 // clang-format off
40 lua.new_enum<GLDrawHint>(
41 "GLDrawHint",
42 {
43 {"STATIC_DRAW", GLDrawHint::STATIC_DRAW},
44 {"DYNAMIC_DRAW", GLDrawHint::DYNAMIC_DRAW},
45 {"STREAM_DRAW", GLDrawHint::STREAM_DRAW}
46 }
47 );
48 lua.new_enum<GLTextureMode>(
49 "GLTextureMode",
50 {
51 {"REPEAT", GLTextureMode::REPEAT},
52 {"MIRRORED_REPEAT", GLTextureMode::MIRRORED_REPEAT},
53 {"CLAMP_TO_EDGE", GLTextureMode::CLAMP_TO_EDGE},
54 {"CLAMP_TO_BORDER", GLTextureMode::CLAMP_TO_BORDER}
55 }
56 );
57 lua.new_enum<GLRenderMode>(
58 "GLRenderMode",
59 {
60 {"QUADS", GLRenderMode::QUADS},
61 {"TRIANGLES", GLRenderMode::TRIANGLES},
62 {"LINES", GLRenderMode::LINES},
63 {"LINE_LOOP", GLRenderMode::LINE_LOOP},
64 {"POINTS", GLRenderMode::POINTS}
65 }
66 );
67 lua.new_enum<GLAttributeBinding>(
68 "GLAttributeBinding",
69 {
70 {"POSITION_POINT", GLAttributeBinding::POSITION_POINT},
71 {"TEXEL_POINT", GLAttributeBinding::TEXEL_POINT},
72 {"INDEX_POINT", GLAttributeBinding::INDEX_POINT}
73 }
74 );
75 lua.new_enum<GLBufferLocation>(
76 "GLBufferLocation",
77 {
78 {"VERTEX_BUFFER_POINT", GLBufferLocation::VERTEX_BUFFER_POINT}
79 }
80 );
81 lua.new_enum<GLBufferBinding>(
82 "GLBufferBinding",
83 {
84 {"TEXTURE_HANDLES", GLBufferBinding::TEXTURE_HANDLES},
85 {"CAMERA", GLBufferBinding::CAMERA},
86 {"UNIFORMS", GLBufferBinding::UNIFORMS}
87 }
88 );
89 lua.new_enum<GLTextureFilter>(
90 "GLTextureFilter",
91 {
92 {"NEAREST", GLTextureFilter::NEAREST},
93 {"BILINEAR", GLTextureFilter::BILINEAR},
94 {"TRILINEAR", GLTextureFilter::TRILINEAR}
95 }
96 );
97 // clang-format on
98
99 auto sampler_type = lua.new_usertype<Sampler>("Sampler", sol::constructors<Colour()>());
100 sampler_type["set"] = &Sampler::set;
101 sampler_type["setf"] = &Sampler::setf;
102 sampler_type["bind"] = &Sampler::bind;
103 sampler_type["unbind"] = &Sampler::unbind;
104 sampler_type["id"] = &Sampler::id;
105
106 auto shader_type = lua.new_usertype<Shader>("Shader", sol::constructors<Shader()>());
107 shader_type["bind"] = &Shader::bind;
108 shader_type["compile"] = &Shader::compile;
109 shader_type["destroy"] = &Shader::destroy;
110 shader_type["id"] = &Shader::id;
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);
115 shader_type["unbind"] = &Shader::unbind;
116 shader_type["set_uniform_bool"] = &Shader::set_uniform<bool>;
117 shader_type["set_uniform_int"] = &Shader::set_uniform<int>;
118 shader_type["set_uniform_uint"] = &Shader::set_uniform<unsigned int>;
119 shader_type["set_uniform_float"] = &Shader::set_uniform<float>;
120 shader_type["set_uniform_double"] = &Shader::set_uniform<double>;
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>;
125 shader_type["set_uniform_colour"] = &Shader::set_uniform<Colour>;
126
127 auto shaderbuffer_type = lua.new_usertype<ShaderBuffer>("ShaderBuffer", sol::constructors<ShaderBuffer(), ShaderBuffer(const GLBufferBinding)>());
128 shaderbuffer_type["bind"] = &ShaderBuffer::bind;
129 shaderbuffer_type["clear"] = &ShaderBuffer::clear;
130 shaderbuffer_type["destroy"] = &ShaderBuffer::destroy;
131 shaderbuffer_type["id"] = &ShaderBuffer::id;
132 shaderbuffer_type["set_index"] = &ShaderBuffer::set_index;
133 shaderbuffer_type["unbind"] = &ShaderBuffer::unbind;
134 // shaderbuffer_type[""] = &ShaderBuffer::buffer;
135 // shaderbuffer_type[""] = &ShaderBuffer::sub_buffer;
136
137 auto texture_type = lua.new_usertype<Texture>("Texture", sol::constructors<Texture()>());
138 texture_type["bind"] = &Texture::bind;
139 texture_type["destroy"] = &Texture::destroy;
140 texture_type["handle"] = &Texture::handle;
141 texture_type["height"] = &Texture::height;
142 texture_type["id"] = &Texture::id;
143 texture_type["load"] = &Texture::load;
144 texture_type["load_mem"] = &Texture::load_mem;
145 texture_type["save"] = &Texture::save;
146 texture_type["unbind"] = &Texture::unbind;
147 texture_type["width"] = &Texture::width;
148 texture_type["get_view"] = &Texture::get_view;
149
150 auto textureview_type = lua.new_usertype<TextureView>(
151 "TextureView",
152 sol::constructors<TextureView(const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int)>()
153 );
154 textureview_type["id"] = &TextureView::id;
155
156 auto vertex_type = lua.new_usertype<Vertex>("Vertex", sol::constructors<Vertex()>());
157 vertex_type["pos"] = &Vertex::m_pos;
158 vertex_type["texels"] = &Vertex::m_texels;
159 vertex_type["index"] = &Vertex::m_index;
160
161 lua.set_function("gen_quad_vertices", &graphics::gen_quad_vertices);
162 lua.set_function("gen_default_indices", &graphics::gen_default_indices);
163 lua.set_function("map_x_texel", &graphics::map_x_texel<int>);
164 lua.set_function("map_y_texel", &graphics::map_y_texel<int>);
165 lua.set_function("map_x_texelf", &graphics::map_x_texel<float>);
166 lua.set_function("map_y_texelf", &graphics::map_y_texel<float>);
167
168 auto vertexbuffer_type = lua.new_usertype<VertexBuffer>("VertexBuffer", sol::constructors<VertexBuffer()>());
169 vertexbuffer_type["clear"] = &VertexBuffer::clear;
170 vertexbuffer_type["count"] = &VertexBuffer::count;
171 vertexbuffer_type["id"] = &VertexBuffer::id;
172 vertexbuffer_type["offset"] = &VertexBuffer::offset;
173 vertexbuffer_type["sub_buffer"] = &VertexBuffer::sub_buffer;
174 vertexbuffer_type["buffer"] = &VertexBuffer::buffer;
175 vertexbuffer_type["erase"] = &VertexBuffer::erase;
176 vertexbuffer_type["reserve"] = &VertexBuffer::reserve;
177 vertexbuffer_type["sub_buffer_indices"] = &VertexBuffer::sub_buffer_indices;
178 vertexbuffer_type["sub_buffer_vertices"] = &VertexBuffer::sub_buffer_vertices;
179
180 auto vertexarray_type = lua.new_usertype<VertexArray>("VertexArray", sol::constructors<VertexArray()>());
181 vertexarray_type["bind"] = &VertexArray::bind;
182 vertexarray_type["count"] = &VertexArray::count;
183 vertexarray_type["id"] = &VertexArray::id;
184 vertexarray_type["offset"] = &VertexArray::offset;
185 vertexarray_type["sub_buffer"] = &VertexArray::sub_buffer;
186 vertexarray_type["unbind"] = &VertexArray::unbind;
187 vertexarray_type["vbo"] = &VertexArray::vbo;
188 vertexarray_type["buffer"] = &VertexArray::buffer;
189 vertexarray_type["clear"] = &VertexArray::clear;
190 vertexarray_type["erase"] = &VertexArray::erase;
191 vertexarray_type["reserve"] = &VertexArray::reserve;
192 vertexarray_type["sub_buffer_indices"] = &VertexArray::sub_buffer_indices;
193 vertexarray_type["sub_buffer_vertices"] = &VertexArray::sub_buffer_vertices;
194
195 auto cameradata_type = lua.new_usertype<Camera::Data>("CameraData", sol::no_constructor);
196 cameradata_type["model_view"] = &Camera::Data::m_model_view;
197 cameradata_type["projection"] = &Camera::Data::m_projection;
198
199 auto camera_type = lua.new_usertype<Camera>("Camera", sol::constructors<Camera()>());
200 camera_type["get_data"] = &Camera::get_data;
201 camera_type["get_model_view"] = &Camera::get_model_view;
202 camera_type["get_origin"] = &Camera::get_origin;
203 camera_type["get_pos"] = &Camera::get_pos;
204 camera_type["get_proj"] = &Camera::get_proj;
205 camera_type["get_rotation"] = &Camera::get_rotation;
206 camera_type["get_scale"] = &Camera::get_scale;
207 camera_type["get_transform"] = &Camera::get_transform;
208 camera_type["rotation_speed"] = &Camera::m_rotation_speed;
209 camera_type["translation_speed"] = &Camera::m_translation_speed;
210 camera_type["allow_rotation"] = &Camera::m_allow_rotation;
211 camera_type["reset"] = &Camera::reset;
212 camera_type["rotate"] = &Camera::rotate;
213 camera_type["scale"] = &Camera::scale;
214 camera_type["set_rotation"] = &Camera::set_rotation;
215 camera_type["set_origin"] = &Camera::set_origin;
216 camera_type["set_scale_horizontal"] = &Camera::set_scale_horizontal;
217 camera_type["set_scale_vertical"] = &Camera::set_scale_vertical;
218 camera_type["move"] = &Camera::move;
219 camera_type["move_x"] = &Camera::move_x;
220 camera_type["move_y"] = &Camera::move_y;
221 camera_type["set_positon"] = &Camera::set_positon;
222 camera_type["set_positon_horizontal"] = &Camera::set_positon_horizontal;
223 camera_type["set_positon_vertical"] = &Camera::set_positon_vertical;
224 camera_type["set_projection"] = &Camera::set_projection;
225
226 auto colour_type =
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)>());
228 colour_type["array"] = &Colour::array;
229 colour_type["normalize"] = &Colour::normalize;
230 colour_type["set_from_norm"] = &Colour::set_from_norm;
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);
239 lua.set("GALAXY_COL_OPAQUE", Colour::OPAQUE);
240 lua.set("GALAXY_COL_TRANSPARENT", Colour::TRANSPARENT);
241 lua.set("GALAXY_COL_OFFSET", Colour::OFFSET);
242 lua.set("GALAXY_COL_LOWER", Colour::LOWER);
243 lua.set("GALAXY_COL_UPPER", Colour::UPPER);
244
245 auto rendercmd_type = lua.new_usertype<RenderCmd>("RenderCmd", sol::constructors<RenderCmd()>());
246 rendercmd_type["type"] = &RenderCmd::type;
247 rendercmd_type["vertices"] = &RenderCmd::vertices;
248 rendercmd_type["vao"] = &RenderCmd::vao;
249 rendercmd_type["data"] = &RenderCmd::data;
250
251 auto renderdata_type = lua.new_usertype<RenderData>("RenderData", sol::constructors<RenderData()>());
252 renderdata_type["transform"] = &RenderData::transform;
253 renderdata_type["colour"] = &RenderData::colour;
254 renderdata_type["entity"] = &RenderData::entity;
255 renderdata_type["point"] = &RenderData::point;
256 renderdata_type["handle"] = &RenderData::handle;
257
258 auto renderer_type = lua.new_usertype<Renderer>("Renderer", sol::no_constructor);
259 renderer_type["begin_pass"] = &Renderer::begin_pass;
260 renderer_type["bind_pipeline"] = &Renderer::bind_pipeline;
261 renderer_type["end_pass"] = &Renderer::end_pass;
262 renderer_type["prepare"] = &Renderer::prepare;
263 renderer_type["push_cmd"] = [](Renderer& renderer, RenderCmd& cmd) {
264 renderer.push_cmd(std::move(cmd));
265 };
266
267 auto renderpipe_type = lua.new_usertype<RenderPipeline>("RenderPipeline", sol::constructors<RenderPipeline()>());
268 renderpipe_type["enabled"] = &RenderPipeline::enabled;
269 renderpipe_type["disabled"] = &RenderPipeline::disabled;
270 renderpipe_type["blend_equation"] = &RenderPipeline::blend_equation;
271 renderpipe_type["blend_function"] = &RenderPipeline::blend_function;
272 renderpipe_type["cull_face"] = &RenderPipeline::cull_face;
273 renderpipe_type["depth_func"] = &RenderPipeline::depth_func;
274 renderpipe_type["shader"] = &RenderPipeline::shader;
275
276 auto vertexbatch_type = lua.new_usertype<VertexBatch>("VertexBatch", sol::constructors<VertexBatch(const int, const int, const std::vector<unsigned int>&)>());
277 vertexbatch_type["bind"] = &VertexBatch::bind;
278 vertexbatch_type["count"] = &VertexBatch::count;
279 vertexbatch_type["flush"] = &VertexBatch::flush;
280 vertexbatch_type["offset"] = &VertexBatch::offset;
281 vertexbatch_type["prepare"] = &VertexBatch::prepare;
282 vertexbatch_type["push"] = &VertexBatch::push;
283 vertexbatch_type["vao"] = &VertexBatch::vao;
284 }
285} // namespace galaxy
Orthographic 2D camera.
Definition Camera.hpp:20
void set_positon(const float x, const float y) noexcept
Set postion of camera.
Definition Camera.cpp:171
void move(const float x, const float y) noexcept
Move position.
Definition Camera.cpp:117
void set_scale_vertical(const float y) noexcept
Set entity scale.
Definition Camera.cpp:159
void scale(const float scale) noexcept
Set entity scale.
Definition Camera.cpp:145
void reset() noexcept
Reset transform.
Definition Camera.cpp:199
void move_x(const float x) noexcept
Move on x axis.
Definition Camera.cpp:125
bool m_allow_rotation
Allow camera to rotate.
Definition Camera.hpp:248
float m_translation_speed
Movement speed.
Definition Camera.hpp:253
const glm::mat4 & get_model_view() noexcept
Retrieve internal transformation matrix.
Definition Camera.cpp:235
void set_positon_vertical(const float y) noexcept
Set postion of camera.
Definition Camera.cpp:185
void set_rotation(const float degrees) noexcept
Set camera rotation.
Definition Camera.cpp:165
glm::mat4 & get_transform() noexcept
Retrieve internal transformation matrix.
Definition Camera.cpp:229
void set_origin(const float x, const float y) noexcept
Set the origin point.
Definition Camera.cpp:191
void move_y(const float y) noexcept
Move on y axis.
Definition Camera.cpp:131
const glm::vec2 & get_scale() const noexcept
Get stored scale.
Definition Camera.cpp:219
const glm::vec2 & get_pos() const noexcept
Get stored position.
Definition Camera.cpp:209
void rotate(const float degrees) noexcept
Rotate entity.
Definition Camera.cpp:137
void set_positon_horizontal(const float x) noexcept
Set postion of camera.
Definition Camera.cpp:179
const glm::mat4 & get_proj() noexcept
Get the Camera projection.
Definition Camera.cpp:241
float get_rotation() const noexcept
Get stored rotation.
Definition Camera.cpp:214
Data & get_data() noexcept
Get camera view and proj.
Definition Camera.cpp:246
float m_rotation_speed
Rotational speed.
Definition Camera.hpp:258
const glm::vec2 & get_origin() const noexcept
Get origin point.
Definition Camera.cpp:224
void set_scale_horizontal(const float x) noexcept
Set entity scale.
Definition Camera.cpp:153
void set_projection(const float left, const float right, const float bottom, const float top) noexcept
Set camera projection.
Definition Camera.cpp:106
Represents an RGBA colour.
Definition Colour.hpp:24
std::array< std::uint8_t, 4 > array() noexcept
Get as array.
Definition Colour.cpp:138
std::uint8_t a() const noexcept
Get alpha.
Definition Colour.cpp:113
static const constexpr std::uint8_t TRANSPARENT
Transparent colour.
Definition Colour.hpp:34
static const constexpr std::uint8_t UPPER
Colour upper bounds.
Definition Colour.hpp:49
glm::vec4 normalize() noexcept
Get normalized rgba vec4.
Definition Colour.cpp:126
static const constexpr std::uint8_t OPAQUE
Opaque colour.
Definition Colour.hpp:29
void set_from_norm(const glm::vec4 &rgba) noexcept
Set RGBA from normalizaed values.
Definition Colour.cpp:118
static const constexpr std::uint8_t LOWER
Colour lower bounds.
Definition Colour.hpp:44
std::uint8_t b() const noexcept
Get blue.
Definition Colour.cpp:108
std::uint8_t r() const noexcept
Get red.
Definition Colour.cpp:98
std::uint8_t g() const noexcept
Get green.
Definition Colour.cpp:103
static const constexpr std::uint8_t OFFSET
Colour offsets for normalization.
Definition Colour.hpp:39
static void inject_graphics() noexcept
Injects graphics module into Lua.
void end_pass(Camera &camera)
Definition Renderer.cpp:109
void push_cmd(RenderCmd &&cmd)
Try not to push too many non-quads, only quads are batched.
Definition Renderer.cpp:84
void bind_pipeline(RenderPipeline &pipeline)
Definition Renderer.cpp:59
void begin_pass(RenderPass &pass)
Definition Renderer.cpp:46
void prepare()
Called only in the update loop when we need to refresh data to render.
Definition Renderer.cpp:35
Texture sampler definitions.
Definition Sampler.hpp:17
void set(const unsigned int param, const int value) const
Set a sampler field.
Definition Sampler.cpp:52
unsigned int id() const noexcept
Get program id.
Definition Sampler.cpp:72
void bind(const unsigned int texture_unit) const
Bind sampler.
Definition Sampler.cpp:62
void setf(const unsigned int param, const float value) const
Set a float sampler field.
Definition Sampler.cpp:57
void unbind(const unsigned int texture_unit) const
Unbind sampler.
Definition Sampler.cpp:67
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.
OpenGL Shader Program.
Definition Shader.hpp:28
unsigned int id() const noexcept
Get program id.
Definition Shader.cpp:221
void compile()
Compiles shader into GPU mem.
Definition Shader.cpp:113
void unbind() const
Unbind.
Definition Shader.cpp:216
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.
Definition Shader.cpp:83
bool load(const std::string &file) noexcept
Loads a combined shader.
Definition Shader.cpp:65
void bind() const
Make active shader.
Definition Shader.cpp:211
void destroy()
Destroys shader program.
Definition Shader.cpp:202
OpenGL 2D TextureView.
unsigned int id() const noexcept
Get OpenGL texture id.
Bindless OpenGL 2D Texture.
Definition Texture.hpp:24
void unbind() const noexcept
Unbind sampler.
Definition Texture.cpp:169
bool load(const std::string &file)
Load a texture from vfs.
Definition Texture.cpp:74
bool load_mem(std::span< std::uint8_t > buffer)
Loads texture from memory.
Definition Texture.cpp:82
void save(std::string_view file)
Saves texture to file on disk.
Definition Texture.cpp:121
void bind() const noexcept
Bind to sampler.
Definition Texture.cpp:164
void destroy()
Destroy texture.
Definition Texture.cpp:174
float height() const noexcept
Get texture height.
Definition Texture.cpp:194
unsigned int id() const noexcept
Get OpenGL texture id.
Definition Texture.cpp:199
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.
Definition Texture.cpp:159
std::uint64_t handle() const noexcept
Get OpenGL bindless handle.
Definition Texture.cpp:204
float width() const noexcept
Get texture width.
Definition Texture.cpp:189
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.
Definition Vertex.cpp:16
std::vector< unsigned int > gen_default_indices() noexcept
Generate some default indices.
Definition Vertex.cpp:49
float map_y_texel(const Type y, const float height) noexcept
Takes in a y positon texture coord and maps it to a texel.
Definition Vertex.hpp:90
float map_x_texel(const Type x, const float width) noexcept
Takes in a x positon texture coord and maps it to a texel.
Definition Vertex.hpp:73
Animated.cpp galaxy.
Definition Animated.cpp:16
GLAttributeBinding
Stores the location of shader attribute binding point for the VAO.
Definition Enums.hpp:17
@ INDEX_POINT
Renderable uniform data index.
@ POSITION_POINT
Position data.
GLTextureFilter
Mipmap filtering.
Definition Enums.hpp:70
@ NEAREST
Nearest-neighbour.
GLRenderMode
Rendering modes.
Definition GLEnums.hpp:55
GLDrawHint
OpenGL driver data buffer storage flags.
Definition GLEnums.hpp:19
GLTextureMode
Texture wrapping modes.
Definition GLEnums.hpp:29
@ 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.
Definition Enums.hpp:49
@ 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.
Definition Enums.hpp:38
@ VERTEX_BUFFER_POINT
Normal VBO.
Camera data.
Definition Camera.hpp:26
glm::mat4 m_projection
Camera projection matrix.
Definition Camera.hpp:35
glm::mat4 m_model_view
Combined transformation matrix.
Definition Camera.hpp:30
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.
int entity
Entity ID.
bool point
Is this being rendered with GL_POINTS.
GPU configuration.
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.
Definition Vertex.hpp:24
glm::vec2 m_texels
Texture coords (uv).
Definition Vertex.hpp:33
unsigned int m_index
Uniform data index.
Definition Vertex.hpp:38
glm::vec3 m_pos
Position.
Definition Vertex.hpp:28