Java Code Examples for com.sun.jna.ptr.IntByReference#getPointer()

The following examples show how to use com.sun.jna.ptr.IntByReference#getPointer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenVR.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Initialize the headset camera.
 * @param allowed <code>true</code> is the use of the headset camera is allowed and <code>false</code> otherwise.
 */
public void initCamera(boolean allowed) {
  hmdErrorStore.setValue(0); // clear the error store
  
  if( allowed && vrsystemFunctions != null ) {
    IntByReference intptr = JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRTrackedCamera_Version, hmdErrorStore);
	  if (intptr != null){
	    cameraFunctions = new VR_IVRTrackedCamera_FnTable(intptr.getPointer());
	    if(cameraFunctions != null && hmdErrorStore.getValue() == 0 ){
	      cameraFunctions.setAutoSynch(false);
	        cameraFunctions.read();
	        logger.config("OpenVR Camera initialized");
	    }
	  }
   }
}
 
Example 2
Source File: OpenVR.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean initVRCompositor(boolean allowed) {
    hmdErrorStore.setValue(0); // clear the error store
    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;
}