diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-31 12:38:12 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-31 12:38:12 +1000 |
commit | 8550c5d41ee84bcbf5e355c5adb6659166e3eb62 (patch) | |
tree | fd944fbb3a0f4a7c71a7d1d23e4289950e346f17 | |
parent | fa04ebc603a7bf742c64724ede23cfa010fb3c4c (diff) |
start on immediate drawing
-rw-r--r-- | bindgen/rust/src/ral.rs | 21 | ||||
-rw-r--r-- | examples/game_demo/game_demo.c | 2 | ||||
-rw-r--r-- | src/new_render/immdraw.c | 27 | ||||
-rw-r--r-- | src/new_render/immdraw.h | 6 | ||||
-rw-r--r-- | src/new_render/render.c | 12 |
5 files changed, 56 insertions, 12 deletions
diff --git a/bindgen/rust/src/ral.rs b/bindgen/rust/src/ral.rs index 2941275..6c196f8 100644 --- a/bindgen/rust/src/ral.rs +++ b/bindgen/rust/src/ral.rs @@ -3,7 +3,9 @@ use std::{os::raw::c_void, ptr}; use celeritas_sys::{ - BufferHandle, GPU_CmdEncoder, GPU_CmdEncoder_BeginRender, GPU_CmdEncoder_EndRender, GPU_GetDefaultEncoder, GPU_GetDefaultRenderpass, GPU_GraphicsPipeline_Create, GraphicsPipelineDesc, ShaderData + BufferHandle, GPU_CmdEncoder, GPU_CmdEncoder_BeginRender, GPU_CmdEncoder_EndRender, + GPU_GetDefaultEncoder, GPU_GetDefaultRenderpass, GPU_GraphicsPipeline_Create, + GraphicsPipelineDesc, ShaderData, }; /// Holds a pointer to the raw `GPU_CmdEncoder` @@ -50,7 +52,6 @@ impl FrameRenderEncoder { pub struct PipelineBuilder { renderpass: Option<RenderPass>, data_layouts: Vec<()>, - } impl PipelineBuilder { // pub fn add_ @@ -58,7 +59,7 @@ impl PipelineBuilder { pub fn build(self) -> Pipeline { let shad = ShaderData { get_layout: todo!(), - data: ptr::null_mut() + data: ptr::null_mut(), }; let desc = GraphicsPipelineDesc { debug_name: todo!(), @@ -70,10 +71,14 @@ impl PipelineBuilder { wireframe: todo!(), depth_test: todo!(), }; - let p = unsafe { GPU_GraphicsPipeline_Create( - todo!(), - self.renderpass.map(|r| r.0).unwrap_or(GPU_GetDefaultRenderpass()) - ) }; + let p = unsafe { + GPU_GraphicsPipeline_Create( + todo!(), + self.renderpass + .map(|r| r.0) + .unwrap_or(GPU_GetDefaultRenderpass()), + ) + }; Pipeline(p) } } @@ -81,7 +86,7 @@ impl PipelineBuilder { // fn default() -> Self { // Self { // renderpass: Default::default(), - + // } // } // } diff --git a/examples/game_demo/game_demo.c b/examples/game_demo/game_demo.c index e81f6e1..a179d10 100644 --- a/examples/game_demo/game_demo.c +++ b/examples/game_demo/game_demo.c @@ -114,7 +114,7 @@ int main() { } // Terrain_Draw(terrain); - Grid_Draw(); + // Grid_Draw(); // END Draw calls Frame_Draw(); diff --git a/src/new_render/immdraw.c b/src/new_render/immdraw.c new file mode 100644 index 0000000..3d7cf7d --- /dev/null +++ b/src/new_render/immdraw.c @@ -0,0 +1,27 @@ +#include "immdraw.h" +#include "log.h" +#include "primitives.h" +#include "ral_common.h" +#include "ral_impl.h" +#include "ral_types.h" +#include "render.h" +#include "shader_layouts.h" + +void Immdraw_Init(Immdraw_Storage* storage) { + INFO("Immediate drawing initialisation"); + // meshes + Geometry sphere_geo = Geo_CreateUVsphere(1.0, 8, 8); + storage->sphere = Mesh_Create(&sphere_geo, false); + + // pipeline / material + ShaderData camera_data = { .get_layout = &Binding_Camera_GetLayout }; + GraphicsPipelineDesc pipeline_desc = { + .debug_name = "Immediate Draw Pipeline", + .data_layouts = { camera_data }, + .data_layouts_count = 1, + + }; + storage->colour_pipeline = GPU_GraphicsPipeline_Create(pipeline_desc, GPU_GetDefaultRenderpass()); +} + +void Immdraw_Sphere(Transform tf, f32 size, Vec4 colour, bool wireframe) {}
\ No newline at end of file diff --git a/src/new_render/immdraw.h b/src/new_render/immdraw.h index add7b76..0d58375 100644 --- a/src/new_render/immdraw.h +++ b/src/new_render/immdraw.h @@ -5,8 +5,14 @@ #pragma once #include "defines.h" #include "maths_types.h" +#include "ral_impl.h" +#include "render_types.h" typedef struct Immdraw_Storage { + Mesh plane; + Mesh cube; + Mesh sphere; + GPU_Pipeline* colour_pipeline; } Immdraw_Storage; // --- Public API diff --git a/src/new_render/render.c b/src/new_render/render.c index f83e573..fd5e1c2 100644 --- a/src/new_render/render.c +++ b/src/new_render/render.c @@ -5,9 +5,11 @@ #include "render.h" #include <assert.h> #include <glfw3.h> +#include <stdio.h> #include "camera.h" #include "core.h" #include "grid.h" +#include "immdraw.h" #include "log.h" #include "maths.h" #include "maths_types.h" @@ -45,6 +47,7 @@ struct Renderer { Shadow_Storage* shadows; Terrain_Storage* terrain; Grid_Storage* grid; + Immdraw_Storage* immediate; // Text_Storage* text; ResourcePools* resource_pools; Mesh_pool mesh_pool; @@ -133,17 +136,20 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window // create our renderpasses ren->shadows = malloc(sizeof(Shadow_Storage)); - // Shadow_Init(ren->shadows, 1024, 1024); + Shadow_Init(ren->shadows, 1024, 1024); - ren->pbr = malloc(sizeof(PBR_Storage)); + ren->pbr = calloc(1, sizeof(PBR_Storage)); PBR_Init(ren->pbr); - ren->terrain = malloc(sizeof(Terrain_Storage)); + ren->terrain = calloc(1, sizeof(Terrain_Storage)); Terrain_Init(ren->terrain); ren->grid = calloc(1, sizeof(Grid_Storage)); Grid_Init(ren->grid); + ren->immediate = calloc(1, sizeof(Immdraw_Storage)); + Immdraw_Init(ren->immediate); + // load default textures ren->white_1x1 = TextureLoadFromFile("assets/textures/white1x1.png"); // TODO: black_1x1 |