summaryrefslogtreecommitdiff
path: root/src/systems/grid.c
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-31 10:19:38 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-31 10:19:38 +1000
commit0a60692230841cbcbbf67acba55d2dbb4730b6cb (patch)
tree1f53fb5144310e6972aa3448c3b68c57e922cb70 /src/systems/grid.c
parent547268b5a9cacc514445a59cc482897fd2f201ee (diff)
add empty grid system
Diffstat (limited to 'src/systems/grid.c')
-rw-r--r--src/systems/grid.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/systems/grid.c b/src/systems/grid.c
new file mode 100644
index 0000000..20e3657
--- /dev/null
+++ b/src/systems/grid.c
@@ -0,0 +1,59 @@
+#include "grid.h"
+#include "file.h"
+#include "log.h"
+#include "maths_types.h"
+#include "primitives.h"
+#include "ral_common.h"
+#include "ral_impl.h"
+#include "ral_types.h"
+#include "render.h"
+#include "render_types.h"
+#include "shader_layouts.h"
+
+void Grid_Init(Grid_Storage* storage) {
+ INFO("Infinite Grid initialisation");
+ Geometry plane_geo = Geo_CreatePlane(f32x2(1.0, 1.0));
+ Mesh plane_mesh = Mesh_Create(&plane_geo, true);
+ storage->plane_vertices = plane_mesh.vertex_buffer;
+ storage->plane_indices = plane_mesh.index_buffer;
+
+ GPU_RenderpassDesc rpass_desc = {
+ .default_framebuffer = true,
+ };
+ storage->renderpass = GPU_Renderpass_Create(rpass_desc);
+
+ arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024);
+
+ Str8 vert_path = str8("assets/shaders/grid.vert");
+ Str8 frag_path = str8("assets/shaders/grid.frag");
+ str8_opt vertex_shader = str8_from_file(&scratch, vert_path);
+ str8_opt fragment_shader = str8_from_file(&scratch, frag_path);
+ if (!vertex_shader.has_value || !fragment_shader.has_value) {
+ ERROR_EXIT("Failed to load shaders from disk")
+ }
+
+ ShaderData camera_data = { .get_layout = &Binding_Camera_GetLayout };
+
+ GraphicsPipelineDesc pipeline_desc = {
+ .debug_name = "Infinite grid pipeline",
+ .vertex_desc = static_3d_vertex_description(),
+ .data_layouts = { camera_data },
+ .data_layouts_count = 1,
+ .vs = {
+ .debug_name = "Grid vertex shader",
+ .filepath = vert_path,
+ .code = vertex_shader.contents,
+ },
+ .fs = {
+ .debug_name = "Grid fragment shader",
+ .filepath = frag_path,
+ .code = fragment_shader.contents,
+ },
+ .wireframe = false,
+ };
+ storage->pipeline = GPU_GraphicsPipeline_Create(pipeline_desc, storage->renderpass);
+}
+
+void Grid_Draw(Grid_Storage* storage) {
+
+} \ No newline at end of file