G2A Many GEOs
SHARE
TWEET

Ritesh

a guest Jan 5th, 2008 459 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public bool InitializeGraphics()
  2.         {
  3.                 try
  4.                 {
  5.                 Cursor.Hide();
  6.                
  7.                 AdapterInformation ai = Manager.Adapters.Default;
  8.                 Caps caps = Manager.GetDeviceCaps(ai.Adapter, DeviceType.Hardware);
  9.  
  10.                 presentParams.Windowed = !doFullscreen;
  11.                 presentParams.SwapEffect = SwapEffect.Discard; // Discard the frames
  12.                         presentParams.EnableAutoDepthStencil = true; // Turn on a Depth stencil
  13.                         presentParams.AutoDepthStencilFormat = DepthFormat.D16; // And the stencil format
  14.  
  15.                 presentParams.BackBufferCount = 1;
  16.                 presentParams.BackBufferWidth = m_dwWidth;                                      //screen width
  17.                 presentParams.BackBufferHeight = m_dwHeight;                                    //screen height
  18.                 presentParams.BackBufferFormat = ai.CurrentDisplayMode.Format;                          //color depth
  19.                
  20.                 presentParams.DeviceWindow = this;
  21.                 presentParams.MultiSample = MultiSampleType.None;                               //anti-aliasing
  22.                 presentParams.PresentationInterval  = PresentInterval.Immediate; //don't wait... draw right away
  23.  
  24.                 // Check if gfx card can do HW T&L
  25.                 CreateFlags flags = CreateFlags.SoftwareVertexProcessing;
  26.                 if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
  27.                     flags = CreateFlags.HardwareVertexProcessing;
  28.  
  29.                 // Check if gfx card can do rasterization etc
  30.                 if (caps.DeviceCaps.SupportsPureDevice)
  31.                     flags |= CreateFlags.PureDevice;
  32.  
  33.                 device = new Device(ai.Adapter, DeviceType.Hardware, this, flags, presentParams); //Create a device
  34.                 device.DeviceReset += new System.EventHandler(this.OnResetDevice);
  35.                 // Add event handler to cancel device resize
  36.                 device.DeviceResizing += new System.ComponentModel.CancelEventHandler(OnDeviceResizing);
  37.  
  38.                 this.OnCreateDevice(device, null);
  39.                         this.OnResetDevice(device, null);
  40.                        
  41.                 return true;
  42.                 }
  43.                 catch (DirectXException)
  44.                 {
  45.                         // Catch any errors and return a failure
  46.                         return false;
  47.                 }
  48.         }
  49.  
  50.         void OnDeviceResizing(object sender, System.ComponentModel.CancelEventArgs e)
  51.         {
  52.             Device device = sender as Device;
  53.  
  54.             // Don't let the device automatically resize itself to the window dimensions in fullscreen mode
  55.             // This is needed because at this point the application hasn't gained control of the device yet, leading to a crash.
  56.             e.Cancel = !device.PresentationParameters.Windowed;
  57.         }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top