Esempio n. 1
0
        public DefaultDevice(DefaultEye eye, CAdapter adapter, DeviceInitializationFlags flags,
            WindowHandle windowHandle, ref SwapChainDescription implicitSwapChainDescription,
            IFileSystem fileSystem)
        {
            this.eye = eye;
            this.adapter = adapter;
            this.flags = flags;

            primaryWindow = new DefaultWindow(this, windowHandle.ClientWidth, windowHandle.ClientHeight,
                ref implicitSwapChainDescription, windowHandle.Title, GameWindowFlags.Default,
                ((COutput)adapter.Outputs[0]).GLDisplayDevice, ref glContext);

            creator = new CDeviceChildCreator(this);
            immediateContext = new CDeviceContext(this, glContext);
        }
Esempio n. 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();
        }