Loading gfx/include/gfx/renderer.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,12 @@ struct Renderer : public com::Library { enum pipeline { FORWARD, DEFERRED, TRANSPARENT }; struct Context { std::function<void(pipeline p, std::function<void(Camera*)>)> render_wrapper; }; std::vector<Context> contexts {}; /** * Renders all objects in a folder. The FS tree is searched recursively using DFS. * Allows selection between rendering pipelines. When rendering with \code FORWARD\endcode Loading gfx/src/buffer_generators.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ #include <utils/invariants.hpp> #include <utils/config.hpp> #include <osi/index.hpp> #include <numbers> #if COMPILER() == COMPILER_CLANG() || COMPILER() == COMPILER_GCC() # define cosf cos # define sinf sin Loading gfx/src/renderer.cpp +48 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,33 @@ Renderer::Renderer() : com::Library{ self_name() }, m_win_width{ 0 }, m_win_heig resize_fullscreen_textures(); configure_face_culling(true); // Add default render context const Context default_context { .render_wrapper = [this](pipeline p, const std::function<void(Camera*)> &draw_callback) { const auto camera = camera_system()->active_camera(); ASSUMPTION(camera != nullptr); //resize_fullscreen_textures(); viewport_system()->active_viewport()->activate(); switch (p) { case FORWARD: case TRANSPARENT: GL_ASSUME_SUCCESS(glBindFramebuffer(GL_FRAMEBUFFER, 0)); break; case DEFERRED: GL_ASSUME_SUCCESS(glBindFramebuffer(GL_FRAMEBUFFER, m_g_buffer)); break; default: UNREACHABLE(); break; } draw_callback(camera); } }; contexts.push_back(default_context); } Renderer::~Renderer() { Loading Loading @@ -124,6 +151,26 @@ void Renderer::clear_render_buffers(bool using_deferred) { GL_ASSUME_SUCCESS(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); } void Renderer::present_collection(com::Folder *const collection, pipeline p) { ASSUMPTION(collection == object_system()->objects() || collection->is_under(object_system()->objects())); for (const Context &ctx : contexts) { ctx.render_wrapper(p, [this, collection, p](const Camera* camera) { ASSUMPTION(camera != nullptr); const auto cam_frame = camera->folder()->find<com::Link>(camera_system()->frame_link_file_name())->target<com::Frame>(); CommonVisitData const common { camera->matrix(), cam_frame->in(), cam_frame->frame().origin() }; GL_ASSUME_SUCCESS(glEnable(GL_DEPTH_TEST)); if (p == TRANSPARENT) present_collection_transparent(collection, common); else present_collection(collection, common); }); } } /* void Renderer::present_collection(com::Folder *const collection, pipeline p) { ASSUMPTION(collection == object_system()->objects() || collection->is_under(object_system()->objects())); ASSUMPTION(camera_system()->active_frame() != nullptr); Loading Loading @@ -157,6 +204,7 @@ void Renderer::present_collection(com::Folder *const collection, pipeline p) { else present_collection(collection, common); } */ void Renderer::lighting_pass(const std::vector<const com::Folder *> &lights, ShaderGraph::lighting_model lm) const { GL_ASSUME_SUCCESS(glBindFramebuffer(GL_FRAMEBUFFER, 0)); Loading osi/include/osi/run.hpp +4 −2 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ # include <lfs/module.hpp> # include <phx/module.hpp> # include <script/module.hpp> # include <xr/module.hpp> # include <com/context.hpp> # include <math/math.hpp> # include <string> Loading Loading @@ -46,7 +47,8 @@ struct Config final { com::boot, com::shutdown }, { gfx::boot, gfx::shutdown }, { scr::boot, scr::shutdown }, { phx::boot, phx::shutdown } { phx::boot, phx::shutdown }, { xr ::boot, xr ::shutdown } }; std::vector<BootAndShutdown> user_modules{}; }; Loading xr/CMakeLists.txt 0 → 100644 +9 −0 Original line number Diff line number Diff line set(THIS_TARGET_NAME xr) file(GLOB "${THIS_TARGET_NAME}_HPP" "./include/${THIS_TARGET_NAME}/*.hpp") file(GLOB "${THIS_TARGET_NAME}_CPP" "./src/*.cpp") add_library(${THIS_TARGET_NAME} "${${THIS_TARGET_NAME}_HPP}" "${${THIS_TARGET_NAME}_CPP}" ) No newline at end of file Loading
gfx/include/gfx/renderer.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,12 @@ struct Renderer : public com::Library { enum pipeline { FORWARD, DEFERRED, TRANSPARENT }; struct Context { std::function<void(pipeline p, std::function<void(Camera*)>)> render_wrapper; }; std::vector<Context> contexts {}; /** * Renders all objects in a folder. The FS tree is searched recursively using DFS. * Allows selection between rendering pipelines. When rendering with \code FORWARD\endcode Loading
gfx/src/buffer_generators.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ #include <utils/invariants.hpp> #include <utils/config.hpp> #include <osi/index.hpp> #include <numbers> #if COMPILER() == COMPILER_CLANG() || COMPILER() == COMPILER_GCC() # define cosf cos # define sinf sin Loading
gfx/src/renderer.cpp +48 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,33 @@ Renderer::Renderer() : com::Library{ self_name() }, m_win_width{ 0 }, m_win_heig resize_fullscreen_textures(); configure_face_culling(true); // Add default render context const Context default_context { .render_wrapper = [this](pipeline p, const std::function<void(Camera*)> &draw_callback) { const auto camera = camera_system()->active_camera(); ASSUMPTION(camera != nullptr); //resize_fullscreen_textures(); viewport_system()->active_viewport()->activate(); switch (p) { case FORWARD: case TRANSPARENT: GL_ASSUME_SUCCESS(glBindFramebuffer(GL_FRAMEBUFFER, 0)); break; case DEFERRED: GL_ASSUME_SUCCESS(glBindFramebuffer(GL_FRAMEBUFFER, m_g_buffer)); break; default: UNREACHABLE(); break; } draw_callback(camera); } }; contexts.push_back(default_context); } Renderer::~Renderer() { Loading Loading @@ -124,6 +151,26 @@ void Renderer::clear_render_buffers(bool using_deferred) { GL_ASSUME_SUCCESS(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); } void Renderer::present_collection(com::Folder *const collection, pipeline p) { ASSUMPTION(collection == object_system()->objects() || collection->is_under(object_system()->objects())); for (const Context &ctx : contexts) { ctx.render_wrapper(p, [this, collection, p](const Camera* camera) { ASSUMPTION(camera != nullptr); const auto cam_frame = camera->folder()->find<com::Link>(camera_system()->frame_link_file_name())->target<com::Frame>(); CommonVisitData const common { camera->matrix(), cam_frame->in(), cam_frame->frame().origin() }; GL_ASSUME_SUCCESS(glEnable(GL_DEPTH_TEST)); if (p == TRANSPARENT) present_collection_transparent(collection, common); else present_collection(collection, common); }); } } /* void Renderer::present_collection(com::Folder *const collection, pipeline p) { ASSUMPTION(collection == object_system()->objects() || collection->is_under(object_system()->objects())); ASSUMPTION(camera_system()->active_frame() != nullptr); Loading Loading @@ -157,6 +204,7 @@ void Renderer::present_collection(com::Folder *const collection, pipeline p) { else present_collection(collection, common); } */ void Renderer::lighting_pass(const std::vector<const com::Folder *> &lights, ShaderGraph::lighting_model lm) const { GL_ASSUME_SUCCESS(glBindFramebuffer(GL_FRAMEBUFFER, 0)); Loading
osi/include/osi/run.hpp +4 −2 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ # include <lfs/module.hpp> # include <phx/module.hpp> # include <script/module.hpp> # include <xr/module.hpp> # include <com/context.hpp> # include <math/math.hpp> # include <string> Loading Loading @@ -46,7 +47,8 @@ struct Config final { com::boot, com::shutdown }, { gfx::boot, gfx::shutdown }, { scr::boot, scr::shutdown }, { phx::boot, phx::shutdown } { phx::boot, phx::shutdown }, { xr ::boot, xr ::shutdown } }; std::vector<BootAndShutdown> user_modules{}; }; Loading
xr/CMakeLists.txt 0 → 100644 +9 −0 Original line number Diff line number Diff line set(THIS_TARGET_NAME xr) file(GLOB "${THIS_TARGET_NAME}_HPP" "./include/${THIS_TARGET_NAME}/*.hpp") file(GLOB "${THIS_TARGET_NAME}_CPP" "./src/*.cpp") add_library(${THIS_TARGET_NAME} "${${THIS_TARGET_NAME}_HPP}" "${${THIS_TARGET_NAME}_CPP}" ) No newline at end of file