Ejemplo n.º 1
0
    void Awake()
    {
        Log.d(LOG_TAG, "Awake()+");
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Log.w(LOG_TAG, "Render already Awaked");
        }
        synchronizer = new RenderThreadSynchronizer();

        if (globalOrigin >= 0 && globalOrigin <= 3)
        {
            _origin = (WVR_PoseOriginModel)globalOrigin;
            Log.d(LOG_TAG, "Has global tracking space " + _origin);
        }

#if UNITY_EDITOR
        if (!Application.isEditor)
#endif
        {
            if (WaveVR_Init.Instance == null || WaveVR.Instance == null)
            {
                Log.e(LOG_TAG, "Fail to initialize");
            }

            // This command can make sure native's render code are initialized in render thread.
            InitializeGraphic(synchronizer);

            // Setup render values
            uint w = 0, h = 0;
            Interop.WVR_GetRenderTargetSize(ref w, ref h);
            sceneWidth  = (float)w;
            sceneHeight = (float)h;

            projRawL = new float[4] {
                0.0f, 0.0f, 0.0f, 0.0f
            };
            projRawR = new float[4] {
                0.0f, 0.0f, 0.0f, 0.0f
            };

            OnIpdChanged(null);
        }

        // May call eglMakeCurrent inside TextureManager()
        if (textureManager == null)
        {
            textureManager = new TextureManager();
        }

        WaveVR_Utils.IssueEngineEvent(WaveVR_Utils.EngineEventID.HMD_INITIAILZED);

        Screen.sleepTimeout         = SleepTimeout.NeverSleep;
        Application.targetFrameRate = targetFPS;
        Log.d(LOG_TAG, "Awake()-");
    }
Ejemplo n.º 2
0
    public static void InitializeGraphic(RenderThreadSynchronizer synchronizer = null)
    {
#if UNITY_EDITOR
        if (Application.isEditor)
        {
            return;
        }
#endif
        WaveVR_Utils.SendRenderEvent(WaveVR_Utils.RENDEREVENTID_INIT_GRAPHIC);
        if (synchronizer != null)
        {
            synchronizer.sync();
        }
    }
Ejemplo n.º 3
0
    void Awake()
    {
        Log.d(LOG_TAG, "Awake()+");
        Log.d(LOG_TAG, "Version of the runtime: " + Application.unityVersion);
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Log.w(LOG_TAG, "Render already Awaked");
        }

        QualitySettings.SetQualityLevel(QualitySettings.GetQualityLevel(), true);
        synchronizer = new RenderThreadSynchronizer();

        if (globalOrigin >= 0 && globalOrigin <= 3)
        {
            _origin = (WVR_PoseOriginModel)globalOrigin;
            Log.d(LOG_TAG, "Has global tracking space " + _origin);
        }

        if (WaveVR_Init.Instance == null || WaveVR.Instance == null)
        {
            Log.e(LOG_TAG, "Fail to initialize");
        }
#if UNITY_EDITOR
        if (!Application.isEditor)
#endif
        {
            // This command can make sure native's render code are initialized in render thread.
            qSColorSpace = QualitySettings.activeColorSpace;
            // InitializeGraphic(synchronizer);

            // Setup render values
            uint w = 0, h = 0;
            Interop.WVR_GetRenderTargetSize(ref w, ref h);
            sceneWidth  = (float)w;
            sceneHeight = (float)h;

            projRawL = new float[4] {
                0.0f, 0.0f, 0.0f, 0.0f
            };
            projRawR = new float[4] {
                0.0f, 0.0f, 0.0f, 0.0f
            };

            WVR_RenderProps_t props = new WVR_RenderProps_t();
            Interop.WVR_GetRenderProps(ref props);
            targetFPS = (int)props.refreshRate;

            OnIpdChanged(null);
        }

        // May call eglMakeCurrent inside TextureManager()
        // First time, we delay InitializeGraphic and construct TextureManager to render loop and skip 16 frame for Unity 2018 version.
        // Otherwise, keep the original flow.
        if (isInitializeGraphic && textureManager == null)
        {
            textureManager = new TextureManager();
        }

        WaveVR_Utils.IssueEngineEvent(WaveVR_Utils.EngineEventID.HMD_INITIAILZED);

        Screen.sleepTimeout         = SleepTimeout.NeverSleep;
        Application.targetFrameRate = targetFPS;
        Log.d(LOG_TAG, "Awake()-");
    }