55 lines
1.0 KiB
C++
55 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
|
|
|
struct xcb_connection_t;
|
|
|
|
class IBoxed {
|
|
friend struct BoxDeleter;
|
|
|
|
private:
|
|
virtual void destroy() = 0;
|
|
};
|
|
|
|
struct BoxDeleter {
|
|
void operator()(IBoxed* obj) {
|
|
obj->destroy();
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
using Box = std::unique_ptr<T, BoxDeleter>;
|
|
|
|
struct alignas(16) Vec4 {
|
|
float x, y, z, w;
|
|
};
|
|
|
|
namespace ffi {
|
|
struct RedrawArgs {
|
|
float cam_yaw;
|
|
float cam_pitch;
|
|
float cam_distance;
|
|
float cam_fovy;
|
|
};
|
|
} // namespace ffi
|
|
|
|
using ffi::RedrawArgs;
|
|
|
|
class ICore : public IBoxed {
|
|
public:
|
|
virtual void configure(std::uint32_t width, std::uint32_t height) = 0;
|
|
virtual void redraw(const RedrawArgs& args) = 0;
|
|
};
|
|
|
|
class ICoreFactory : public IBoxed {
|
|
private:
|
|
virtual ICore* new_xcb(xcb_connection_t* connection, std::uint32_t window, std::uint32_t width, std::uint32_t height) const = 0;
|
|
|
|
public:
|
|
Box<ICore> from_xcb(xcb_connection_t* connection, std::uint32_t window, std::uint32_t width, std::uint32_t height) const {
|
|
return Box<ICore>{new_xcb(connection, window, width, height)};
|
|
}
|
|
};
|