order panels correctly based on pixel coordinates

This commit is contained in:
Crispy 2023-04-07 20:32:52 +02:00
parent 03d15b42bd
commit 1770dd6e26
3 changed files with 10 additions and 7 deletions

View file

@ -20,12 +20,18 @@ App::App()
XRRMonitorInfo *monitor_info = XRRGetMonitors(_xdisplay, _root_window, 1, &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++)
{
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));
}
}

View file

@ -5,7 +5,7 @@
#include <X11/Xutil.h>
#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),
_index(index),
_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);
assert(overlay_create_err == 0);
_app->vr_overlay->ShowOverlay(_id);
// _app->vr_overlay->SetOverlayWidthInMeters(_id, 2.5f);
uint8_t col[4] = {20, 50, 50, 255};
_app->vr_overlay->SetOverlayRaw(_id, &col, 1, 1, 4);
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)
vr::VRTextureBounds_t bounds{0, 1, 1, 0};
_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);
}
}

View file

@ -10,7 +10,7 @@ class App;
class Panel
{
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();