From 3dc6e61d2da254ab545cf58c3c7da54dfac5178b Mon Sep 17 00:00:00 2001 From: Petr Babic <pbabic@redhat.com> Date: Sun, 11 Feb 2024 11:03:45 +0100 Subject: [PATCH] conform to gfx refactor --- src/presenter.cpp | 54 +++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/src/presenter.cpp b/src/presenter.cpp index 66d6517..495a411 100644 --- a/src/presenter.cpp +++ b/src/presenter.cpp @@ -17,54 +17,34 @@ void Presenter::initialize() { osi::presenters()->push_back<com::Folder>("maker")->push_back<com::Link>(self_name() + ".link", this); - // gfx::object_system()->push_frame_back( - // gfx::object_system()->insert_object( - // { "grid" }, - // gfx::shader_generators()->insert_shader_forward_varying_color(), - // gfx::buffer_generators()->insert_procedural_grid() - // ), - // grid_frame() - // ); + // Generate grid + auto grid_shader = gfx::shader_system()->insert_shader("grid_shader", gfx::Shader::Pipeline::FORWARD, {"shaders"}); + auto grid_color = grid_shader->insert<gfx::Shader::NodeConstant>(vec3{0, 0, 0}); + grid_shader->connect(grid_shader->root(), gfx::Shader::MasterNode::inputs::color, grid_color, 0); - // --- BEGIN test_box --- + gfx::object_system()->push_frame_back( + gfx::object_system()->insert_object( + { "grid" }, + grid_shader, + gfx::buffer_generators()->insert_procedural_grid() + ), + grid_frame() + ); - auto shader = gfx::shader_system()->insert_shader("my_shader", gfx::Shader::Pipeline::FORWARD, {"shaders"}); - auto color = shader->insert<gfx::Shader::MyConstant<vec3>>(vec3{0, 0, 1}); - auto master = shader->find<gfx::Shader::MasterNode>(); - shader->connect(master, 0, color, 0); + // Generate box + auto box_shader = gfx::shader_system()->insert_shader("box_shader", gfx::Shader::Pipeline::FORWARD, {"shaders"}); + auto box_color = box_shader->insert<gfx::Shader::NodeConstant>(vec3{0, 0, 1}); + box_shader->connect(box_shader->root(), gfx::Shader::MasterNode::inputs::color, box_color, 0); com::Folder* const test_box = gfx::object_system()->insert_object( { "maker", "test_box" }, - // gfx::shader_generators()->insert_shader_forward_uniform_color(), - shader, + box_shader, gfx::buffer_generators()->insert_procedural_box_solid({ 0.5f, 0.5f, 0.5f } , "test_box", { "maker" }) ); gfx::object_system()->push_frame_back( test_box , root()->push_back<com::Folder>("test_box")->push_back<com::Frame>() ); - // gfx::object_system()->get_uniforms(test_box)->push_back<com::FileVec3>("material_ambient_color", vec3{ 0.75f, 0.75f, 0 }); - - // The second instance - // com::Frame* const frame2 = root()->push_back<com::Folder>("test_box_2")->push_back<com::Frame>(); - // frame2->move_origin({ 0.5f, 0, 1.5f }); - // gfx::object_system()->push_frame_back(test_box, frame2); - - // --- END test_box --- - - // --- BEGIN directional light --- - - // com::Frame* const frame_light = root()->push_back<com::Folder>("directional_light")->push_back<com::Frame>(); - // com::Folder* const dir_light = gfx::light_system()->insert_light<gfx::DirectionalLight>( - // { "global", "directional" }, - // frame_light, - // vec4{ 0.75f, 0.75f, 0.75f, 1 } - // ); - - // --- END directional light --- - - // gfx::object_system()->insert_light(test_box, dir_light); - // gfx::light_system()->insert_shadow_caster(dir_light, test_box); } void Presenter::release() -- GitLab