Пример #1
0
        /// <summary>
        /// Changes the output mode to the given one.
        /// </summary>
        /// <param name="newMode">The new mode.</param>
        public void ChangeOutputMode(EngineOutputModeInfo newMode)
        {
            newMode.HostOutput.EnsureEqual(m_targetOutput, $"{nameof(newMode)}.{nameof(newMode.HostOutput)}");

            m_targetOutputMode = newMode;
            m_renderLoop.SetCurrentViewSize(m_targetOutputMode.PixelWidth, m_targetOutputMode.PixelHeight);
            m_renderLoop.ForceViewRefresh();
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FullscreenRenderTarget" /> class.
        /// </summary>
        /// <param name="outputInfo">The target output monitor.</param>
        /// <param name="initialMode">The initial view mode.</param>
        public FullscreenRenderTarget(EngineOutputInfo outputInfo, EngineOutputModeInfo initialMode = default(EngineOutputModeInfo))
        {
            outputInfo.EnsureNotNull(nameof(outputInfo));

            // Check whether we are inside a win.forms application
            System.Windows.Forms.WindowsFormsSynchronizationContext syncContext = SynchronizationContext.Current
                                                                                  as System.Windows.Forms.WindowsFormsSynchronizationContext;
            if (syncContext == null)
            {
                throw new SeeingSharpException($"{nameof(FullscreenRenderTarget)} muss be created inside a Windows.Forms application context!");
            }
            m_syncContext = syncContext;

            //Set confiugration
            m_targetOutput     = outputInfo;
            m_targetOutputMode = initialMode;
            if (m_targetOutputMode.HostOutput != outputInfo)
            {
                m_targetOutputMode = m_targetOutput.DefaultMode;
            }
            m_renderAwaitors = new ThreadSaveQueue <TaskCompletionSource <object> >();

            // Ensure that graphics is initialized
            GraphicsCore.Touch();

            // Create the dummy form
            m_dummyForm = new DummyForm();
            m_dummyForm.SetStyleCustom(ControlStyles.AllPaintingInWmPaint, true);
            m_dummyForm.SetStyleCustom(ControlStyles.ResizeRedraw, true);
            m_dummyForm.SetStyleCustom(ControlStyles.OptimizedDoubleBuffer, false);
            m_dummyForm.SetStyleCustom(ControlStyles.Opaque, true);
            m_dummyForm.SetStyleCustom(ControlStyles.Selectable, true);
            m_dummyForm.SetDoubleBuffered(false);
            m_dummyForm.MouseEnter      += (sender, eArgs) => Cursor.Hide();
            m_dummyForm.MouseLeave      += (sender, eArgs) => Cursor.Show();
            m_dummyForm.HandleDestroyed += OnDummyForm_HandleDestroyed;
            m_dummyForm.GotFocus        += OnDummyForm_GotFocus;
            m_dummyForm.CreateControl();

            // Create and start the renderloop
            m_renderLoop = new RenderLoop(syncContext, this);
            m_renderLoop.Camera.SetScreenSize(m_targetOutputMode.PixelWidth, m_targetOutputMode.PixelHeight);
            m_renderLoop.RegisterRenderLoop();
        }