Beispiel #1
0
        private void RenderCore(int syncInterval, PresentFlags presentFlags, float lastFrameTimeInSecond)
        {
            try
            {
                // Freeze logic when render time is slow
                if (lastFrameTimeInSecond < 0.2f)
                {
                    XResource.UpdateLogic(RenderTimer.DurationSinceLastFrame);
                    OnUpdateLogic(lastFrameTimeInSecond);
                }

                XResource.RenderTarget.BeginDraw();
                {
                    OnDraw(XResource.RenderTarget);
                    OnPostDraw();
                }
                XResource.RenderTarget.EndDraw();

                XResource.SwapChain.Present(syncInterval, presentFlags);
            }
            catch (SharpGenException e)
            {
                unchecked
                {
                    const int DeviceRemoved = (int)0x887a0005;
                    const int DeviceReset   = (int)0x887A0007;
                    if (e.ResultCode == DeviceRemoved || e.ResultCode == DeviceReset)
                    {
                        OnReleaseDeviceSizeResources();
                        OnReleaseDeviceResources();
                        XResource.ReleaseDeviceResources();
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }