diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-05 12:48:05 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-05 12:48:05 +1000 |
commit | dfb6adbcbcc7d50b770b6d5ea82efdd8f8c32e25 (patch) | |
tree | a470b91a90716d7ea46fde53ed395449c24583a2 /src/systems/grid.c | |
parent | 54354e32c6498cc7f8839ab4deb1208d37216cc5 (diff) |
delete documentation workflow
Diffstat (limited to 'src/systems/grid.c')
-rw-r--r-- | src/systems/grid.c | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/systems/grid.c b/src/systems/grid.c deleted file mode 100644 index e907865..0000000 --- a/src/systems/grid.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "grid.h" -#include "file.h" -#include "log.h" -#include "maths.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), 1, 1); - Mesh plane_mesh = Mesh_Create(&plane_geo, true); - storage->plane_vertices = plane_mesh.vertex_buffer; - - u32 indices[6] = { 5, 4, 3, 2, 1, 0 }; - storage->plane_indices = - GPU_BufferCreate(6 * sizeof(u32), BUFFER_INDEX, BUFFER_FLAG_GPU, &indices); - - 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") - } - - ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL); - - 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* grid = Render_GetGridStorage(); - Grid_Execute(grid); -} - -void Grid_Execute(Grid_Storage* storage) { - RenderScene* scene = Render_GetScene(); - GPU_CmdEncoder* enc = GPU_GetDefaultEncoder(); - GPU_CmdEncoder_BeginRender(enc, storage->renderpass); - GPU_EncodeBindPipeline(enc, storage->pipeline); - Mat4 view, proj; - u32x2 dimensions = GPU_Swapchain_GetDimensions(); - Camera camera = scene->camera; - Camera_ViewProj(&camera, (f32)dimensions.x, (f32)dimensions.y, &view, &proj); - Binding_Camera camera_data = { .view = view, - .projection = proj, - .viewPos = vec4(camera.position.x, camera.position.y, - camera.position.z, 1.0) }; - GPU_EncodeBindShaderData(enc, 0, Binding_Camera_GetLayout(&camera_data)); - GPU_EncodeSetVertexBuffer(enc, storage->plane_vertices); - GPU_EncodeSetIndexBuffer(enc, storage->plane_indices); - GPU_EncodeDrawIndexedTris(enc, 6); - GPU_CmdEncoder_EndRender(enc); -} |