77 lines
1.5 KiB
C++
77 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
struct xcb_connection_t;
|
|
|
|
namespace ffi {
|
|
struct Core;
|
|
|
|
struct SphericalPosition {
|
|
float yaw = 0.;
|
|
float pitch = 0.;
|
|
float distance = 1.;
|
|
};
|
|
|
|
enum class UseNormal: std::uint8_t {
|
|
Light,
|
|
Camera,
|
|
};
|
|
|
|
struct RedrawArgs {
|
|
SphericalPosition camera_position;
|
|
SphericalPosition light_position;
|
|
float light_radius = 1.;
|
|
float light_spread = 0.;
|
|
float accum_sigma = 1.;
|
|
float accum_scale = 1.;
|
|
std::uint8_t reflections = 0;
|
|
UseNormal use_normal = UseNormal::Light;
|
|
bool show_axes = true;
|
|
bool show_shapes = true;
|
|
bool show_hit_emission = true;
|
|
bool show_miss_emission = true;
|
|
bool show_direct_hit = true;
|
|
bool show_indirect_hit = true;
|
|
bool show_light = true;
|
|
};
|
|
} // namespace ffi
|
|
|
|
using ffi::UseNormal;
|
|
using ffi::RedrawArgs;
|
|
using ffi::SphericalPosition;
|
|
|
|
class MutCore {
|
|
friend class BoxCore;
|
|
|
|
public:
|
|
explicit operator bool() const { return ptr; }
|
|
|
|
void configure(std::uint32_t width, std::uint32_t height) const;
|
|
void redraw(const RedrawArgs& args) const;
|
|
|
|
private:
|
|
ffi::Core* ptr = nullptr;
|
|
ffi::Core* use() const;
|
|
};
|
|
|
|
class BoxCore {
|
|
public:
|
|
BoxCore() = default;
|
|
BoxCore(const BoxCore&) = delete;
|
|
BoxCore(BoxCore&&);
|
|
BoxCore& operator=(const BoxCore&) = delete;
|
|
BoxCore& operator=(BoxCore&&);
|
|
~BoxCore();
|
|
|
|
explicit operator bool() const { return !!ptr; }
|
|
const MutCore* operator->() const { return &ptr; }
|
|
|
|
void reset();
|
|
|
|
static BoxCore from_xcb(xcb_connection_t* connection, std::uint32_t window, std::uint32_t width, std::uint32_t height);
|
|
|
|
private:
|
|
MutCore ptr;
|
|
};
|