Search in sources :

Example 1 with VR_IVRCompositor_FnTable

use of com.jme3.system.jopenvr.VR_IVRCompositor_FnTable in project jmonkeyengine by jMonkeyEngine.

the class OpenVR method initVRCompositor.

@Override
public boolean initVRCompositor(boolean allowed) {
    // clear the error store
    hmdErrorStore.setValue(0);
    if (allowed && vrsystemFunctions != null) {
        IntByReference intptr = JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRCompositor_Version, hmdErrorStore);
        if (intptr != null) {
            if (intptr.getPointer() != null) {
                compositorFunctions = new VR_IVRCompositor_FnTable(intptr.getPointer());
                if (compositorFunctions != null && hmdErrorStore.getValue() == 0) {
                    compositorFunctions.setAutoSynch(false);
                    compositorFunctions.read();
                    if (environment.isSeatedExperience()) {
                        compositorFunctions.SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseSeated);
                    } else {
                        compositorFunctions.SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding);
                    }
                    logger.config("OpenVR Compositor initialized");
                } else {
                    logger.severe("OpenVR Compositor error: " + hmdErrorStore.getValue());
                    compositorFunctions = null;
                }
            } else {
                logger.log(Level.SEVERE, "Cannot get valid pointer for generic interface \"" + JOpenVRLibrary.IVRCompositor_Version + "\", " + OpenVRUtil.getEVRInitErrorString(hmdErrorStore.getValue()) + " (" + hmdErrorStore.getValue() + ")");
                compositorFunctions = null;
            }
        } else {
            logger.log(Level.SEVERE, "Cannot get generic interface for \"" + JOpenVRLibrary.IVRCompositor_Version + "\", " + OpenVRUtil.getEVRInitErrorString(hmdErrorStore.getValue()) + " (" + hmdErrorStore.getValue() + ")");
            compositorFunctions = null;
        }
    }
    if (compositorFunctions == null) {
        logger.severe("Skipping VR Compositor...");
        if (vrsystemFunctions != null) {
            vsyncToPhotons = vrsystemFunctions.GetFloatTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float, hmdErrorStore);
        } else {
            vsyncToPhotons = 0f;
        }
    }
    return compositorFunctions != null;
}
Also used : IntByReference(com.sun.jna.ptr.IntByReference) VR_IVRCompositor_FnTable(com.jme3.system.jopenvr.VR_IVRCompositor_FnTable)

Aggregations

VR_IVRCompositor_FnTable (com.jme3.system.jopenvr.VR_IVRCompositor_FnTable)1 IntByReference (com.sun.jna.ptr.IntByReference)1