/// <summary> /// Initializes a new instance of the <see cref="GraphicsDeviceInformation" /> class. /// </summary> public GraphicsDeviceInformation() { Adapter = GraphicsAdapter.Default; PresentParameters p = new PresentParameters(); p.InitDefaults(); PresentationParameters = p; }
internal GraphicsDevice(GraphicSystem graphicSystem) { _direct3D = new Direct3D(); _graphicsSystem = graphicSystem; _presentParameters = new PresentParameters(); _presentParameters.InitDefaults(); _presentParameters.BackBufferWidth = graphicSystem.DefaultScreenWidth; _presentParameters.BackBufferHeight = graphicSystem.DefaultScreenHeight; }
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); }
protected void AddDevice(GraphicsAdapter graphicsAdapter, DisplayMode mode, GraphicsDeviceInformation deviceBaseInfo, GameGraphicsParameters prefferedParameters, List <GraphicsDeviceInformation> graphicsDeviceInfos) { var deviceInfo = deviceBaseInfo.Clone(); PresentParameters p = new PresentParameters(); p.InitDefaults(); p.FullScreenRefreshRateInHz = mode.RefreshRate; if (prefferedParameters.IsFullScreen) { p.BackBufferWidth = prefferedParameters.PreferredBackBufferWidth; p.BackBufferHeight = prefferedParameters.PreferredBackBufferHeight; p.Windowed = false; } else { p.BackBufferWidth = prefferedParameters.PreferredBackBufferWidth; p.BackBufferHeight = prefferedParameters.PreferredBackBufferHeight; p.Windowed = true; p.FullScreenRefreshRateInHz = 0; } p.DeviceWindowHandle = MainWindow.NativeWindow.Handle; p.AutoDepthStencilFormat = prefferedParameters.PreferredDepthStencilFormat; p.MultiSampleQuality = 0; p.PresentationInterval = prefferedParameters.SynchronizeWithVerticalRetrace ? PresentInterval.One : PresentInterval.Immediate; p.SwapEffect = SwapEffect.Discard; p.PresentFlags = PresentFlags.Video; deviceInfo.PresentationParameters = p; deviceInfo.Adapter = GraphicsAdapter.Adapters[prefferedParameters.PreferredVideoAdapter]; if (!graphicsDeviceInfos.Contains(deviceInfo)) { graphicsDeviceInfos.Add(deviceInfo); } }
public static void StartD3D(Window parentWindow) { _activeClients++; if (_activeClients > 1) { return; } _d3DContext = new Direct3DEx(); var presentParameters = new PresentParameters(); presentParameters.InitDefaults(); presentParameters.DeviceWindowHandle = new WindowInteropHelper(parentWindow).Handle; //presentParameters.Windowed = true; //presentParameters.SwapEffect = SwapEffect.Discard; //presentParameters.PresentationInterval = PresentInterval.Immediate; _d3DDevice = new DeviceEx(_d3DContext, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve, presentParameters); }