protected override void OnInitialization(Graphics3DConfiguration config) { if (GraphicsDirect3D11.Device != null) { throw new Graphics3DStateException("Cannot do device initialization: Device already initialized!"); } Device11 device = null; Device11.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, Direct3DConverter11.ConvertToSwapChainDescription(config), out device, out swapChain); //Setup device to main device GraphicsDirect3D11.Device = device; SetupRenderTarget(); }
public static SwapChainDescription ConvertToSwapChainDescription(Graphics3DConfiguration configuration) { SwapChainDescription description = new SwapChainDescription(); description.BufferCount = 1; //TODO description.IsWindowed = !configuration.ScreenConfiguration.FullScreen; description.OutputHandle = configuration.Target; description.SwapEffect = SlimDX.DXGI.SwapEffect.Discard; description.Usage = SlimDX.DXGI.Usage.RenderTargetOutput; description.ModeDescription = new ModeDescription( configuration.ScreenConfiguration.Width, configuration.ScreenConfiguration.Height, new Rational(60, 1), //TODO Hz ConvertToFormat(configuration.ScreenConfiguration.ColorMode)); description.SampleDescription = new SampleDescription( 1, //TODO 0); description.Flags = SwapChainFlags.AllowModeSwitch; return description; }
public static SwapChainDescription ConvertToSwapChainDescription(Graphics3DConfiguration configuration) { SwapChainDescription description = new SwapChainDescription(); description.BufferCount = 1; //TODO description.IsWindowed = !configuration.ScreenConfiguration.FullScreen; description.OutputHandle = configuration.Target; description.SwapEffect = SlimDX.DXGI.SwapEffect.Discard; description.Usage = SlimDX.DXGI.Usage.RenderTargetOutput; description.ModeDescription = new ModeDescription( configuration.ScreenConfiguration.Width, configuration.ScreenConfiguration.Height, new Rational(60, 1), //TODO Hz ConvertToFormat(configuration.ScreenConfiguration.ColorMode)); description.SampleDescription = new SampleDescription( 1, //TODO 0); description.Flags = SwapChainFlags.AllowModeSwitch; return(description); }
static void Main() { Form win = new Form(); win.KeyDown += ((sender, e) => { win.Close(); }); win.Width = G3D_WIDTH; win.Height = G3D_HEIGHT; win.StartPosition = FormStartPosition.CenterScreen; win.Text = "Graphics 3D - Demo"; Graphics3DConfiguration config = new Graphics3DConfiguration(); config.Target = win.Handle; config.ScreenConfiguration.ColorMode = ColorMode.Bit32; config.ScreenConfiguration.FullScreen = true; config.ScreenConfiguration.Height = G3D_HEIGHT; config.ScreenConfiguration.Width = G3D_WIDTH; Graphics3DApplication.Initialize += new Action <Graphics3DDevice>(Graphics3DApplication_Initialize); Graphics3DApplication.Dispose += new Action <Graphics3DDevice>(Graphics3DApplication_Dispose); Graphics3DApplication.Run(win, Graphics3DSystem.InitializeSystem(config, "Direct3D9")); }