// Starts the camera capture and returns a Texture2D that will have the camera output as it's content
        public static Texture2D startCameraCapture(bool useFrontCameraIfAvailable, LTCapturePreset capturePreset)
        {
            int width = 0, height = 0;

            switch (capturePreset)
            {
            case LTCapturePreset.Size192x144:
                width  = 192;
                height = 144;
                break;

            case LTCapturePreset.Size640x480:
                width  = 640;
                height = 480;
                break;

            case LTCapturePreset.Size1280x720:
                width  = 1280;
                height = 720;
                break;

            case LTCapturePreset.Size1920x1080:
                width  = 1920;
                height = 1080;
                break;
            }

            // Create texture that will be updated in the plugin code
            var texFormat = LiveTextureBinding.isUsingMetalAPI ? TextureFormat.BGRA32 : TextureFormat.ARGB32;

            _cameraTexture = new Texture2D(width, height, texFormat, false);

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                if (isUsingMetalAPI)
                {
                    _liveTextureStartMetalCameraCapture(useFrontCameraIfAvailable, (int)capturePreset, _cameraTexture.GetNativeTexturePtr());
                }
                else
                {
                    _liveTextureStartCameraCapture(useFrontCameraIfAvailable, (int)capturePreset, _cameraTexture.GetNativeTextureID());
                }
            }

            return(_cameraTexture);
        }
Example #2
0
	// Starts the camera capture and returns a Texture2D that will have the camera output as it's content
    public static Texture2D startCameraCapture( bool useFrontCameraIfAvailable, LTCapturePreset capturePreset )
    {
		// force lower presets for devices that cant handle higher as a safety net
		if( useFrontCameraIfAvailable && capturePreset == LTCapturePreset.Size1280x720 )
			capturePreset = LTCapturePreset.Size640x480;
		
		if( iPhone.generation == iPhoneGeneration.iPhone3G )
			capturePreset = LTCapturePreset.Size192x144;

		var isMediumResDevice = ( iPhone.generation == iPhoneGeneration.iPad1Gen || iPhone.generation == iPhoneGeneration.iPhone3GS );
		if( capturePreset == LTCapturePreset.Size1280x720 && isMediumResDevice )
			capturePreset = LTCapturePreset.Size640x480;
		
    	int width = 0, height = 0;
		switch( capturePreset )
		{
			case LTCapturePreset.Size192x144:
				width = 192;
				height = 144;
				break;
			case LTCapturePreset.Size640x480:
				width = 640;
				height = 480;
				break;
			case LTCapturePreset.Size1280x720:
				width = 1280;
				height = 720;
				break;
		}

        // Create texture that will be updated in the plugin code
		Texture2D texture = new Texture2D( width, height, TextureFormat.ARGB32, false );
		
        if( Application.platform == RuntimePlatform.IPhonePlayer )
			_arStartCameraCapture( useFrontCameraIfAvailable, (int)capturePreset, texture.GetNativeTextureID() );
		
		return texture;
    }