Esempio n. 1
0
    // 初始化
    private void InitEyeStereoScreens()
    {
        bool useDFT = NvrViewer.USE_DTR && !NvrGlobal.supportDtr;

        if (!USE_DTR || useDFT)
        {
            // 编辑器模式 or 不支持DTR的DFT模式 只生成1个纹理
            RenderTexture rendetTexture = device.CreateStereoScreen();
            rendetTexture.Create();
            int tid = (int)rendetTexture.GetNativeTexturePtr();
            for (int i = 0; i < _texture_count; i++)
            {
                eyeStereoScreens[i] = rendetTexture;
                _texture_ids[i]     = tid;
            }
        }
        else
        {
            for (int i = 0; i < _texture_count; i++)
            {
                eyeStereoScreens[i] = device.CreateStereoScreen();
                eyeStereoScreens[i].Create();
                _texture_ids[i] = (int)eyeStereoScreens[i].GetNativeTexturePtr();
            }
        }
    }
Esempio n. 2
0
    /// @note Each scene load causes an OnDestroy of the current SDK, followed
    /// by and Awake of a new one.  That should not cause the underlying native
    /// code to hiccup.  Exception: developer may call Application.DontDestroyOnLoad
    /// on the SDK if they want it to survive across scene loads.
    void Awake()
    {
        SVR.AtwAPI.BeginTrace("gvrviewer-awake");
        if (instance == null)
        {
            instance = this;
        }
        if (instance != this)
        {
            Debug.LogError("There must be only one GvrViewer object in a scene.");
            UnityEngine.Object.DestroyImmediate(this);
            return;
        }
#if UNITY_IOS
        Application.targetFrameRate = 60;
#endif
        // Prevent the screen from dimming / sleeping
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        GvrViewerInternal.Instance.StereoScreenScale = StereoScreenScale;

        // Set up stereo pre- and post-render stages only for:
        // - Unity without the GVR native integration
        // - In-editor emulator when the current platform is Android or iOS.
        //   Since GVR is the only valid VR SDK on Android or iOS, this prevents it from
        //   interfering with VR SDKs on other platforms.
#if !UNITY_HAS_GOOGLEVR || (UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS))
        //AddPrePostRenderStages();
#endif  // !UNITY_HAS_GOOGLEVR || UNITY_EDITOR

        SVR.AtwAPI.BeginTrace("1");
        InitDevice();
        SVR.AtwAPI.EndTrace();
        //if(stereoScreen == null)
        SVR.AtwAPI.BeginTrace("2");
        stereoScreen = device.CreateStereoScreen();
        SVR.AtwAPI.EndTrace();

        Svr.SvrLog.Log("GvrViewer Awake Resume");
        SVR.AtwAPI.EndTrace();

        Application.lowMemory += OnLowMemory;
    }
Esempio n. 3
0
 /// Return a StereoScreen with sensible default values.
 public RenderTexture CreateStereoScreen()
 {
     return(device.CreateStereoScreen());
 }