1

I have an WPF+SharpDX Windows application that displays to the OSVR HDK via a fullscreen window on the screen that is the HDK. This setup works well, but it requires users to state which screen the HDK is on.

I would like to have that automatically detected, but haven't seen anything in the API on which screen is the headset.

Currently I render in a window:

var bounds = dxgiDevice.Adapter.Outputs[_selectedOutput].Description.DesktopBounds;
form.DesktopBounds = new System.Drawing.Rectangle(
    bounds.X, bounds.Y, bounds.Width, bounds.Height);

And _selectedOutputis the thing I'm looking for.

I don't support direct mode at this time and I'm using Managed-OSVR. The application will run on Windows 8/8.1/10.

Krzysztof Bociurko
  • 4,575
  • 2
  • 26
  • 44

1 Answers1

1

It's been a while since I coded anything for OSVR, but here's from what I remember: If you're running in extended mode, the OSVR is treated as a regular display. You can rearrange it as any other screen. The output location can be configured in the OSVR config file. I used the following (Java) to retrieve the position and size to set up my window:

osvrContext.getRenderManagerConfig().getXPosition()
osvrContext.getRenderManagerConfig().getYPosition()
osvrContext.getDisplayParameters().getResolution(0).getWidth()
osvrContext.getDisplayParameters().getResolution(0).getHeight()

To clarify: I don't know if you can retrieve the id of the display in extended mode. From what I know, it's only defined as a position and size on the desktop. I hope that it helps you, somewhat.

reden
  • 968
  • 7
  • 14
  • Unfortunatelly , I haven't got anything like `osvrContext` or `getRenderManagerConfig` in Managed-OSVR. Every method that returns dimmensions is either just width/height or is returning bounds for just one eye. The code you mentioned is from the official Java API - but I cannot find an equivalent in the C# (Managed) one. – Krzysztof Bociurko Nov 08 '16 at 15:12
  • No, it's from my own Java wrapper. I wish there was an official Java API ;) – reden Nov 08 '16 at 17:32
  • 1
    A hack I would do then is to look for: 'OSVR\OSVR-Core\bin\whatever config you're using.json'. Find: "xPosition": 1920, "yPosition": 0 and use those to get your window appear in the right position – reden Nov 08 '16 at 17:36
  • Whoops, google-fu has failed me, somehow I've mixed your and OSVR's github search results into one. Back to the point, is this the hack that you're using or is there any cleaner way to do this? I'm having a semi-sandboxed app and while I probably could go read config files from the hard drive, that might give me some problems in the future. – Krzysztof Bociurko Nov 10 '16 at 15:17
  • No, I used the example I posted in the answer. That's what I would recommend. The other way is just something you could try if you can't access the methods in the API (which makes the port kind of broken) – reden Nov 10 '16 at 18:14
  • 1
    @reden if you'd be willing to share your java wrapper, that would be swell :D @chanibal You do have an OSVR client context in managed-osvr. the RenderManager config is a string value loaded into the OSVR path tree, iirc at `/renderManagerConfig` - parse as JSON to get those values. Don't have display ID in there now, and that config is subject to change - please open an issue on https://github.com/sensics/OSVR-RenderManager – Ryan Pavlik Dec 15 '16 at 16:32
  • Thanks @reden, will check that – Krzysztof Bociurko Dec 15 '16 at 16:36
  • (You might be able to use a Windows API to go from virtual desktop coordinates to screen ID, I would think. Note that this would only work if the headset isn't in direct mode, since direct mode requires you to render to a texture and give to rendermanager. Figuring out how to use rendermanager would probably be the best solution - let it handle distortion, etc.) – Ryan Pavlik Dec 15 '16 at 16:36
  • @reden, using direct mode is somewhere in my roadmap. As for desktop coordinates, I do use that API, the issue is that I don't know which screen the OSVR is on. Currently I'm guessing by searching the HDK1/HDK2 resolutions and providing the user a way to change the screen number in settings if the guess was wrong. – Krzysztof Bociurko Dec 15 '16 at 16:39
  • @ryan-pavlik My code is on github: https://github.com/neph1/OSVR-Java-Wrapper & https://github.com/neph1/OSVR-Java . With jMonkeyEngine integration: https://github.com/neph1/jme3-osvr . Process is documented in this thread: http://www.osvr.org/forum/viewtopic.php?f=9&t=3482&hilit=java – reden Dec 17 '16 at 09:29
  • Cool stuff! Shame it's on the forum, I actually can't post to the forum, I end up using Reddit instead (and ideally would be using the mailing list, etc) – Ryan Pavlik Dec 20 '16 at 15:28