cancel
Showing results for 
Search instead for 
Did you mean: 

ovrHmd_AttachToWindow is not working in Qt's GLWidget.

mmostajab
Honored Guest
I wanted to send the output directly to the oculus using the ovrHmd_AttachToWindow function as follows:

        if (!ovrHmd_AttachToWindow(hmd, (void*) Base::winId(), 0, 0)) {
dprintf("HMD: Could not attach to window!\n");
return;
}
dprintf("HMD: connected to window with id HWND=%i", Base::winId());


unfortunately, it is not working. Also, there is no error. Just it is not sent directly to the Oculus. The window is appearing there, and I should move the windows to oculus manually and make it full screen. I am using the extended display mode.
3 REPLIES 3

jherico
Adventurer
"mmostajab" wrote:
I wanted to send the output directly to the oculus using the ovrHmd_AttachToWindow function as follows:

        if (!ovrHmd_AttachToWindow(hmd, (void*) Base::winId(), 0, 0)) {
dprintf("HMD: Could not attach to window!\n");
return;
}
dprintf("HMD: connected to window with id HWND=%i", Base::winId());


unfortunately, it is not working. Also, there is no error. Just it is not sent directly to the Oculus. The window is appearing there, and I should move the windows to oculus manually and make it full screen. I am using the extended display mode.


You seem to be misunderstanding how the Direct/Extended mechanism works from an application perspective. Your expectations appear to be based on how Direct mode works, but you're working in Extended. You can detect if the HMD is in Direct mode by checking the flags, and it's your responsibility as a developer to do the right thing depending on what mode you detect.

Specifically, if you're in extended mode, it's your responsibility to create a fullscreen window on the target monitor (which can be found by looking in the ovrHmd structure) or create a borderless window matching the desktop position and current resolution of the Rift. In extended mode, ovrHmd_AttachToWindow doesn't actually have any effect.

In Direct mode, on the other hand, the ovrHmd_AttachToWindow is what tells the SDK to link the OpenGL context for the window to the actual display on the Rift.

mmostajab
Honored Guest
Great! Thank you! 🙂

It fixed my problem. I used the hmd->WinodwPos and hmd->Resolution to translate my output into HMD 🙂

jherico
Adventurer
"mmostajab" wrote:
It fixed my problem. I used the hmd->WinodwPos and hmd->Resolution to translate my output into HMD 🙂


That's good. But you should bear in mind that hmd->Resolution is the native resolution of the headset, regardless of the current resolution. If someone is for any reason running the Rift at something other than the native resolution, they will get a bad result from code that simply uses hmd->Resolution. This may become even more critical in the future as HMDs start supporting higher resolutions, perhaps even having native resolutions that some systems may not be able to support.

The correct solution is to iterate over all the screen devices on the system, and find the one which has a desktop position matching hmd->WindowPos and then query the system for that screen's current resolution. Obviously this isn't really critical if you're just experimenting or developing for your own use, but if you're planning on creating a distributable application, it's something you should make sure you get right.