mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 12:09:19 +02:00
A template defined in a module interface is instantiated in the importing unit, where its body's types must be complete. A declaration reaching the importer only through the interface's global module fragment is not enough for MSVC: cParser::operator>> uses std::stringstream, and every unit that parsed a float got an incomplete type. 526 headers across 161 units, derived from what each interface's template bodies actually name.
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
module;
|
|
#include <cstddef>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
export module eu07.vr.vr_interface;
|
|
import eu07.glm;
|
|
import eu07.vehicle.camera;
|
|
import eu07.simcore;
|
|
import eu07.model.texture;
|
|
|
|
export {
|
|
|
|
class vr_interface
|
|
{
|
|
public:
|
|
enum eye_e {
|
|
eye_left,
|
|
eye_right
|
|
};
|
|
|
|
virtual viewport_proj_config get_proj_config(eye_e) = 0;
|
|
virtual TModel3d* get_hiddenarea_mesh(eye_e) = 0;
|
|
virtual glm::ivec2 get_target_size() = 0;
|
|
virtual void begin_frame() = 0;
|
|
virtual void submit(eye_e, opengl_texture*) = 0;
|
|
virtual std::vector<TModel3d*> get_render_models() = 0;
|
|
virtual glm::mat4 get_pick_transform() = 0;
|
|
virtual void finish_frame() = 0;
|
|
virtual ~vr_interface() = 0;
|
|
};
|
|
|
|
class vr_interface_factory
|
|
{
|
|
public:
|
|
using create_method = std::unique_ptr<vr_interface>(*)();
|
|
|
|
bool register_backend(const std::string &backend, create_method func);
|
|
std::unique_ptr<vr_interface> create(const std::string &name);
|
|
|
|
static vr_interface_factory* get_instance();
|
|
|
|
private:
|
|
std::unordered_map<std::string, create_method> backends;
|
|
static vr_interface_factory *instance;
|
|
};
|
|
|
|
} // export
|