diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ec52c8191afa4ed7f9d38a639c0f64c19019b48..f5590ea197161ec06252427f9ad1c9951bdb5a4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,7 +244,6 @@ add_library(lava.frame STATIC ${LIBLAVA_DIR}/frame/input.hpp ${LIBLAVA_DIR}/frame/render_target.cpp ${LIBLAVA_DIR}/frame/render_target.hpp - ${LIBLAVA_DIR}/frame/render_thread.hpp ${LIBLAVA_DIR}/frame/renderer.cpp ${LIBLAVA_DIR}/frame/renderer.hpp ${LIBLAVA_DIR}/frame/swapchain.cpp diff --git a/liblava/frame.hpp b/liblava/frame.hpp index a1828e0c8f236f0d73ea884be1ef6121115b66b6..6cc7272ab7a9d5f9c00d5b61e1cfb7d648cf1313 100644 --- a/liblava/frame.hpp +++ b/liblava/frame.hpp @@ -7,7 +7,6 @@ #include <liblava/frame/frame.hpp> #include <liblava/frame/input.hpp> #include <liblava/frame/render_target.hpp> -#include <liblava/frame/render_thread.hpp> #include <liblava/frame/renderer.hpp> #include <liblava/frame/swapchain.hpp> #include <liblava/frame/window.hpp> diff --git a/liblava/frame/render_thread.hpp b/liblava/frame/render_thread.hpp deleted file mode 100644 index e07028721266bb462fec09e29595c31e6c4470ba..0000000000000000000000000000000000000000 --- a/liblava/frame/render_thread.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// file : liblava/frame/render_thread.hpp -// copyright : Copyright (c) 2018-present, Lava Block OÜ -// license : MIT; see accompanying LICENSE file - -#pragma once - -#include <liblava/frame/renderer.hpp> -#include <thread> - -namespace lava { - - struct render_thread { - ~render_thread() { - destroy(); - } - - bool create(swapchain* swapchain) { - plotter.on_destroy = [&]() { stop(); }; - - return plotter.create(swapchain); - } - - void destroy() { - plotter.destroy(); - } - - void start() { - thread = std::thread(&render_thread::render_loop, this); - } - - void stop() { - if (!active) - return; - - active = false; - thread.join(); - } - - using render_func = std::function<VkCommandBuffers(ui32)>; - render_func on_render; - - renderer* get_renderer() { - return &plotter; - } - bool running() const { - return active; - } - - bool render() { - auto frame_index = plotter.begin_frame(); - if (!frame_index) - return false; - - return plotter.end_frame(on_render(*frame_index)); - } - - private: - void render_loop() { - active = true; - - while (active) { - if (!plotter.active) - continue; - - if (!on_render) - continue; - - render(); - } - } - - std::thread thread; - bool active = false; - - renderer plotter; - }; - -} // namespace lava