コード例 #1
0
        /// <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;
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D10GraphicsAdapter"/> class.
        /// </summary>
        /// <param name="graphicsDevice">The graphics device.</param>
        /// <param name="factory">The DXGI factory.</param>
        /// <param name="adapterIndex">Index of the adapter.</param>
        internal D3D10GraphicsAdapter(D3D.Device graphicsDevice, DXGI.Factory factory, int adapterIndex)
        {
            _graphicsDevice = graphicsDevice;
            _adapterIndex   = adapterIndex;

            List <DisplayMode> modes = new List <DisplayMode>();

            DXGI.Adapter adapter = factory.GetAdapter(adapterIndex);
            if (adapter != null)
            {
                DXGI.AdapterDescription adDesc = adapter.Description;
                _desc        = adDesc.Description;
                _devId       = adDesc.DeviceId;
                _rev         = adDesc.Revision;
                _subsystemId = adDesc.SubsystemId;
                _vendorId    = adDesc.VendorId;

                DXGI.Output output = adapter.GetOutput(0);
                if (output != null)
                {
                    foreach (SurfaceFormat format in Enum.GetValues(typeof(SurfaceFormat)))
                    {
                        try {
                            System.Collections.ObjectModel.ReadOnlyCollection <DXGI.ModeDescription> modeList = output.GetDisplayModeList(D3D10Helper.ToD3DSurfaceFormat(format), 0);
                            if (modeList == null)
                            {
                                continue;
                            }
                            foreach (DXGI.ModeDescription modeDesc in modeList)
                            {
                                DisplayMode displayMode = new DisplayMode(modeDesc.Width, modeDesc.Height, format);
                                if (!modes.Contains(displayMode))
                                {
                                    modes.Add(displayMode);
                                }
                            }
                        } catch (Exception e) {
                            String s = e.StackTrace;
                            continue;
                        }
                    }
                    _displayModes = new DisplayModeCollection(modes);
                    output.Dispose();
                }
                adapter.Dispose();
            }
        }
コード例 #3
0
        /// <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));
        }