Oculus Rift Support

Sorry for the late reply.

I did what you suggested and i think i found the place where it chrases. I added some debug output in both OVRAppState and in OculusFilter. OculusFilter looks like this:

*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mygame.testoculus.oculusvr.post;

import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.texture.FrameBuffer;
import com.oculusvr.capi.GLTexture;
import com.oculusvr.capi.Hmd;
import com.oculusvr.capi.OvrSizei;
import com.oculusvr.capi.OvrVector2i;
import com.oculusvr.capi.Posef;
import com.oculusvr.capi.TextureHeader;
import mygame.testoculus.oculusvr.input.OculusRift;

/**
 *
 * @author reden
 */
public class OculusFilter extends Filter {

    private int eyeIndex = 0;
    private Hmd hmd;
    private GLTexture eyeTexture;
    private Posef pose;
    int textureId = -1;
    int eye;
    private static final Posef poses[] = (Posef[]) new Posef().toArray(2);
    private static final GLTexture eyeTextures[] = (GLTexture[]) new GLTexture().toArray(2);
    
    private static int STATE = 0;

    public OculusFilter(Hmd hmd, int eyeIndex) {
        this.hmd = hmd;
        this.eyeIndex = eyeIndex;
        eyeTexture = eyeTextures[eyeIndex];
    }

    @Override
    protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
        material = new Material(manager, "oculusvr/shaders/Oculus.j3md");

    }

    @Override
    protected Material getMaterial() {
        return material;

    }

    public void setEyeTextureSize(OvrSizei size) {
        TextureHeader eth = eyeTexture.ogl.Header;
        eth.TextureSize.w = size.w;
        eth.TextureSize.h = size.h;
        eth.RenderViewport.Size.w = eth.TextureSize.w;
        eth.RenderViewport.Size.h = eth.TextureSize.h;
        eth.RenderViewport.Pos.x = 0;
        eth.RenderViewport.Pos.y = 0;
    }

    @Override
    protected void preFrame(float tpf) {
        super.preFrame(tpf);
        if (textureId == -1) {
            // try to assign the texture id from the material
            if (material.getTextureParam("Texture") != null) {
                com.jme3.texture.Texture t = material.getTextureParam("Texture").getTextureValue();
                int id = t.getImage().getId();
                eyeTexture.ogl.TexId = id;
                textureId = id;
            }
        }
        System.out.println("OculusFilter: preFrame : before eye");
        eye = hmd.EyeRenderOrder[eyeIndex];
        System.out.println("OculusFilter: preFrame : after eye");
        if (STATE == 0) {
            // anything to do?
            STATE++;
        }
    }

    @Override
    protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
        super.postFrame(renderManager, viewPort, prevFilterBuffer, sceneBuffer);
        // for both:
        if (STATE != 0) {
            pose = OculusRift.getEyePoses()[eye];
            poses[eye].Orientation = pose.Orientation;
            poses[eye].Position = pose.Position;
            STATE++;
        }
    }

    @Override
    protected void postFilter(Renderer r, FrameBuffer buffer) {
        super.postFilter(r, buffer);
        STATE++;
        if (STATE == 5) {
            System.out.println("OculusFilter: postFilter : before endframe");
            hmd.endFrame(poses, eyeTextures);
            System.out.println("OculusFilter: postFilter : after endframe");
            STATE = 0;
        }
    }

    public GLTexture getEyeTexture() {
        return eyeTexture;
    }

}

This is the output when running the program:


run:
Oculus Rift initialized: HMDInfo [HResolution = 1920, VResolution = 1080, HScreenSize = 0.0, VScreenSize = 0.0, VScreenCenter = 0.0, EyeToScreenDistance = 0.0, LensSeparationDistance = 0.0, InterpupillaryDistance = 0.064, DistortionK = [0.0, 0.0, 0.0, 0.0] , DesktopX = 0, DesktopY = 0, DisplayDeviceName = , DisplayId = 0]
jan 29, 2015 1:35:18 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.1.0 (snapshot-github)
jan 29, 2015 1:35:18 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Lwjgl 2.9.1 context running on thread LWJGL Renderer Thread
jan 29, 2015 1:35:18 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: igdumdim64
jan 29, 2015 1:35:18 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: 10.18.10.3574
jan 29, 2015 1:35:18 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: Intel
jan 29, 2015 1:35:18 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 4.2.0 - Build 10.18.10.3574
jan 29, 2015 1:35:18 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: Intel(R) HD Graphics 4600
jan 29, 2015 1:35:18 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 4.20 - Build 10.18.10.3574
jan 29, 2015 1:35:18 PM com.jme3.renderer.opengl.TextureUtil initialize
INFO: Supported texture formats: 
	Alpha8 (Linear)
	Luminance8 (Linear/sRGB)
	Luminance16F (Linear)
	Luminance32F (Linear)
	Luminance8Alpha8 (Linear/sRGB)
	Luminance16FAlpha16F (Linear)
	BGR8 (Linear/sRGB)
	RGB8 (Linear/sRGB)
	RGB565 (Linear/sRGB)
	RGB5A1 (Linear/sRGB)
	RGBA8 (Linear/sRGB)
	ABGR8 (Linear/sRGB)
	ARGB8 (Linear/sRGB)
	BGRA8 (Linear/sRGB)
	DXT1 (Linear/sRGB)
	DXT1A (Linear/sRGB)
	DXT3 (Linear/sRGB)
	DXT5 (Linear/sRGB)
	Depth (Linear)
	Depth16 (Linear)
	Depth24 (Linear)
	Depth32F (Linear)
	RGB16F_to_RGB111110F (Linear)
	RGB111110F (Linear)
	RGB16F_to_RGB9E5 (Linear)
	RGB9E5 (Linear)
	RGB16F (Linear)
	RGBA16F (Linear)
	RGB32F (Linear)
	RGBA32F (Linear)
	Depth24Stencil8 (Linear)

