-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
70 lines (52 loc) · 1.95 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "vr/system.h"
#include "vr/overlay.h"
#include "vr/overlay_scene.h"
#include "vrwidget.h"
#include <QApplication>
#include <QTimer>
#include <fmt/core.h>
#include <chrono>
#include <thread>
void at_exit() {
ShockLink::VR::VRSystem::Shutdown();
}
int main(int argc, char** argv) {
std::atexit(at_exit);
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
QApplication app(argc, argv);
if (!ShockLink::VR::VRSystem::Initialize()) {
fmt::print("Failed to initialize OpenVR\n");
return 1;
}
auto overlayA = new ShockLink::VR::Overlay("testA", "testA", &app);
if (!overlayA->Ok()) {
fmt::print("Failed to create overlay\n");
return 1;
}
auto overlayB = new ShockLink::VR::Overlay("testB", "testB", &app);
if (!overlayB->Ok()) {
fmt::print("Failed to create overlay 2\n");
return 1;
}
ShockLink::VRWidget* widgetA = new ShockLink::VRWidget();
widgetA->setStyleSheet("QWidget { background-color: gray; }");
ShockLink::VRWidget* widgetB = new ShockLink::VRWidget();
widgetB->setStyleSheet("QWidget { background-color: gray; }");
overlayA->Scene()->SetWidget(widgetA);
overlayA->SetWidth(0.2f);
overlayA->SetVisible(true);
overlayB->Scene()->SetWidget(widgetB);
overlayB->SetWidth(0.2f);
overlayB->SetVisible(true);
ShockLink::VR::Transform controllerOffset;
controllerOffset.SetPosition(glm::vec3(0.0f, 0.05f, 0.1f));
controllerOffset.SetRotation(glm::radians(glm::vec3(-90.0f, 0.0f, 0.0f)));
//overlayA->SetTransformRelative(controllerOffset, ShockLink::VR::Overlay::TrackedDeviceType::LeftController);
//overlayB->SetTransformRelative(controllerOffset, ShockLink::VR::Overlay::TrackedDeviceType::RightController);
QTimer* vrLoopTimer = new QTimer(&app);
QObject::connect(vrLoopTimer, &QTimer::timeout, [&]() {
ShockLink::VR::VRSystem::Update();
});
vrLoopTimer->start(10);
return app.exec();
}