Files
rogue/source/rogue.hpp
2026-04-23 19:33:39 -03:00

104 lines
2.3 KiB
C++

#ifndef ROGUE_HPP
#define ROGUE_HPP
#include <atomic>
#include "render/context.hpp"
#include "render/shader_compiler.hpp"
#include "ui/display.hpp"
#include "ui/user_input.hpp"
#include "util/logger.hpp"
#include "vuk/extra/ImGuiIntegration.hpp"
namespace rog {
struct camera_data {
glm::mat4 view;
glm::mat4 inverse_view;
glm::mat4 projection;
glm::mat4 inverse_projection;
glm::uvec4 resolution;
};
struct rt_config {
std::uint32_t current_samples;
};
struct sky_config {
float turbidity;
float azimuth;
float inclination;
};
class rogue {
private:
logger *log;
ui::user_input user_input = {};
ui::display display;
render::context context;
render::shader_compiler shader_compiler;
std::atomic<bool> close_requested = false;
vuk::extra::ImGuiData imgui_data;
sky_config sky = sky_config{
.turbidity = 2.0f,
.azimuth = 0.25f,
.inclination = 1.0f,
};
[[nodiscard]] vuk::PipelineBaseCreateInfo
create_compute_pipeline(std::string_view comp_module,
std::string_view comp_entry);
[[nodiscard]] vuk::PipelineBaseCreateInfo create_graphics_pipeline(
std::string_view vs_module, std::string_view vs_entry,
std::string_view fs_module, std::string_view fs_entry);
[[nodiscard]] vuk::PipelineBaseCreateInfo
create_graphics_pipeline(std::string_view module);
void create_pipelines();
[[nodiscard]] vuk::Value<vuk::ImageAttachment> get_swap_target();
struct vuk_frame_resources {
vuk::Allocator allocator;
vuk::Value<vuk::ImageAttachment> swap_target;
};
[[nodiscard]] vuk_frame_resources get_next_frame_resources();
void do_tick();
[[nodiscard]] glm::mat4 calculate_orbital_view(glm::vec3 min, glm::vec3 max,
float distance, float speed,
float time);
vuk::Unique<vuk::Image> raytrace_accumulation_image;
vuk::Unique<vuk::ImageView> raytrace_accumulation_view;
vuk::ImageAttachment texture_of_raytrace_accumulation;
struct {
std::vector<glm::vec3> positions;
std::vector<std::uint32_t> indices;
glm::vec3 min;
glm::vec3 max;
} model;
void load_obj(std::filesystem::path model);
void create_bvh();
public:
rogue(logger *log, std::filesystem::path model);
void stop();
void run();
};
}; // namespace rog
#endif