Exemple #1
0
        void OnEnable()
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            IntPtr tempPtr = Marshal.StringToHGlobalAnsi(PROPERTY_ISVR9);
            bVR9 = Composer.DpnuGetIntValue(tempPtr, 0) == 0? false: true;
            IntPtr tempPtrQcom = Marshal.StringToHGlobalAnsi(PROPERTY_ISQCOM);
            bQCOM = Composer.DpnuGetIntValue(tempPtrQcom, 0) == 0? false: true;
            Debug.Log("DpnDevice Init bVR9 " + bVR9 + " bQCOM " + bQCOM);
#endif
            ConfigEngine.Init();
            if (!bVR9)
            {
                _buffers.Init
                    (DpnManager.eyeTextureDepth
                    , DpnManager.eyeTextureFormat
                    , DpnManager.DeviceInfo.resolution_x
                    , DpnManager.DeviceInfo.resolution_y);
#if UNITY_ANDROID && !UNITY_EDITOR
#else
                IntPtr[] buf_ptr = new IntPtr[(int)dpncEYE.NUM]
                {
                    _buffers.GetEyeTexturePtr(dpncEYE.LEFT)
                    , _buffers.GetEyeTexturePtr(dpncEYE.RIGHT)
                };
                Composer.SetTextures(buf_ptr[0], dpncEYE.LEFT);
                Composer.SetTextures(buf_ptr[1], dpncEYE.RIGHT);
#endif
            }
            //
#if !UNITY_ANDROID
            string pcScreenOutput = "pcScreenOutput";
#if UNITY_EDITOR
            IntPtr OutputPtr = Marshal.StringToHGlobalAnsi(pcScreenOutput);
            Composer.DpnuSetIntValue(OutputPtr, (int)dpncOutputMode.NONE);
            Marshal.FreeHGlobal(OutputPtr);
#else
            IntPtr OutputPtr = Marshal.StringToHGlobalAnsi(pcScreenOutput);
            Composer.DpnuSetIntValue(OutputPtr, (int)DpnManager.pcScreenOutputMode);
            Marshal.FreeHGlobal(OutputPtr);
#endif
#endif

            Camera.onPreRender += CameraPreRender;
            Camera.onPreCull   += CameraPreCull;

            if (DpnManager.DPVRPointer)
            {
                gameObject.AddComponent <DpnPointerManager>();
            }

            //cameras
            StartCoroutine(CallbackCoroutine());
        }
        /// <summary>
        /// invoked by DpnPostRender
        /// </summary>
        public void _EndEye(Camera cam)
        {
            dpncEYE eye     = ((PLUGIN_EVENT_TYPE)cam.depth == PLUGIN_EVENT_TYPE.RightEyeEndFrame) ? dpncEYE.RIGHT : dpncEYE.LEFT;
            dpnRect view    = new dpnRect(new Rect(0, 0, Camera.current.targetTexture.width, Camera.current.targetTexture.height));
            IntPtr  tempPtr = Marshal.AllocHGlobal(Marshal.SizeOf(view));

            Marshal.StructureToPtr(view, tempPtr, false);
            Composer.PostRender(RENDER_EVENT.Postnontransparent, (int)tempPtr);
#if UNITY_5_6_0 || UNITY_5_6_1
            IntPtr eyeTexturePtr = prev;
            prev = Camera.current.targetTexture.GetNativeTexturePtr();
#else
            IntPtr eyeTexturePtr = Camera.current.targetTexture.GetNativeTexturePtr();
#endif
            Composer.SetTextures(eyeTexturePtr, eye);
        }
Exemple #3
0
        /// <summary>
        /// invoked by DpnPostRender
        /// </summary>
        public void _EndEye(Camera cam)
        {
            dpncEYE eye     = ((PLUGIN_EVENT_TYPE)cam.depth == PLUGIN_EVENT_TYPE.RightEyeEndFrame) ? dpncEYE.RIGHT : dpncEYE.LEFT;
            dpnRect view    = new dpnRect(new Rect(0, 0, Camera.current.targetTexture.width, Camera.current.targetTexture.height));
            IntPtr  tempPtr = Marshal.AllocHGlobal(Marshal.SizeOf(view));

            Marshal.StructureToPtr(view, tempPtr, false);
            if (!DpnDevice.bQCOM)   // XR1: support texture clamp to board, don't need app fill edge as black. Plugin use partial clear to filledge, which cause enable foveated rendering failed
            {
                Composer.PostRender(RENDER_EVENT.Postnontransparent, (int)tempPtr);
            }
#if UNITY_5_6_0 || UNITY_5_6_1
            IntPtr eyeTexturePtr = prev;
            prev = Camera.current.targetTexture.GetNativeTexturePtr();
#else
            IntPtr eyeTexturePtr = Camera.current.targetTexture.GetNativeTexturePtr();
#endif
            Composer.SetTextures(eyeTexturePtr, eye);
        }
        private void DeviceUpdate()
        {
            if (!bVR9)
            {
                if (false == _buffers.SwapBuffers())
                {
#if UNITY_ANDROID && !UNITY_EDITOR
#else
                    Debug.Log("DPVR texture is recreated.");
                    IntPtr[] buf_ptr = new IntPtr[(int)dpncEYE.NUM]
                    {
                        _buffers.GetEyeTexturePtr(dpncEYE.LEFT)
                        , _buffers.GetEyeTexturePtr(dpncEYE.RIGHT)
                    };
                    Composer.SetTextures(buf_ptr[0], dpncEYE.LEFT);
                    Composer.SetTextures(buf_ptr[1], dpncEYE.RIGHT);
#endif
                }
            }
        }