Aug
14
2013

Unity3D, Oculus Rift and the fullscreen problem

A problem that got me frustrated since I unpacked my Rift and started the first Unity3D demo was, that there was no way to force the demo to run fullscreen on a secondary monitor (-adapter did not work for me). There are two workarounds that worked for me somehow:

  • Change the primary display to the rift
  • Use display mirroring

However, both solutions are not really acceptable. The first one has some side effects like the taskbar beeing on the rift, windows opening there becoming inaccessible and so on. Mirroring works quite well if you have a primary display with a resolution up to 1920x1200. Since I own a 30" monitor, that forced me to use a lower resolution on it. Not very nice in the long run. Display mirroring also introduces some lags on the rift which are quite irritating.

Road to solution

So I thought about it for a while and remembered a tool that could capture screens from Direct3D applications through a hooking mechanism (see http://spazzarama.com/2011/03/14/c-screen-capture-and-overlays-for-direct3d-9-10-and-11-using-api-hooks/). From there it was quite easy to introduce a new hook that would link into IDXGISwapChain.SetFullscreenState where you are able to set a target output. Exactly what I wanted. An hour later the thing really worked - cool. No more display mirroring, my primary display beeing the one I am used to.

Solution

All this led to a small command line tool that can force any(?) Direct3D 11 application to output on the Oculus Rift.

Requirements

  • Direct3D 11 application and graphics card
  • .NET Framework 4
  • obviously an Oculus Rift DevKit 1 (later DevKits can be used if code is modified - device detection looks for device id containing OVR0001)

Usage

Extract the ZIP file anywhere you like. As I said, the tool is a command line tool. So bring up a command prompt and enter the following:

ForceToRift.exe [PathToExeToStart] [additional arguments to pass to exe]

After hitting return you should see some debug output and your target application should start on the Rift. Remember that this only works for Direct3D 11 applications. So if you have a Unity3D Demo that was compiled for Direct3D9 you can try the following:

ForceToRift.exe [Direct3D9App.exe] --force-d3d11

 

Downloads

  • Binaries
  • Source code (be aware that it is not really cleaned up, but it works for me, the interesting part is in DXHookD3D11.cs)

You are free to use and modify this as you want.

Comments (3) -

Justin

I'm glad you found a way to use my D3DHook project for this. A mate at work got himself a Rift dev kit and one of his first questions was whether I thought that project would help Smile

Cheers,
Justin

bonus senza deposito per opzioni binarie

This site really has all of the info I wanted about this subject and didn't know who to ask.

Archer

Nice post. I was checking continuously this weblog and I am inspired! Very helpful info specifically the final section Smile I handle such info a lot. I was seeking this certain information for a long time. Thank you and good luck.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

TextBox