⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dxmutenum.cs

📁 运用directX完成的坦克游戏雏形
💻 CS
📖 第 1 页 / 共 3 页
字号:
                        BuildConflictList(deviceCombo);
                        BuildPresentIntervalList(deviceInfo, deviceCombo);

                        deviceCombo.adapterInformation = adapterInfo;
                        deviceCombo.deviceInformation = deviceInfo;

                        // Add the combo to the list of devices
                        deviceInfo.deviceSettingsList.Add(deviceCombo);
                    }
                }
            }
        }

        /// <summary>
        /// Adds all depth/stencil formats that are compatible with the device 
        /// and application to the given device combo
        /// </summary>
        private static void BuildDepthStencilFormatList(EnumDeviceSettingsCombo deviceCombo)
        {
            foreach(DepthFormat depthStencil in depthStencilPossibleList)
            {
                if (Manager.CheckDeviceFormat((int)deviceCombo.AdapterOrdinal,
                    deviceCombo.DeviceType, deviceCombo.AdapterFormat,
                    Usage.DepthStencil, ResourceType.Surface, depthStencil))
                {
                    // This can be used as a depth stencil, make sure it matches
                    if (Manager.CheckDepthStencilMatch((int)deviceCombo.AdapterOrdinal,
                        deviceCombo.DeviceType, deviceCombo.AdapterFormat,
                        deviceCombo.BackBufferFormat, depthStencil))
                    {
                        // Yup, add it
                        deviceCombo.depthStencilFormatList.Add(depthStencil);
                    }
                }
            }
        }

        /// <summary>
        /// Adds all multisample types that are compatible with the device and app to
        /// the given device combo
        /// </summary>
        private static void BuildMultiSampleTypeList(EnumDeviceSettingsCombo deviceCombo)
        {
            foreach(MultiSampleType msType in multiSampleTypeList)
            {
                int result, quality;
                // Check this
                if (Manager.CheckDeviceMultiSampleType((int)deviceCombo.AdapterOrdinal,
                    deviceCombo.DeviceType, deviceCombo.BackBufferFormat,
                    deviceCombo.IsWindowed, msType, out result, out quality))
                {
                    deviceCombo.multiSampleTypeList.Add(msType);
                    if (quality > multisampleQualityMax + 1)
                        quality = (int)(multisampleQualityMax + 1);

                    deviceCombo.multiSampleQualityList.Add(quality);
                }
            }
        }


        /// <summary>
        /// Find any conflicts between the available depth/stencil formats and
        /// multisample types.
        /// </summary>
        private static void BuildConflictList(EnumDeviceSettingsCombo deviceCombo)
        {
            foreach(DepthFormat depthFormat in deviceCombo.depthStencilFormatList)
            {
                foreach(MultiSampleType msType in deviceCombo.multiSampleTypeList)
                {
                    // Check this for conflict
                    if (!Manager.CheckDeviceMultiSampleType((int)deviceCombo.AdapterOrdinal,
                        deviceCombo.DeviceType, (Format)depthFormat,
                        deviceCombo.IsWindowed, msType))
                    {
                        // Add it to the list
                        EnumDepthStencilMultisampleConflict conflict = new EnumDepthStencilMultisampleConflict();
                        conflict.DepthStencilFormat = depthFormat;
                        conflict.MultisampleType = msType;
                        deviceCombo.depthStencilConflictList.Add(conflict);
                    }
                }
            }
        }


        /// <summary>
        /// Adds all present intervals that are compatible with the device and app 
        /// to the given device combo
        /// </summary>
        private static void BuildPresentIntervalList(EnumDeviceInformation deviceInfo, EnumDeviceSettingsCombo deviceCombo)
        {
            for (int i = 0; i < presentIntervalList.Count; i++)
            {
                PresentInterval pi = (PresentInterval)presentIntervalList[i];
                if (deviceCombo.IsWindowed)
                {
                    if ( (pi == PresentInterval.Two) ||
                        (pi == PresentInterval.Three) ||
                        (pi == PresentInterval.Four) )
                    {
                        // These intervals are never supported in windowed mode
                        continue;
                    }
                }

                // Not that PresentInterval.Default is zero so you can't do a bitwise
                // check for it, it's always available
                if ( (pi == PresentInterval.Default) ||
                    ((deviceInfo.Caps.PresentationIntervals & pi) != 0))
                {
                    deviceCombo.presentIntervalList.Add(pi);
                }
            }
        }

        /// <summary>
        /// Resets the list of possible depth stencil formats
        /// </summary>
        public static void ResetPossibleDepthStencilFormats()
        {
            depthStencilPossibleList.Clear();
            depthStencilPossibleList.AddRange(new DepthFormat[] {
                                                             DepthFormat.D16,
                                                             DepthFormat.D15S1,
                                                             DepthFormat.D24X8,
                                                             DepthFormat.D24S8,
                                                             DepthFormat.D24X4S4,
                                                             DepthFormat.D32 });
        }

        /// <summary>
        /// Resets the possible multisample type list
        /// </summary>
        public static void ResetPossibleMultisampleTypeList()
        {
            multiSampleTypeList.Clear();
            multiSampleTypeList.AddRange(new MultiSampleType[] {
                                                            MultiSampleType.None,
                                                            MultiSampleType.NonMaskable,
                                                            MultiSampleType.TwoSamples,
                                                            MultiSampleType.ThreeSamples,
                                                            MultiSampleType.FourSamples,
                                                            MultiSampleType.FiveSamples,
                                                            MultiSampleType.SixSamples,
                                                            MultiSampleType.SevenSamples,
                                                            MultiSampleType.EightSamples,
                                                            MultiSampleType.NineSamples,
                                                            MultiSampleType.TenSamples,
                                                            MultiSampleType.ElevenSamples,
                                                            MultiSampleType.TwelveSamples,
                                                            MultiSampleType.ThirteenSamples,
                                                            MultiSampleType.FourteenSamples,
                                                            MultiSampleType.FifteenSamples,
                                                            MultiSampleType.SixteenSamples });
        }

        /// <summary>
        /// Resets the possible present interval list
        /// </summary>
        public static void ResetPossiblePresentIntervalList()
        {
            presentIntervalList.Clear();
            presentIntervalList.AddRange(new PresentInterval[] {
                                                            PresentInterval.Immediate,
                                                            PresentInterval.Default,
                                                            PresentInterval.One,
                                                            PresentInterval.Two,
                                                            PresentInterval.Three,
                                                            PresentInterval.Four });
        }

        /// <summary>
        /// Set the minimum and maximum resolution items
        /// </summary>
        public static void SetResolutionMinMax(uint minWidth, uint minHeight, uint maxWidth, uint maxHeight)
        {
            minimumWidth = minWidth;
            minimumHeight = minHeight;
            maximumWidth = maxHeight;
            maximumWidth = maxWidth;
        }

        /// <summary>
        /// Sets the minimum and maximum refresh
        /// </summary>
        public static void SetRefreshMinMax(uint minRefresh, uint maxRefresh)
        {
            minimumRefresh = minRefresh;
            maximumRefresh = maxRefresh;
        }

        /// <summary>
        /// Property for MultisampleQualityMax
        /// </summary>
        public static uint MultisampleQualityMax
        {
            get { return multisampleQualityMax; }
            set 
            {
                if (value > 0xffff)
                    multisampleQualityMax = 0xffff;
                else
                    multisampleQualityMax = value;
            }
        }

        /// <summary>
        /// Allows the user to set if post pixel shader blending is required
        /// </summary>
        public static bool IsPostPixelShaderBlendingRequred
        {
            get { return isPostPixelShaderBlendingRequired; }
            set { isPostPixelShaderBlendingRequired = value; }
        }

        /// <summary>
        /// Allows the user to set if software vertex processing is available
        /// </summary>
        public static bool IsSoftwareVertexProcessingPossible
        {
            get { return isSoftwareVertexProcessing; }
            set { isSoftwareVertexProcessing = value; }
        }

        /// <summary>
        /// Allows the user to set if hardware vertex processing is available
        /// </summary>
        public static bool IsHardwareVertexProcessingPossible
        {
            get { return isHardwareVertexProcessing; }
            set { isHardwareVertexProcessing = value; }
        }

        /// <summary>
        /// Allows the user to set if pure hardware vertex processing is available
        /// </summary>
        public static bool IsPureHardwareVertexProcessingPossible
        {
            get { return isPureHardwareVertexProcessing; }
            set { isPureHardwareVertexProcessing = value; }
        }

        /// <summary>
        /// Allows the user to set if mixed vertex processing is available
        /// </summary>
        public static bool IsMixedVertexProcessingPossible
        {
            get { return isMixedVertexProcessing; }
            set { isMixedVertexProcessing = value; }
        }

        /// <summary>
        /// Allows the user to get the possible depth stencil formats
        /// </summary>
        public static ArrayList PossibleDepthStencilFormatList
        {
            get { return depthStencilPossibleList; }
        }

        /// <summary>
        /// Allows the user to get the possible multisample types
        /// </summary>
        public static ArrayList PossibleMultisampleTypeList
        {
            get { return multiSampleTypeList; }
        }

        /// <summary>
        /// Allows the user to get the possible present intervals
        /// </summary>
        public static ArrayList PossiblePresentIntervalsList
        {
            get { return presentIntervalList; }
        }

        /// <summary>
        /// Use this after Enumerate to get the list of adapter information
        /// </summary>
        public static ArrayList AdapterInformationList
        {
            get { return adapterInformationList; }
        }

        /// <summary>
        /// Get the adapter information for a specific adapter
        /// </summary>
        public static EnumAdapterInformation GetAdapterInformation(uint ordinal)
        {
            foreach(EnumAdapterInformation eai in adapterInformationList)
            {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -