当前位置: 首页>>代码示例>>C#>>正文


C# MyRenderDeviceSettings类代码示例

本文整理汇总了C#中MyRenderDeviceSettings的典型用法代码示例。如果您正苦于以下问题:C# MyRenderDeviceSettings类的具体用法?C# MyRenderDeviceSettings怎么用?C# MyRenderDeviceSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MyRenderDeviceSettings类属于命名空间,在下文中一共展示了MyRenderDeviceSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartRenderComponent

        protected override void StartRenderComponent(MyRenderDeviceSettings? settings)
        {
            DrawThread = Thread.CurrentThread;

            MyRenderWindow wnd = new MyRenderWindow();
#if XB1
			System.Diagnostics.Debug.Assert(false);
#else
            wnd.Control = Control.FromHandle(WindowHandle);            
            wnd.TopLevelForm = (Form)wnd.Control.TopLevelControl;
            wnd.TopLevelForm.Tag = wnd;

            m_bufferedInputSource = wnd;

            wnd.TopLevelForm.KeyPress += TopLevelForm_KeyPress;

            m_windowCreatedEvent.Set();
            ((Form)wnd.TopLevelForm).FormClosed += (o, e) => ExitThreadSafe();
#endif

			Action showCursor = () =>
            {
                //if (!wnd.TopLevelForm.IsDisposed)
                //wnd.TopLevelForm.ShowCursor = true;
            };
            Action hideCursor = () =>
            {
                //if (!wnd.TopLevelForm.IsDisposed)
                //wnd.TopLevelForm.ShowCursor = false;
            };
            m_setMouseVisible = (b) =>
            {
                // In case of crash, this may be null, don't want subsequent crash
                var component = GameRenderComponent;
                if (component != null)
                {
                    var renderThread = component.RenderThread;
                    if (renderThread != null)
                    {
                        renderThread.Invoke(b ? showCursor : hideCursor);
                    }
                }
            };

            if (settings == null)
            {
                settings = new MyRenderDeviceSettings(0, MyWindowModeEnum.Window, wnd.Control.ClientSize.Width, wnd.Control.ClientSize.Height, 0, false, MyCompilationSymbols.DX11ForceStereo, false);
            }

            GameRenderComponent.StartSync(m_gameTimer, wnd, settings, MyRenderQualityEnum.NORMAL, MyPerGameSettings.MaxFrameRate);
            GameRenderComponent.RenderThread.SizeChanged += RenderThread_SizeChanged;
            GameRenderComponent.RenderThread.BeforeDraw += RenderThread_BeforeDraw;

            VRageRender.MyViewport vp = new MyViewport(0, 0, wnd.Control.ClientSize.Width, wnd.Control.ClientSize.Height);
            RenderThread_SizeChanged(wnd.Control.ClientSize.Width, wnd.Control.ClientSize.Height, vp);
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:56,代码来源:MySandboxExternal.cs

示例2: StartSync

        public static MyRenderThread StartSync(MyGameTimer timer, IMyRenderWindow renderWindow, MyRenderDeviceSettings? settingsToTry, MyRenderQualityEnum renderQuality)
        {
            var result = new MyRenderThread(timer, false);
            result.m_renderWindow = renderWindow;
            result.m_settings = MyRenderProxy.CreateDevice(result, renderWindow.Handle, settingsToTry);
            MyRenderProxy.SendCreatedDeviceSettings(result.m_settings);

            result.m_currentQuality = renderQuality;
            result.m_form = System.Windows.Forms.Control.FromHandle(renderWindow.Handle);

            result.LoadContent();
            result.UpdateSize();
            return result;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:14,代码来源:MyRenderThread.cs

示例3: ApplySettings

 public void ApplySettings(MyRenderDeviceSettings settings)
 {
     MyRender.ApplySettings(settings);
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:4,代码来源:MyDX9Render.cs

示例4: ReadSettingsFromControls

        private bool ReadSettingsFromControls(ref MyRenderDeviceSettings deviceSettings, ref MyGraphicsSettings graphicsSettings)
        {
            bool changed;

            changed = deviceSettings.AdapterOrdinal != (int)m_videoAdapterCombobox.GetSelectedKey();
            deviceSettings.AdapterOrdinal = (int)m_videoAdapterCombobox.GetSelectedKey();

            var resolution = m_resolutionsForAdapter[(int)m_resolutionCombobox.GetSelectedKey()];

            changed = changed || deviceSettings.BackBufferWidth != resolution.X;
            deviceSettings.BackBufferWidth = resolution.X;

            changed = changed || deviceSettings.BackBufferHeight != resolution.Y;
            deviceSettings.BackBufferHeight = resolution.Y;

            int refreshRate = 0;
            foreach (var displayMode in MyVideoSettingsManager.Adapters[deviceSettings.AdapterOrdinal].SupportedDisplayModes)
            { // Pick the highest refresh rate available (although it might be better to add combobox for refresh rates as well)
                if (displayMode.Width == resolution.X &&
                    displayMode.Height == resolution.Y &&
                    refreshRate < displayMode.RefreshRate)
                    refreshRate = displayMode.RefreshRate;
            }

            changed = changed || deviceSettings.RefreshRate != refreshRate;
            deviceSettings.RefreshRate = refreshRate;

            changed = changed || deviceSettings.VSync != m_verticalSyncCheckbox.IsChecked;
            deviceSettings.VSync = m_verticalSyncCheckbox.IsChecked;

            changed = changed || deviceSettings.WindowMode != (MyWindowModeEnum)m_windowModeCombobox.GetSelectedKey();
            deviceSettings.WindowMode = (MyWindowModeEnum)m_windowModeCombobox.GetSelectedKey();

            var fov = MathHelper.ToRadians(m_fieldOfViewSlider.Value);
            changed = changed || graphicsSettings.FieldOfView != fov;
            graphicsSettings.FieldOfView = fov;

            changed = changed || graphicsSettings.HardwareCursor != m_hardwareCursorCheckbox.IsChecked;
            graphicsSettings.HardwareCursor = m_hardwareCursorCheckbox.IsChecked;

            changed = changed || graphicsSettings.EnableDamageEffects != m_enableDamageEffectsCheckbox.IsChecked;
            graphicsSettings.EnableDamageEffects = m_enableDamageEffectsCheckbox.IsChecked;

            changed = changed || graphicsSettings.Render.InterpolationEnabled != m_renderInterpolationCheckbox.IsChecked;
            graphicsSettings.Render.InterpolationEnabled = m_renderInterpolationCheckbox.IsChecked;

            changed = changed || graphicsSettings.Render.Dx9Quality != (MyRenderQualityEnum)m_renderQualityCombobox.GetSelectedKey();
            graphicsSettings.Render.Dx9Quality = (MyRenderQualityEnum)m_renderQualityCombobox.GetSelectedKey();

            return changed;
        }
开发者ID:mittens,项目名称:SpaceEngineers,代码行数:51,代码来源:MyGuiScreenOptionsVideoSpace.cs

示例5: CreateDeviceInternalSafe

 private static bool CreateDeviceInternalSafe(IntPtr windowHandle, MyRenderDeviceSettings? settingsToTry)
 {
     try
     {
         CreateDeviceInternal(windowHandle, settingsToTry);
         return true;
     }
     catch (Exception ex)
     {
         Log.WriteLine("CreateDevice failed: " + ex.ToString());
         DisposeDevice();
     }
     return false;
 }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:14,代码来源:MyRender-Device.cs

示例6: ReadSettingsFromControls

        private bool ReadSettingsFromControls(ref MyRenderDeviceSettings deviceSettings)
        {
            bool changed;
            MyRenderDeviceSettings read;

            var selectedResolution = (int)m_comboResolution.GetSelectedKey();
            if ((uint)selectedResolution < (uint)m_resolutions.Count)
            {
                var resolution = m_resolutions[selectedResolution];
                read.BackBufferWidth = resolution.X;
                read.BackBufferHeight = resolution.Y;
                read.WindowMode = (MyWindowModeEnum)m_comboWindowMode.GetSelectedKey();
                read.AdapterOrdinal = (int)m_comboVideoAdapter.GetSelectedKey();
                read.VSync = m_checkboxVSync.IsChecked;
                read.RefreshRate = 0;
                foreach (var displayMode in MyVideoSettingsManager.Adapters[deviceSettings.AdapterOrdinal].SupportedDisplayModes)
                { // Pick the highest refresh rate available (although it might be better to add combobox for refresh rates as well)
                    if (displayMode.Width == read.BackBufferWidth &&
                        displayMode.Height == read.BackBufferHeight &&
                        read.RefreshRate < displayMode.RefreshRate)
                    {
                        read.RefreshRate = displayMode.RefreshRate;
                    }
                }
                changed = !read.Equals(ref deviceSettings);
                deviceSettings = read;
            }
            else
            { // unsupported display mode selected, so pretend nothing was changed
                changed = false;
            }

            return changed;
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:34,代码来源:MyGuiScreenOptionsDisplay.cs

示例7: StartRenderComponent

 protected virtual void StartRenderComponent(MyRenderDeviceSettings? settingsToTry)
 {
     GameRenderComponent.Start(m_gameTimer, InitializeRenderThread, settingsToTry, MyRenderQualityEnum.NORMAL);
     GameRenderComponent.RenderThread.SizeChanged += RenderThread_SizeChanged;
     GameRenderComponent.RenderThread.BeforeDraw += RenderThread_BeforeDraw;
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:6,代码来源:MySandboxGame.cs

示例8: SwitchSettings

 public virtual void SwitchSettings(MyRenderDeviceSettings settings)
 {
     MyRenderProxy.SwitchDeviceSettings(settings);
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:4,代码来源:MySandboxGame.cs

示例9: CreateDevice

        public static MyRenderDeviceSettings CreateDevice(IntPtr windowHandle, MyRenderDeviceSettings? settingsToTry)
        {
            Debug.Assert(Device == null, "Device was not properly released");

            // try first settingsToTry (if available)
            //  if that doesn't work, try again using desktop fullscreen settings
            //  if that doesn't work, use fallback settings (800x600 or 640x480 in window) and hope for the best

            m_windowHandle = windowHandle;

            var deviceType = DeviceType.Hardware;
            int adapterOrdinal = 0;
            if (settingsToTry.HasValue)
            {
                adapterOrdinal = settingsToTry.Value.AdapterOrdinal;
            }
            EnablePerfHUD(m_d3d, ref adapterOrdinal, ref deviceType);

            bool deviceCreated = false;

            if (settingsToTry.HasValue)
            {
                try
                {
                    var settings = settingsToTry.Value;
                    var originalWindowMode = settings.WindowMode;
                    settings.AdapterOrdinal = adapterOrdinal;
                    settings.WindowMode = MyWindowModeEnum.Window;
                    TryCreateDeviceInternal(windowHandle, deviceType, settings, out m_device, out m_parameters);
                    Debug.Assert(m_device != null);
                    m_settings = settings;

                    bool modeExists = false;
                    foreach(var mode in m_adaptersList[settings.AdapterOrdinal].SupportedDisplayModes)
                    {
                        if(mode.Width == m_settings.BackBufferWidth && mode.Height == m_settings.BackBufferHeight && mode.RefreshRate == m_settings.RefreshRate)
                        {
                            modeExists = true;
                            break;
                        }
                    }

                    if(!modeExists)
                    {
                        var fallbackMode = m_adaptersList[settings.AdapterOrdinal].SupportedDisplayModes.Last(x => true);
                        m_settings.BackBufferHeight = fallbackMode.Height;
                        m_settings.BackBufferWidth = fallbackMode.Width;
                        m_settings.RefreshRate = fallbackMode.RefreshRate;
                    }

                    if (originalWindowMode != m_settings.WindowMode)
                    {
                        m_settings.WindowMode = originalWindowMode;
                        ApplySettings(m_settings);
                    }
                    deviceCreated = true;
                }
                catch
                {
                    /* These settings don't work so we'll try different. Dispose device in case it failed while switching to fullscreen. */
                    DisposeDevice();
                }
            }

            if (!deviceCreated)
            {
                // find the best match among supported display modes
                var adapters = GetAdaptersList();
                int i = 0;
                int j = 0;
                for (;i < adapters.Length; ++i)
                {
                    for (j = 0; j < adapters[i].SupportedDisplayModes.Length; ++j)
                    {
                        var bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
                        if (adapters[i].SupportedDisplayModes[j].Width == bounds.Width &&
                            adapters[i].SupportedDisplayModes[j].Height == bounds.Height)
                        {
                            goto DISPLAY_MODE_FOUND_LABEL;
                        }
                    }
                }

            DISPLAY_MODE_FOUND_LABEL:
                if (i != adapters.Length) // found appropriate display mode
                {
                    var displayMode = adapters[i].SupportedDisplayModes[j];
                    var bestFitSettings = new MyRenderDeviceSettings()
                    {
                        AdapterOrdinal = i,
                        BackBufferWidth = displayMode.Width,
                        BackBufferHeight = displayMode.Height,
                        RefreshRate = displayMode.RefreshRate,
                        VSync = true,
                        WindowMode = MyWindowModeEnum.Window, // initially create windowed, we change it to fullscreen afterwards
                    };
                    try
                    {
                        TryCreateDeviceInternal(windowHandle, deviceType, bestFitSettings, out m_device, out m_parameters);
                        Debug.Assert(m_device != null);
//.........这里部分代码省略.........
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:101,代码来源:MyRender-Device.cs

示例10: ApplySettings

        public static void ApplySettings(MyRenderDeviceSettings settings)
        {
            bool canReset = m_settings.AdapterOrdinal == settings.AdapterOrdinal;
            m_settings = settings;
            m_parameters = CreatePresentParameters(m_settings, m_windowHandle);
            SupportsHDR = GetAdaptersList()[m_settings.AdapterOrdinal].HDRSupported;

            if (canReset)
            {
                if (!Reset())
                    Recreate();
            }
            else
            {
                Recreate();
            }
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:17,代码来源:MyRender-Device.cs

示例11: SettingsChanged

 public static bool SettingsChanged(MyRenderDeviceSettings settings)
 {
     return !m_settings.Equals(ref settings);
 }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:4,代码来源:MyRender-Device.cs

示例12: CreatePresentParameters

        private static PresentParameters CreatePresentParameters(MyRenderDeviceSettings settings, IntPtr windowHandle)
        {
            PresentParameters p = new PresentParameters();
            p.InitDefaults();

            switch (settings.WindowMode)
            {
                case MyWindowModeEnum.Fullscreen:
                    p.FullScreenRefreshRateInHz = settings.RefreshRate;
                    p.BackBufferHeight = settings.BackBufferHeight;
                    p.BackBufferWidth = settings.BackBufferWidth;
                    p.Windowed = false;
                    break;

                case MyWindowModeEnum.FullscreenWindow:
                    {
                        WinApi.DEVMODE mode = new WinApi.DEVMODE();
                        WinApi.EnumDisplaySettings(null, WinApi.ENUM_REGISTRY_SETTINGS, ref mode);
                        p.FullScreenRefreshRateInHz = 0;
                        p.BackBufferHeight = mode.dmPelsHeight;
                        p.BackBufferWidth = mode.dmPelsWidth;
                        p.Windowed = true;
                    }
                    break;

                case MyWindowModeEnum.Window:
                    p.FullScreenRefreshRateInHz = 0;
                    p.BackBufferHeight = settings.BackBufferHeight;
                    p.BackBufferWidth = settings.BackBufferWidth;
                    p.Windowed = true;
                    break;
            }
            p.DeviceWindowHandle = windowHandle;

            p.AutoDepthStencilFormat = Format.D24S8;
            p.EnableAutoDepthStencil = true;
            p.BackBufferFormat = Format.X8R8G8B8;
            p.MultiSampleQuality = 0;
            p.PresentationInterval = settings.VSync ? PresentInterval.One : PresentInterval.Immediate;
            p.SwapEffect = SwapEffect.Discard;

            // PresentFlags.Video may cause crash when driver settings has overridden multisampling
            // We don't need it, it's just hint for driver
            p.PresentFlags = PresentFlags.DiscardDepthStencil;

            return p;
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:47,代码来源:MyRender-Device.cs

示例13: TryCreateDeviceInternal

        private static void TryCreateDeviceInternal(IntPtr windowHandle, DeviceType deviceType, MyRenderDeviceSettings settingsToTry, out Device device, out PresentParameters parameters)
        {
            device = null;
            parameters = CreatePresentParameters(settingsToTry, windowHandle);
            while (device == null)
            {
                try
                {
                    // These calls are here to ensure that none of these calls throw exceptions (even if their results are not used).
                    m_d3d.Dispose();
                    m_d3d = new Direct3D();

                    var d3dCaps = m_d3d.GetDeviceCaps(settingsToTry.AdapterOrdinal, DeviceType.Hardware);

                    device = new Device(m_d3d, settingsToTry.AdapterOrdinal, deviceType, Parameters.DeviceWindowHandle,
                        CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve,
                        Parameters);
                    device.Clear(ClearFlags.Target, new SharpDX.ColorBGRA(0, 0, 0, 1), 1.0f, 0);

                    var caps = Device.Capabilities;
                }
                catch (SharpDX.SharpDXException e)
                {
                    if (e.ResultCode == ResultCode.NotAvailable ||
                        (e.ResultCode == ResultCode.InvalidCall && GetForegroundWindow() != Parameters.DeviceWindowHandle))
                    {
                        // User has probably Alt+Tabbed or locked his computer before the game has started.
                        // To counter this, we try creating device again a bit later.
                        Thread.Sleep(2000);
                        MyLog.Default.WriteLine("Device creation failed with " + e.Message);
                    }
                    else
                    {
                        // Either settings or graphics card are not supported.
                        MyLog.Default.WriteLine(e);
                        throw;
                    }
                }

                try
                {
                    MyLog.Default.WriteLine("Loading adapters");
                    m_adaptersList = GetAdaptersList(m_d3d);
                    MyLog.Default.WriteLine("Found adapters");
                    foreach (var adapter in m_adaptersList)
                    {
                        adapter.LogInfo(MyLog.Default.WriteLine);
                    }
                }
                catch (Exception e)
                {
                    MyLog.Default.WriteLine(e);
                    throw;
                }
            }
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:56,代码来源:MyRender-Device.cs

示例14: CreateDevice

 public MyRenderDeviceSettings CreateDevice(IntPtr windowHandle, MyRenderDeviceSettings? settingsToTry)
 {
     return default(MyRenderDeviceSettings);
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:4,代码来源:MyNullRender.cs

示例15: SettingsChanged

 public bool SettingsChanged(MyRenderDeviceSettings settings)
 {
     return true;
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:4,代码来源:MyNullRender.cs


注:本文中的MyRenderDeviceSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。