   Creating fullscreen D3D apps with C#
  I''m having a little trouble getting fullscreen apps to run in D3D.  I''m assuming this is what I have to do to link the refresh rate with the monitor''s refresh rate.  Here''s the code I have:   // first I create the windowthis.ClientSize = new System.Drawing.Size(1600,1200);System.Windows.Forms.Cursor.Hide();this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;this.WindowState = System.Windows.Forms.FormWindowState.Maximized;// then I create the device for D3D:presentParams.Windowed=true; presentParams.SwapEffect = SwapEffect.Discard; // Discard the frames presentParams.EnableAutoDepthStencil = true; // Turn on a Depth stencilpresentParams.AutoDepthStencilFormat = DepthFormat.D16; // And the stencil formatdevice = new Device(0, DeviceType.Hardware, formToUse, CreateFlags.HardwareVertexProcessing , presentParams); //Create a devicedevice.DeviceReset += new System.EventHandler(onResetDevice);I changed the presentParams.Windowed to false, but that gives me a runtime error on the device creation line.  Anyone know what to do to get it to run full screen and sync the refresh rate?--Vic-- 
  For full-screen you must set the PresentParameters.BackBufferFormat to the format you want. ;  I added the following line:presentParams.BackBufferFormat = Microsoft.DirectX.Direct3D.Format.D16;but that didn''t seem to quite solve the problem.--Vic-- ;  You must also set width and height of the backbuffer in fullscreen mode. In windowed mode, when you leave them default (zero) they default to the window client size, which is fine, but in fullscreen you need to specify them. ;quote:Original post by Roof Top Pew Wee  I added the following line:presentParams.BackBufferFormat = Microsoft.DirectX.Direct3D.Format.D16;but that didn''t seem to quite solve the problem.--Vic--   That would be a depth buffer format. Provide a color mode (AxRxGxBx). And like the other poster said, specify BackBufferWidth and BackBufferHeight. ;  Well, I''m making a little progress.  My code currently looks like this:presentParams.Windowed=false; presentParams.SwapEffect = SwapEffect.Discard; // Discard the frames presentParams.EnableAutoDepthStencil = true; // Turn on a Depth stencilpresentParams.AutoDepthStencilFormat = DepthFormat.D16; // And the stencil formatpresentParams.BackBufferFormat = Microsoft.DirectX.Direct3D.Format.R5G6B5;presentParams.BackBufferHeight = 1200;presentParams.BackBufferWidth = 1600;presentParams.BackBufferCount = 1;device = new Device(0, DeviceType.Hardware, formToUse, CreateFlags.HardwareVertexProcessing , presentParams); //Create a deviceBut now, my program just freezes.  Doesn''t draw anything on the screen.  So here are some of my questions:1.  Is this the correct way to make a full screen app?this.ClientSize = new System.Drawing.Size(1600,1200);System.Windows.Forms.Cursor.Hide();this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;this.WindowState = System.Windows.Forms.FormWindowState.Maximized;Or is this just a maximized window with no border?  Not sure if there is even a difference.2.  Instead of R5G6B5 I put A1R5G5B5, but that threw the error, making me think my GFX card can''t handle that format.  I got a GeForce4 MX440, and I''m assuming this is the format I''d need to do stuff with Alpha, like load up some .tgas with transparent pixels.  I suppose I can look into this after I get fullscreen to simply work.3.  My rendering loop simply does this:device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);device.BeginScene();// render stuffdevice.EndScene();// Update the screendevice.Present();This worked fine in my windowed mode.  Do I have to do anything now that I''m working with back buffers, like "flip" them every scene like in DDraw?  --Vic--;  I would start with 640x480, just to see if it works. 1600x1200 is a big big, and requires this to be a valid mode (in other words, the monitor definition must support 1600x1200).You don''t need to create a 1600x1200 window, even if you have a 400x300 window created you can use that to create a fullscreen device that does 1024x768.You''re right, alpha isn''t a part of the backbuffer, so X8R8G8B8 is a valid backbuffer format, but A8R8G8B8 is only valid for textures (although you can specify it as backbuffer format).After creating the device, everything else works the same. Present() will handle flipping/discarding. ;  I have lowered the resolution that I am using, but I get the frozen sceen.  The screen clicks, for when the resolution change occurs, and then it shows a my desktop with a black square taking up most of the screen, but everything is frozen.  I have to CTRL ALT DEL to get out of the program.  Any ideas, anyone?--Vic-- ;  Everything looks fine now, or at the very least it is consitent with what I do.One question though? What does you onResetDevice handler do? It is possible you are getting stuck in an infinite reset-handler-reset loop?The handler is called immediately after calling CreateDevice when running in fullscreen mode. It is NOTcalled when running in windowed mode for whatever reason. That may be your problem. If anything try commenting out the line where you add the DeviceReset event handler and see if that helps.   [edited by - Entz on February 16, 2004 4:30:29 PM];  Still to no avail.  my onResetDevice does nothing. Just an empty function.--Vic-- 