Actual gopherVR
===============

As most of you know, GopherVR is a gopher client that lets you browse
gopherspace in 3d - it's been around forever,  runs on Irix too,  and
while it's fun- it's not actual Virtual Reality.

So  I  finally figured out how to browser gopherspace with actual  VR
goggles - It took some doing because the state of VR on  linux  is  a
complete mess right now.

I  have a valve index which I got a while ago to mess with vr coding,
and whilst there are open toolkits such as openxr/monado/etc...  they
are in various states of brokenness and are not seeing a lot  of  dev
work. WebXR doesn't work at all  in  any  of  the  browsers,  there's 
basically no way to play 360 video's on Linux, etc,...

SteamVR  somewhat works,  but it's still a bugridden mess, and it too
won't play video.

One thing that does work is vr-video-player, which  can  use  steamvr 
via their openvr library. The name is a bit of a misnomer- because it
isn't really a video player.  It's  more  of a 'make-a-window-vr-ish' 
type thing. You pass it an xorg window ID, and it will  present  that
window's content in VR, complete with head-tracking  and  everything.
So, for 360 video, you'd play it in mplayer or vlc or whatever,  then
pass the video player window ID to vr-video-player and then  it would
cubemap it so it all looks proper 3d in the goggles. It's all  a  bit
hacky.

vr-video-player has various cli  options to map the captured window's
content in various different ways, --sphere, --sphere360, --flat, etc

One option caught my eye:

	--plane : View the window as a slightly curved screen.
	          This is recommended for non-stereoscopic content

Non-stereoscopic content, you say? I tried it with a terminal  window
and sure enough, it was usable in  VR!   Now  i  can  use  phetch  or 
whatever favorite gopher client and browse gopherspace  like  a  real
cyberpunk! :P http://www.linkerror.com/stuff/vrbaby.jpg

Getting vr-video-player to compile was also a fun mess.
It depends on openvr, but openvr is not a package in my  distro-  nor
does it even compile to anything remotely installable  for me when  I
grab the latest master from git.  (it depends on a corevr folder which
doesn't exist anywhere in their repo, nor can i find anything on that
might contain it after lots of googling around)     Thankfully  steam 
comes with a pre-compiled  lib  out  of  the  box, so we can get away
with some build  hackery and use the steam-bundled lib, and then just
the headers from the git repo.

Here's the changes i made:

diff --git a/build.sh b/build.sh
index cacabdc..27588ad 100755
--- a/build.sh
+++ b/build.sh
@@ -1,8 +1,8 @@
 #!/bin/sh -e

-dependencies="glm glew sdl2 openvr x11 xcomposite xfixes"
-includes=$(pkg-config --cflags $dependencies)
-libs=$(pkg-config --libs $dependencies)
-gcc -c src/window_texture.c -O2 $includes
-g++ -c src/main.cpp -O2 $includes
-g++ -o vr-video-player window_texture.o main.o -s $libs
+dependencies="glm glew sdl2 x11 xcomposite xfixes"
+includes="$(pkg-config --cflags $dependencies) -I$HOME/src/openvr/headers"
+libs="$(pkg-config --libs $dependencies) -lopenvr_api -L$HOME/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/"
+gcc -ggdb -O0 -c src/window_texture.c $includes
+g++ -ggdb -O0 -c src/main.cpp $includes
+g++ -ggdb -O0 -o vr-video-player window_texture.o main.o -s $libs

Then after compiling you'll have to set your LD_LIBRARY_PATH to the
folder containing the libopenvr_api.so in order to run the executable

YMMV of course, since the steam-bundled lib and the headers from git
would eventually diverge- i'd imagine. I guess this hacked-together
mess puts the /punk/ in cyberpunk :P

It'd be nice if non-windows VR could get more developer attention
though.

Oh oh oh, and because we can swallow any window into VR  now,  we can
run gopherVR in VR! Finally - all dreams come true eventually :)

Other random idea: Run an xorg xephyr window (yo dawg I heard you 
like xorg, so i put xorg in your xorg so you can xorg while you
xorg) - and then capture that - now you've got the full desktop in 
vr

Here's a little video of a direct capture of phetch running in
cool-old-term running in vr-video-player (that's a mouthful):
http://www.linkerror.com/stuff/vrgopher.webm