public void Create(bool fullscreen, int width, int height, bool audio) { GraphicsDevice Device; Window = new Form(); Window.ClientSize = new System.Drawing.Size(width, height); Window.Show(); //GraphicsAdapter.DefaultAdapter. PresentationParameters param = new PresentationParameters(); param.BackBufferCount = 1; //param.BackBufferFormat=SurfaceFormat.Rgba32; param.BackBufferHeight = height; param.BackBufferWidth = width; //param.FullScreenRefreshRateInHz=60; param.IsFullScreen = fullscreen; param.PresentFlag = PresentFlag.None; param.SwapEffect = fullscreen?SwapEffect.Flip:SwapEffect.Discard; param.PresentationInterval = PresentInterval.One; param.AutoDepthStencilFormat = DepthFormat.Depth16; param.BackBufferFormat = SurfaceFormat.Bgr32; param.EnableAutoDepthStencil = true; param.PresentationInterval = PresentInterval.Immediate; try { Device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, Window.Handle, CreateOptions.HardwareVertexProcessing, param); } catch (InvalidCallException e) { System.Console.WriteLine(e.Message); System.Console.WriteLine(e.ErrorCode); throw e; } Device.Clear(new Color(0, 0, 0, 1)); Device.Present(); renderer = new XnaRenderer(Device); }
public void Create(bool fullscreen, int width, int height, bool audio) { GraphicsDevice Device; Window = new Form(); Window.ClientSize = new System.Drawing.Size(width, height); Window.Show(); //GraphicsAdapter.DefaultAdapter. PresentationParameters param=new PresentationParameters(); param.BackBufferCount=1; //param.BackBufferFormat=SurfaceFormat.Rgba32; param.BackBufferHeight=height; param.BackBufferWidth=width; //param.FullScreenRefreshRateInHz=60; param.IsFullScreen=fullscreen; param.PresentFlag=PresentFlag.None; param.SwapEffect=fullscreen?SwapEffect.Flip:SwapEffect.Discard; param.PresentationInterval=PresentInterval.One; param.AutoDepthStencilFormat = DepthFormat.Depth16; param.BackBufferFormat = SurfaceFormat.Bgr32; param.EnableAutoDepthStencil = true; param.PresentationInterval = PresentInterval.Immediate; try { Device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, Window.Handle, CreateOptions.HardwareVertexProcessing, param); } catch (InvalidCallException e) { System.Console.WriteLine(e.Message); System.Console.WriteLine(e.ErrorCode); throw e; } Device.Clear(new Color(0, 0, 0, 1)); Device.Present(); renderer = new XnaRenderer(Device); }