Beispiel #1
0
        private void Tick()
        {
            var now       = _stopWatch.ElapsedMilliseconds / 1000.0f;
            var deltaTime = now - _lastUpdate;

            _averageDeltaTime += deltaTime;
            if (_frameCounter == _framesToAverage)
            {
                var averageFrameTime = _averageDeltaTime / _frameCounter;

                Window.Title = $"Xacor delta.avg: {averageFrameTime * 1000.0f:000.00}ms, delta.abs: {deltaTime * 1000.0f:000.00}ms, fps: {1.0f / averageFrameTime:0000}";

                _averageDeltaTime = 0.0f;
                _frameCounter     = 0;
            }

            Update(deltaTime);
            _lastUpdate = now;
            BeginDraw();
            Draw();
            EndDraw();

            _swapchain.Present();

            _frameCounter++;
        }
Beispiel #2
0
        void render()
        {
            // ConsoleLogger.logDebug( "ContentBase.render" );
            var rtv = swapChain?.GetCurrentBackBufferRTV();

            Debug.Assert(null != rtv);
            ComUtils.assign(ref cachedRtv, rtv);
            var dsv = swapChain?.GetDepthBufferDSV();

            Debug.Assert(null != dsv);
            ComUtils.assign(ref cachedDsv, dsv);
            if (null == rtv || null == dsv)
            {
                return;
            }

            animation?.update();
            // ConsoleLogger.logDebug( "ContentBase.render 2" );
            backBufferTexture = rtv;
            try
            {
                // MicroProfiler.start();
                scene.render(this, rtv, dsv);
                m_cursor?.render();

                string screenshot = System.Threading.Interlocked.Exchange(ref screenshotLocation, null);
                if (null != screenshot)
                {
                    using (var dev = device)
                        using (var tx = rtv.GetTexture())
                            ScreenGrabber.saveTexture(dev, context, tx, screenshot);
                }
                // MicroProfiler.key( "done rendering" );
            }
            finally
            {
                backBufferTexture = null;
            }
            swapChain.Present(1);
            // MicroProfiler.finish();
        }