LWJGL 3 with Oculus Rift

Started by BrickFarmer, February 12, 2015, 11:55:48

Previous topic - Next topic

BrickFarmer

I finally got my single room experiment working!  I'm not sure what, but something was wrong with my procedural texture generation.  When I switch to png textures it started working :)

todo:

The mouse cursor gets stolen at startup, as described here:

http://forum.lwjgl.org/index.php?topic=5572.msg29683#msg29683

I get ~112fps but it is not steady at that rate.

There is some judder when looking around, but that might be from the SDK tracking head movement.

Anyway I'm just pleased to have something simple finally running.  I've put my code up on github if anyone is interested.  You might need to change the monitor number, since it's quite tricky to work out which monitor is the rift.  enjoy.

Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

BrickFarmer

I want to port this over to OpenGL ES, but it's not clear from the roadmap if OpenGL ES binding is part of the 3.0 3.1 release?

Related to that, is it going to be possible using openGL ES to target both desktop and mobile?  I dont have much experience with ES, and I'm wondering if it is even supported on the desktop?

Otherwise I'm going to port my examples over to 'modern OpenGL'  is there a 'best practice' example for using shaders with LWJGL3?
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

spasi

Quote from: BrickFarmer on March 09, 2015, 09:49:40I want to port this over to OpenGL ES, but it's not clear from the roadmap if OpenGL ES binding is part of the 3.0 3.1 release?

LWJGL 3 will have both libOVR and OpenGL ES bindings.

Quote from: BrickFarmer on March 09, 2015, 09:49:40Related to that, is it going to be possible using openGL ES to target both desktop and mobile?  I dont have much experience with ES, and I'm wondering if it is even supported on the desktop?

See this post. It's a bit old, so try to make sure the information is still valid.

Quote from: BrickFarmer on March 09, 2015, 09:49:40Otherwise I'm going to port my examples over to 'modern OpenGL'  is there a 'best practice' example for using shaders with LWJGL3?

There is no such thing as "best practice doing X with LWJGL". Anything that applies to OpenGL in general, applies to LWJGL. If you limit your search options to LWJGL specific code samples and tutorials (or this forum), you'll never find the information you're looking for.

BrickFarmer

Thanks for that!  Some interesting reading, and still seems to reflect the current state of progress from what else I'm reading.  The Google Angle looks promising, but not much of interest without a Java wrapper :)  I'm gonna stick with porting this over to 'modern OpenGL' for now then, and have another look later about ES2/3.
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

BrickFarmer

So before I go any further, I wanted to check if my usage of LWJGL3 is correct in my simple shader example.  I mean my program runs, but is there any gochas that I should know about before I take the next steps?

For example, I found a mention of
glGetProgramiv(program, GL_LINK_STATUS, linked)
in my book, but cant find the equivalent for LWJGL. 

Also it looks like I should delete the program if linking fails, and I assume somewhere before I shut down GLFW?  Or does the shader program get cleaned up internally at shutdown?


https://github.com/WhiteHexagon/example-jovr-lwjgl3-rift/blob/master/src/main/java/com/sunshineapps/riftexample/ShaderProgram120.java

Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

spasi

Quote from: BrickFarmer on March 11, 2015, 08:46:53So before I go any further, I wanted to check if my usage of LWJGL3 is correct in my simple shader example.  I mean my program runs, but is there any gochas that I should know about before I take the next steps?

For example, I found a mention of
glGetProgramiv(program, GL_LINK_STATUS, linked)
in my book, but cant find the equivalent for LWJGL.

You can use either glGetProgrami(int program, int pname, ByteBuffer params) or glGetProgram(int program, int pname, IntBuffer params).

Quote from: BrickFarmer on March 11, 2015, 08:46:53Also it looks like I should delete the program if linking fails, and I assume somewhere before I shut down GLFW?  Or does the shader program get cleaned up internally at shutdown?

Everything is cleaned up automatically when you destroy an OpenGL context or the process exits. But it's good practice to do manual cleanup ahead of that. You should get used to properly handling the lifecycle of resources you allocate, especially if you're interested in trying Vulkan some day.

rupy

Quote from: spasi on March 09, 2015, 10:45:02
Quote from: BrickFarmer on March 09, 2015, 09:49:40I want to port this over to OpenGL ES, but it's not clear from the roadmap if OpenGL ES binding is part of the 3.0 3.1 release?

LWJGL 3 will have both libOVR and OpenGL ES bindings.

Nice! When is this planned to be released?

I have been using Pete's Minecrift driver so far:

http://aeonalpha.com (Runs at 1000+ FPS on GTX 750 Ti)

Also is Vulkan being looked at?

Being an old school direct rendering fan, I think Vulkan is the wrong priority:

First hardware should display the frame when the GPU sends the data like g-sync, but a common standard; that would be a more direct reward for VR. This multi-threaded rendering is going to slow development down, almost to a grinding halt.

Complexity is killing us slowly.

"It's like Homeworld in first person."

BrickFarmer

I noticed that libOVR is showing as beta support :) do you have any pointers to that for getting started?  Also is it matching the Oculus Rift 0.6.0 SDK version?  I'm keen to have another go with LWJGL and DK2.
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

spasi

I can't be of much help; I don't own a DK2, so have no way to do any testing with LWJGL. Everything is there though (the C API) and the Oculus SDK has plenty of example code to get you started and lots of useful information in the guides.

Yes, the bindings have been updated to the 0.6.0 SDK. The API has seen big improvements in the latest version. The 0.5 API felt like a hacky work-in-progress. 0.6 should be much closer to the final API and simpler to use than 0.5.

BrickFarmer

Wow that was fast, 0.6.0 has not been out for long.  I'll dust of my windows box and give it a try :) Thanks!
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

BrickFarmer

The libOVR does not seem to be a part of the nightly, so I git cloned lwjgl3 master and tried building it from source.  I needed an extra 'ant release' to build the .jar, but this also seems to be missing org.lwjgl.ovr package.  Unless I used the wrong target? 

I did do this on my mac, and I'm wondering if the build is platform aware? ie didnt include ovr since it's no longer supported on OSX? 

or is there a config file somewhere that I need to set the build.ovr flag?
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

spasi

Indeed, the libOVR bindings are not included by default. You need to edit this line, set the location to where you extracted the Oculus SDK. This is only supported on Windows atm, since the 0.6.0 runtime is Windows-only. You can use a free version of Visual Studio to build LWJGL, either Express 2013 for Windows Desktop or the new Community 2013.

BrickFarmer

I went with the community 2013, wow that is a slow install, it's taken most of the day to get everything running. jdk 1.8_45, ant 1.9.4, VS2013

So now I get as far as compile-native which fails with the linker with multiple error LNK2019 resulting in lwjgl.dll fater error LNK1120 101 unresolved externals

I'm sure it's just some more config stuff missing, but is there a guide for this so I dont waste your time?  Thanks.
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

spasi


BrickFarmer

Thanks! that helped somewhat...  So I have the 'VS2013 x64 Native Tools Command Prompt' open. Java version is showing correct as 64bit server vm.  ant echos x86 for build.arch. pretty sure my windows is 64bit 7 home premium SP1. A quick print in Java for os.arch shows amd64.  but I'm still seeing some kind of mismatch, now with LNK1112 module machine type 'x64' conflicts with target machine type 'X86' on LIBCMT.lib(crt0dat.obj).  So where might it be getting the X86  from?
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon