示例#1
0
        /// <summary>
        /// Changes the display parameters of the Managed Direct3D Wrapper for the render window
        /// </summary>
        /// <param name="renderWindow">Window to render to.</param>
        /// <param name="screenWidth">Width of the screen in pixels.</param>
        /// <param name="screenHeight">Height of the screen in pixels.</param>
        /// <param name="vsync">Should the renderer wait for a vsync before drawing?</param>
        /// <returns>true if successful, false otherwise.</returns>
        public bool Resize(Control renderWindow, int screenWidth, int screenHeight, bool vsync)
        {
            try
            {
                // Now  setup our D3D present parameters
                m_PresentParams = new PresentParameters( );
                m_PresentParams.BackBufferWidth  = screenWidth;
                m_PresentParams.BackBufferHeight = screenHeight;
                // taking out option for fullscreen mode
                //presentParams.BackBufferFormat = (isWindowed) ? Format.Unknown : Format.R5G6B5;
                m_PresentParams.BackBufferFormat   = Format.Unknown;
                m_PresentParams.BackBufferCount    = 1;
                m_PresentParams.MultiSample        = MultiSampleType.None;
                m_PresentParams.MultiSampleQuality = 0;
                m_PresentParams.SwapEffect         = SwapEffect.Copy;        // Discard;
                m_PresentParams.DeviceWindow       = renderWindow;
                // taking out option for fullscreen mode
                //presentParams.Windowed = isWindowed;
                m_PresentParams.Windowed = true;
                m_PresentParams.EnableAutoDepthStencil    = false;
                m_PresentParams.FullScreenRefreshRateInHz = 0;
                m_PresentParams.PresentationInterval      = (vsync) ? PresentInterval.Default : PresentInterval.Immediate;

                // Find the swap chain
                SetActiveRenderTarget(renderWindow);

                m_Font.OnLostDevice( );
                m_Sprite.OnLostDevice( );
                m_Device.Reset(m_PresentParams);
                m_Sprite.OnResetDevice( );
                m_Font.OnResetDevice( );

                m_RenderTargets[m_ActiveTarget].Reset(m_Device, m_PresentParams);
            }
            catch (Exception)
            {
                DialogResult r = MessageBox.Show("Failed to change the render window", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                return(false);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Handles resetting the device (Private utility function).
        /// </summary>
        private void Reset()
        {
            font.OnLostDevice();
            line.OnLostDevice();
            sprite.OnLostDevice();

            device.Reset(presentParams);

            font.OnResetDevice();
            sprite.OnResetDevice();
            line.OnResetDevice();
        }
示例#3
0
        ///// <summary>
        ///// Retrieves an appropriate multi sample format from the manager.
        ///// </summary>
        //private static MultiSampleType GetMultiSampleType(int adapter)
        //{
        //  if (Manager.CheckDeviceMultiSampleType(adapter, DeviceType, Format.X8R8G8B8, !FullScreen, MultiSampleType.FourSamples))
        //    return MultiSampleType.FourSamples;
        //  else if (Manager.CheckDeviceMultiSampleType(adapter, DeviceType, Format.X8R8G8B8, !FullScreen, MultiSampleType.TwoSamples))
        //    return MultiSampleType.TwoSamples;
        //  else if (Manager.CheckDeviceMultiSampleType(adapter, DeviceType, Format.X8R8G8B8, !FullScreen, MultiSampleType.NonMaskable))
        //    return MultiSampleType.NonMaskable;
        //  else
        //    return MultiSampleType.None;
        //}

        public static void PerformDeviceReset(int sizeX, int sizeY)
        {
            int res;

            MdxRender.Device.CheckCooperativeLevel(out res);

            //clean up unmanaged resources
            fontFPS.OnLostDevice();
            DebugFont.OnLostDevice();
            tagPool.OnLostDevice();
            console.OnLostDevice();
            SelectTool.OnLostDevice();
            Billboard.OnLostDevice();
            foreach (SceneState scene in scenes)
            {
                scene.Instance.OnDeviceLost();
            }

            //reset the device with new viewport dimensions
            pp.BackBufferWidth  = sizeX;
            pp.BackBufferHeight = sizeY;
            //MdxRender.Device.Reset(pp);

            //re-create unmanaged resources
            fontFPS.OnResetDevice();
            DebugFont.OnResetDevice();
            tagPool.OnResetDevice();
            console.OnResetDevice();
            SelectTool.OnResetDevice();
            Billboard.OnResetDevice();
            foreach (SceneState scene in scenes)
            {
                scene.Instance.OnDeviceReset();
            }

            //re-init any state variables we need
            SetupDevice();
            UpdateViewTransform();
            MdxRender.Device.Transform.World = Matrix.Identity;
            MdxRender.Device.Transform.View  = camera.GetViewMatrix();
        }
示例#4
0
 public void OnLostDevice()
 {
     font.OnLostDevice();
 }