Example #1
0
        // Returns whether the exit was prevented.
        bool PreventExit()
        {
            if (LoopTerminating == null) return false;

            var preventArgs = new PreventEventArgs();
            LoopTerminating(preventArgs);

            return preventArgs.Prevent;
        }
Example #2
0
        public void RunLoop(IWindow mainWindow)
        {
            if (!initialized)
                throw new NotSupportedException("Starting a loop without creating a device and primary swap chain is not supported by ObjectGl4 DefaultEye");
            if (!(mainWindow is DefaultWindow))
                throw new NotSupportedException("For ObjectGL4 DefaultEye, 'loopWindow' must be of type " + typeof(DefaultWindow).FullName);

            loopTimer = new LoopTimer();

            loopWindow = (DefaultWindow)mainWindow;
            loopWindow.RenderFrame += (sender, args) =>
            {
                loopTimer.UpdateTime();
                if (NewFrame != null) NewFrame(loopTimer.RealTime);
            };
            loopWindow.Closing += (sender, args) =>
            {
                var e = new PreventEventArgs();
                if (LoopTerminating != null) LoopTerminating(e);
                if (e.Prevent)
                    args.Cancel = true;
            };
            loopWindow.Run();
        }