@Override
    public boolean initialize() {
        // Check to make sure the HMD is connected
        OVRDetectResult detect = OVRDetectResult.calloc();
        ovr_Detect(0, detect);
        boolean connected = detect.IsOculusHMDConnected();
        LOGGER.config("OVRDetectResult.IsOculusHMDConnected = " + connected);
        LOGGER.config("OVRDetectResult.IsOculusServiceRunning = " + detect.IsOculusServiceRunning());
        detect.free();

        if (!connected) {
            LOGGER.info("Oculus Rift not connected");
            return false;
        }

        initialized = true;

        // Set up the HMD
        OVRLogCallback callback = new OVRLogCallback() {
            @Override
            public void invoke(long userData, int level, long message) {
                LOGGER.fine("LibOVR [" + userData + "] [" + level + "] " + memASCII(message));
            }
        };
        OVRInitParams initParams = OVRInitParams.calloc();
        initParams.LogCallback(callback);
        if (ovr_Initialize(initParams) != ovrSuccess) {
            LOGGER.severe("LibOVR Init Failed");
            return false; // TODO fix memory leak - destroy() is not called
        }
        LOGGER.config("LibOVR Version " + ovr_GetVersionString());
        initParams.free();

        // Get access to the HMD
        LOGGER.info("Initialize HMD Session");
        PointerBuffer pHmd = memAllocPointer(1);
        OVRGraphicsLuid luid = OVRGraphicsLuid.calloc();
        if (ovr_Create(pHmd, luid) != ovrSuccess) {
            LOGGER.severe("Failed to create HMD");
            return false; // TODO fix memory leak - destroy() is not called
        }
        session = pHmd.get(0);
        memFree(pHmd);
        luid.free();
        sessionStatus = OVRSessionStatus.calloc();

        // Get the information about the HMD
        LOGGER.fine("Get HMD properties");
        hmdDesc = OVRHmdDesc.malloc();
        ovr_GetHmdDesc(session, hmdDesc);
        if (hmdDesc.Type() == ovrHmd_None) {
            LOGGER.warning("No HMD connected");
            return false; // TODO fix memory leak - destroy() is not called
        }

        resolutionW = hmdDesc.Resolution().w();
        resolutionH = hmdDesc.Resolution().h();

        LOGGER.config("HMD Properties: "
                + "\t Manufacturer: " + hmdDesc.ManufacturerString()
                + "\t Product: " + hmdDesc.ProductNameString()
                + "\t Serial: <hidden>" // + hmdDesc.SerialNumberString() // Hidden for privacy reasons
                + "\t Type: " + hmdDesc.Type()
                + "\t Resolution (total): " + resolutionW + "," + resolutionH);

        if (resolutionW == 0) {
            LOGGER.severe("HMD width=0 : aborting");
            return false; // TODO fix memory leak - destroy() is not called
        }

        // Find the FOV for each eye
        for (int eye = 0; eye < 2; eye++) {
            fovPorts[eye] = hmdDesc.DefaultEyeFov(eye);
        }

        // Get the pose for each eye, and cache it for later.
        for (int eye = 0; eye < 2; eye++) {
            // Create the projection objects
            projections[eye] = OVRMatrix4f.malloc();
            hmdRelativeEyePoses[eye] = new Matrix4f();
            hmdRelativeEyePositions[eye] = new Vector3f();

            // Find the eye render information - we use this in the
            // view manager for giving LibOVR its timewarp information.
            eyeRenderDesc[eye] = OVREyeRenderDesc.malloc();
            ovr_GetRenderDesc(session, eye, fovPorts[eye], eyeRenderDesc[eye]);

            // Get the pose of the eye
            OVRPosef pose = eyeRenderDesc[eye].HmdToEyePose();

            // Get the position and rotation of the eye
            vecO2J(pose.Position(), hmdRelativeEyePositions[eye]);
            Quaternion rotation = quatO2J(pose.Orientation(), new Quaternion());

            // Put it into a matrix for the get eye pose functions
            hmdRelativeEyePoses[eye].loadIdentity();
            hmdRelativeEyePoses[eye].setTranslation(hmdRelativeEyePositions[eye]);
            hmdRelativeEyePoses[eye].setRotationQuaternion(rotation);
        }

        // Recenter the HMD. The game itself should do this too, but just in case / before they do.
        reset();

        // Do this so others relying on our texture size (the GUI in particular) get it correct.
        findHMDTextureSize();

        // Allocate the memory for the tracking state - we actually
        // set it up later, but Input uses it so calloc it now.
        trackingState = OVRTrackingState.calloc();

        // Set up the input
        input = new OculusVRInput(this, session, sessionStatus, trackingState);

        // TODO find some way to get in ovrTrackingOrigin_FloorLevel

        // throw new UnsupportedOperationException("Not yet implemented!");
        return true;
    }
Frame buffers we can draw into.
jme3-vr/src/main/java/com/jme3/input/vr/oculus/OculusVR.java