Exemple #1
0
        public virtual void Draw()
        {
            if (!CanDoUpdates())
            {
                return;
            }

            PreDrawCallback?.Invoke(this, new EventArgs());

            UpdateTexture();

            if (DashboardOverlay != null && DashboardOverlay.IsVisible())
            {
                DashboardOverlay.SetTexture(ref _textureData);
                DashboardOverlay.Show();
            }

            if (InGameOverlay != null && InGameOverlay.IsVisible())
            {
                InGameOverlay.SetTexture(ref _textureData);
                InGameOverlay.Show();
            }

            PostDrawCallback?.Invoke(this, new EventArgs());
        }
        public static void RunOverlays()
        {
            Stopwatch fpsWatch    = new Stopwatch();
            VREvent_t eventData   = new VREvent_t();
            uint      vrEventSize = (uint)Marshal.SizeOf <VREvent_t>();

            while (!_doStop)
            {
                fpsWatch.Restart();

                UpdatePoses();

                PreUpdateCallback?.Invoke(null, null);

                foreach (WebKitOverlay overlay in Overlays)
                {
                    overlay.Update();
                }
                while (OpenVR.System.PollNextEvent(ref eventData, vrEventSize))
                {
                    SteamVR_Event.Send(((EVREventType)eventData.eventType).ToString().Replace("VREvent_", ""), eventData);
                }

                PostUpdateCallback?.Invoke(null, null);

                PreDrawCallback?.Invoke(null, null);

                foreach (WebKitOverlay overlay in Overlays)
                {
                    overlay.Draw();
                }

                PostDrawCallback?.Invoke(null, null);

                fpsWatch.Stop();
                Thread.Sleep(fpsWatch.ElapsedMilliseconds >= _frameSleep ? 0 : (int)(_frameSleep - fpsWatch.ElapsedMilliseconds));
            }

            CefShutdown();
        }
        public virtual void Draw()
        {
            if (!CanDoUpdates())
            {
                return;
            }

            PreDrawCallback?.Invoke(this, new EventArgs());

            var newbitmap = _browser.ScreenshotAsync().Result;

            if (newbitmap != null)
            {
                if (_bitmap != null)
                {
                    _bitmap.Dispose();
                }
                _bitmap           = newbitmap;
                _browserDidUpdate = true;
            }
            UpdateTexture();

            if (_bitmap != null)
            {
                if (DashboardOverlay != null && DashboardOverlay.IsVisible())
                {
                    DashboardOverlay.SetTexture(ref _textureData);
                    DashboardOverlay.Show();
                }

                if (InGameOverlay != null && InGameOverlay.IsVisible())
                {
                    InGameOverlay.SetTexture(ref _textureData);
                    InGameOverlay.Show();
                }
            }

            PostDrawCallback?.Invoke(this, new EventArgs());
        }