mirror of
https://github.com/CrispyPin/sinpin-vr.git
synced 2024-11-10 04:20:25 +01:00
order panels correctly based on pixel coordinates
This commit is contained in:
parent
03d15b42bd
commit
1770dd6e26
3 changed files with 10 additions and 7 deletions
10
src/app.cpp
10
src/app.cpp
|
@ -20,12 +20,18 @@ App::App()
|
||||||
XRRMonitorInfo *monitor_info = XRRGetMonitors(_xdisplay, _root_window, 1, &monitor_count);
|
XRRMonitorInfo *monitor_info = XRRGetMonitors(_xdisplay, _root_window, 1, &monitor_count);
|
||||||
printf("found %d monitors:\n", monitor_count);
|
printf("found %d monitors:\n", monitor_count);
|
||||||
|
|
||||||
|
float pixels_per_meter = 1920;
|
||||||
|
float x_min = -(monitor_info[0].x + monitor_info[0].width / 2.0f);
|
||||||
|
|
||||||
for (int i = 0; i < monitor_count; i++)
|
for (int i = 0; i < monitor_count; i++)
|
||||||
{
|
{
|
||||||
XRRMonitorInfo mon = monitor_info[i];
|
XRRMonitorInfo mon = monitor_info[i];
|
||||||
printf("screen %d: pos(%d, %d) wh(%d, %d)\n", i, mon.x, mon.y, mon.width, mon.height);
|
printf("screen %d: pos(%d, %d) %dx%d\n", i, mon.x, mon.y, mon.width, mon.height);
|
||||||
|
|
||||||
_panels.push_back(Panel(this, i, mon.x, mon.y, mon.width, mon.height));
|
float pos_x = (x_min + mon.x) / pixels_per_meter;
|
||||||
|
float pos_y = 1.2f;
|
||||||
|
vr::HmdMatrix34_t start_pose = {{{1, 0, 0, pos_x}, {0, 1, 0, pos_y}, {0, 0, 1, 0}}};
|
||||||
|
_panels.push_back(Panel(this, start_pose, i, mon.x, mon.y, mon.width, mon.height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
Panel::Panel(App *app, int index, int x, int y, int width, int height)
|
Panel::Panel(App *app, vr::HmdMatrix34_t start_pose, int index, int x, int y, int width, int height)
|
||||||
: _app(app),
|
: _app(app),
|
||||||
_index(index),
|
_index(index),
|
||||||
_x(x),
|
_x(x),
|
||||||
|
@ -33,7 +33,6 @@ Panel::Panel(App *app, int index, int x, int y, int width, int height)
|
||||||
auto overlay_create_err = _app->vr_overlay->CreateOverlay(_name.c_str(), _name.c_str(), &_id);
|
auto overlay_create_err = _app->vr_overlay->CreateOverlay(_name.c_str(), _name.c_str(), &_id);
|
||||||
assert(overlay_create_err == 0);
|
assert(overlay_create_err == 0);
|
||||||
_app->vr_overlay->ShowOverlay(_id);
|
_app->vr_overlay->ShowOverlay(_id);
|
||||||
// _app->vr_overlay->SetOverlayWidthInMeters(_id, 2.5f);
|
|
||||||
uint8_t col[4] = {20, 50, 50, 255};
|
uint8_t col[4] = {20, 50, 50, 255};
|
||||||
_app->vr_overlay->SetOverlayRaw(_id, &col, 1, 1, 4);
|
_app->vr_overlay->SetOverlayRaw(_id, &col, 1, 1, 4);
|
||||||
printf("Created overlay instance %d\n", _index);
|
printf("Created overlay instance %d\n", _index);
|
||||||
|
@ -41,8 +40,6 @@ Panel::Panel(App *app, int index, int x, int y, int width, int height)
|
||||||
// (flipping uv on y axis because opengl and xorg are opposite)
|
// (flipping uv on y axis because opengl and xorg are opposite)
|
||||||
vr::VRTextureBounds_t bounds{0, 1, 1, 0};
|
vr::VRTextureBounds_t bounds{0, 1, 1, 0};
|
||||||
_app->vr_overlay->SetOverlayTextureBounds(_id, &bounds);
|
_app->vr_overlay->SetOverlayTextureBounds(_id, &bounds);
|
||||||
vr::HmdMatrix34_t start_pose = DEFAULT_POSE;
|
|
||||||
start_pose.m[0][3] += index * 1.5f;
|
|
||||||
_app->vr_overlay->SetOverlayTransformAbsolute(_id, _app->_tracking_origin, &start_pose);
|
_app->vr_overlay->SetOverlayTransformAbsolute(_id, _app->_tracking_origin, &start_pose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ class App;
|
||||||
class Panel
|
class Panel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Panel(App *app, int index, int xmin, int xmax, int ymin, int ymax);
|
Panel(App *app, vr::HmdMatrix34_t start_pose, int index, int xmin, int xmax, int ymin, int ymax);
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue