pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

C# pastebin - collaborative debugging tool View Help


Posted by Ritesh on Sat 5 Jan 19:46
report abuse | download | new post

  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.         }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post