Files
mirage_old/src/core/renderer/render_context.h

49 lines
1.6 KiB
C++

#pragma once
#include "LLGL/LLGL.h"
#include "misc/mirage_type.h"
#include "render_buffer.h"
#include <span>
namespace mirage {
class render_context {
public:
enum class update_status { success, wait_for_present, fail };
~render_context();
bool init(const swap_chain_descriptor& in_desc, const std::shared_ptr<LLGL::Surface>& in_surface);
update_status render_update(const duration_type& in_delta_time);
void resize_swap_chain(const LLGL::Extent2D& in_size, long in_flag);
void set_vsync(bool in_vsync);
[[nodiscard]] auto is_vsync() const {
return vsync;
}
[[nodiscard]] auto get_swap_chain() const {
return swap_chain;
}
[[nodiscard]] Eigen::Vector2f get_size() const {
const auto& extent_2d = swap_chain->GetResolution();
return {extent_2d.width, extent_2d.height};
}
[[nodiscard]] Eigen::Matrix4f get_projection_matrix() const;
void push_rectangle(const Eigen::Vector2f& in_pos, const Eigen::Vector2f& in_size, const linear_color_type& in_color);
void reset_vertices() {
vertex_buffer->clear();
index_buffer->clear();
}
private:
std::shared_ptr<render_buffer> vertex_buffer;
std::shared_ptr<render_buffer> index_buffer;
std::shared_ptr<render_buffer> param_buffer;
LLGL::CommandBuffer* command_buffer = nullptr;
LLGL::SwapChain* swap_chain = nullptr;
bool vsync = true;
pipeline_info pipeline;
std::optional<LLGL::Extent2D> new_size;
};
} // namespace mirage