/// <summary> /// Creates a new instance of <see cref="D3D10RenderSystemProvider"/> using the adapter index. /// </summary> /// <param name="adapterIndex">Index of the adapter to use when creating the underlying device</param> public D3D10RenderSystemProvider(int adapterIndex) { //Create the DXGI Factory DXGI.Factory factory = new DXGI.Factory(); //Create the device DXGI.Adapter adapter = factory.GetAdapter(adapterIndex); D3D.Device device = new D3D.Device(adapter, D3D.DriverType.Hardware, D3D.DeviceCreationFlags.None); //Enumerate adapters List <IGraphicsAdapter> adapterList = new List <IGraphicsAdapter>(); int adapterCount = factory.GetAdapterCount(); for (int i = 0; i < adapterCount; i++) { adapterList.Add(new D3D10GraphicsAdapter(device, factory, i)); } _adapters = new ReadOnlyList <IGraphicsAdapter>(adapterList); //Create the renderer _renderer = new D3D10Renderer(factory, device, (D3D10GraphicsAdapter)adapterList[adapterIndex]); //Create default content manager _content = new ContentManager(new EmbeddedResourceLocator(Tesla.Direct3D10.DefaultContent.ResourceManager)); _content.UseDefaultContent = false; }
/// <summary> /// Enumerates all the available adapters for the render system. This should /// only be used to identify which adapter to use at startup. /// </summary> /// <returns>List of available adapters</returns> public static ReadOnlyList <IGraphicsAdapter> EnumerateAdapters() { //Create the DXGI Factory DXGI.Factory factory = new DXGI.Factory(); //Create the device DXGI.Adapter adapter = factory.GetAdapter(0); D3D.Device device = new D3D.Device(adapter, D3D.DriverType.Hardware, D3D.DeviceCreationFlags.None); //Enumerate adapters List <IGraphicsAdapter> adapterList = new List <IGraphicsAdapter>(); int adapterCount = factory.GetAdapterCount(); for (int i = 0; i < adapterCount; i++) { adapterList.Add(new D3D10GraphicsAdapter(device, factory, i)); } factory.Dispose(); return(new ReadOnlyList <IGraphicsAdapter>(adapterList)); }