Esempio n. 1
0
        /// <summary>
        /// The main render loop callback that is cached in a delegate and is invoked to process main game loop.
        /// </summary>
        private void RenderLoopCallback()
        {
            if (Exiting)
            {
                CompositionTarget.Rendering -= OnCompositionTargetRendering;
                if (element != null)
                {
                    element.Dispose();
                    element = null;
                }
                return;
            }

            // run render loop once
            RunCallback();
            // mark completion of drawing operations
            deviceContext.End(queryForCompletion);

            // wait until drawing completes
            Bool completed;

            while (!(deviceContext.GetData(queryForCompletion, out completed) &&
                     completed))
            {
                Thread.Yield();
            }

            // syncronize D3D surface with WPF
            if (!element.IsDisposed)
            {
                element.InvalidateRendering();
            }
        }