jan 29, 2015 1:35:18 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Device: OpenAL Soft
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Vendor: OpenAL Community
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer: OpenAL Soft
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Version: 1.1 ALSOFT 1.15.1
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: AudioRenderer supports 64 channels
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
jan 29, 2015 1:35:18 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxilary sends: 4
Enter OVRAppState initialize
EyeRenderDesc(allocated@0xddbb6a0 (56 bytes) (shared from auto-allocated@0xddbb6a0 (112 bytes))) {
  int Eye@0=0
  FovPort Fov@4=FovPort(allocated@0xddbb6a4 (16 bytes) (shared from allocated@0xddbb6a0 (56 bytes) (shared from auto-allocated@0xddbb6a0 (112 bytes)))) {
    float UpTan@0=1.3292863
    float DownTan@4=1.3292863
    float LeftTan@8=1.0586576
    float RightTan@c=1.092368
  }
  OvrRecti DistortedViewport@14=OvrRecti(allocated@0xddbb6b4 (16 bytes) (shared from allocated@0xddbb6a0 (56 bytes) (shared from auto-allocated@0xddbb6a0 (112 bytes)))) {
    OvrVector2i Pos@0=OvrVector2i(allocated@0xddbb6b4 (8 bytes) (shared from allocated@0xddbb6b4 (16 bytes) (shared from allocated@0xddbb6a0 (56 bytes) (shared from auto-allocated@0xddbb6a0 (112 bytes))))) {
      int x@0=0
      int y@4=0
    }
    OvrSizei Size@8=OvrSizei(allocated@0xddbb6bc (8 bytes) (shared from allocated@0xddbb6b4 (16 bytes) (shared from allocated@0xddbb6a0 (56 bytes) (shared from auto-allocated@0xddbb6a0 (112 bytes))))) {
      int w@0=3c0
      int h@4=438
    }
  }
  OvrVector2f PixelsPerTanAngleAtCenter@24=OvrVector2f(allocated@0xddbb6c4 (8 bytes) (shared from allocated@0xddbb6a0 (56 bytes) (shared from auto-allocated@0xddbb6a0 (112 bytes)))) {
    float x@0=549.6183
    float y@4=549.6183
  }
  OvrVector3f HmdToEyeViewOffset@2c=OvrVector3f(allocated@0xddbb6cc (12 bytes) (shared from allocated@0xddbb6a0 (56 bytes) (shared from auto-allocated@0xddbb6a0 (112 bytes)))) {
    float x@0=0.032
    float y@4=0.0
    float z@8=0.0
  }
}
FovPort(native@0xbf924c) (16 bytes) {
  float UpTan@0=1.3292863
  float DownTan@4=1.3292863
  float LeftTan@8=1.0586576
  float RightTan@c=1.092368
}
Before autoflush
Exit OVRAppState Initialize
Enter OVRAppState: Update
Exit OVRAppState: Update
SimpleUpdate
Exit SimpleUpdate
OculusFilter: preFrame : before eye
OculusFilter: preFrame : after eye
OculusFilter: preFrame : before eye
OculusFilter: preFrame : after eye
OculusFilter: postFilter : before endframe
AL lib: (EE) alc_cleanup: 1 device not closed
OVRCreateDXGIFactory2 result 0x0
OVRCreateDXGIFactory2 result 0x0
OVRCreateDXGIFactory2 result 0x0
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

As you can see the debugouput after the

hmd.endFrame(poses, eyeTextures);

in OculusFilter:postFilter is not printed, in other words it fair to assume that he chrashes there. Now the question remains on why he chrashes there…

About the orientation in extended mode, as far as i can see windows only allows you to change to orientation of the oculus display when the option “extend these displays” is chosen, not in the option “Duplicate these displays”. And since the resolution of the laptop is 1920 x 1080, i get a border around the game where the desktop is shown.