Skip to content
Snippets Groups Projects
Commit a34ddcdd authored by Lava Block's avatar Lava Block
Browse files

remove render_thread #12

parent 32e47e0e
Branches
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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>
// 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment