public WinformsDevice(WinformsEye eye, Direct3D direct3D, CAdapter adapter, ControlWindow primaryWindow, SwapChainDescription implicitSwapChainDesc, DeviceInitializationFlags flags, IFileSystem fileSystem) { this.eye = eye; this.adapter = adapter; this.primaryWindow = primaryWindow; this.implicitSwapChainDesc = implicitSwapChainDesc; this.flags = flags; caps = adapter.Info.GetCaps(DeviceType.Hardware); devicePresentParams = new PresentParameters(); FillDevicePresentParams(); d3dDevice = new Device(direct3D, adapter.Index, DeviceType.Hardware, primaryWindow.Handle, CreateFlags.FpuPreserve | CreateFlags.HardwareVertexProcessing, devicePresentParams); CreateBackBufferAndDepthStencil(); additionalSwapChains = new List<CAdditionalSwapChain>(); creator = new CDeviceChildCreator(this); immediateContext = new CDeviceContext(this); lastSwapChainSize = new IntSize(primaryWindow.SwapChainWidth, primaryWindow.SwapChainHeight); fullscreenState = FullscreenState.Windowed; fullscreenDisplayMode = adapter.GetSupportedDisplayModes().First(); }
public DefaultWindow(DefaultDevice device, int width, int height, ref SwapChainDescription implicitSwapChainDescription, string title, GameWindowFlags gameWindowFlags, DisplayDevice displayDevice, ref Context glContext) : base(width, height, GraphicsMode.Default, title, gameWindowFlags, displayDevice) { glContext = glContext ?? new Context(Context); this.glContext = glContext; this.device = device; implicitSwapChainDesc = implicitSwapChainDescription; swapChainSurfaces = new SwapChainSurfaces(device, width, height, ref implicitSwapChainDescription); keyboard = new Keyboard(this); mouse = new Mouse(this); }
public DefaultDevice(DefaultEye eye, CAdapter adapter, DeviceInitializationFlags flags, WindowHandle windowHandle, ref SwapChainDescription implicitSwapChainDescription, IFileSystem fileSystem) { this.eye = eye; this.adapter = adapter; this.flags = flags; primaryWindow = new DefaultWindow(this, windowHandle.ClientWidth, windowHandle.ClientHeight, ref implicitSwapChainDescription, windowHandle.Title, GameWindowFlags.Default, ((COutput)adapter.Outputs[0]).GLDisplayDevice, ref glContext); creator = new CDeviceChildCreator(this); immediateContext = new CDeviceContext(this, glContext); }
public SwapChainSurfaces(ICDevice device, int width, int height, ref SwapChainDescription implicitSwapChainDescription) { this.device = device; var glContext = device.GetCurrentContext(); texture2DDescription = new Texture2DDescription { ArraySize = 1, ExtraFlags = ExtraFlags.None, Usage = Usage.Default, MipLevels = 1, MiscFlags = MiscFlags.None }; OnReset(glContext, width, height, ref implicitSwapChainDescription); }
public WinformsDevice(Factory1 dxgiFactory, WinformsEye eye, CAdapter adapter, ControlWindow primaryWindow, SwapChainDescription primarySwapChainDesc, DeviceInitializationFlags flags, IFileSystem fileSystem) { this.flags = flags; this.eye = eye; this.dxgiFactory = dxgiFactory; this.adapter = adapter; d3dDevice = new Device(adapter.DXGIAdapter, CtSharpDX11.DeviceCreationFlags(flags)); primarySwapChain = new CSwapChain(this, primaryWindow, ref primarySwapChainDesc, pswc => { }, () => !primaryWindow.IsVisible && additionalSwapChains.All(aswc => !aswc.Window.IsVisible)); creator = new CDeviceChildCreator(this); immediateContext = new CDeviceContext(this, d3dDevice.ImmediateContext); additionalSwapChains = new List<CSwapChain>(); }
public IAdditionalSwapChain CreateAdditionalSwapChain(IWindowHandle windowHandle, SwapChainDescription swapChainDesc) { throw new NotSupportedException("Additional swap chains are not yet supported by the ObjectGL.Default eye"); }
public void Initialize( IAdapter adapter, IWindowHandle windowHandle, BSwapChainDescription primarySwapChainDesc, DeviceInitializationFlags initializationFlags, IFileSystem fileSystem) { var cAdapter = (CAdapter)adapter; var window = (ControlWindow)windowHandle; device = new WinformsDevice(factory, this, cAdapter, window, primarySwapChainDesc, initializationFlags, fileSystem); window.SetSwapChain(device.PrimarySwapChain); windows.Add(window); window.Control.Show(); IsInitialized = true; }
public IAdditionalSwapChain CreateAdditionalSwapChain(IWindowHandle windowHandle, SwapChainDescription swapChainDesc) { var window = (ControlWindow) windowHandle; var aswc = new CSwapChain(this, window, ref swapChainDesc, OnAdditionalSwapChainDisposed, () => false); window.SetSwapChain(aswc); additionalSwapChains.Add(aswc); return aswc; }
void IPrimarySwapChain.ResetToPseudoFullscreen(ref SwapChainDescription description) { implicitSwapChainDesc = description; var defaultDisplay = DisplayDevice.Default; if (fullscreenState == FullscreenState.Fullscreen) defaultDisplay.RestoreResolution(); fullscreenState = FullscreenState.PseudoFullscreen; WindowState = WindowState.Fullscreen; ResetProcedure(); }
public void OnReset(Context glContext, int width, int height, ref SwapChainDescription implicitSwapChainDescription) { if (backBuffer != null) { backBuffer.Dispose(); backBuffer = null; } if (autoDepthStencil != null) { autoDepthStencil.Dispose(); autoDepthStencil = null; } texture2DDescription.Width = width; texture2DDescription.Height = height; texture2DDescription.Sampling = implicitSwapChainDescription.Sampling; texture2DDescription.FormatID = implicitSwapChainDescription.ColorBufferFormatID; texture2DDescription.BindFlags = BindFlags.RenderTarget; backBuffer = new CBackBuffer(device, ref texture2DDescription); if (implicitSwapChainDescription.EnableAutoDepthStencil) { texture2DDescription.FormatID = implicitSwapChainDescription.DepthStencilFormatID; texture2DDescription.BindFlags = BindFlags.DepthStencil; autoDepthStencil = new CAutoDepthStencil(device, ref texture2DDescription); } }
public void GetDescription(out SwapChainDescription description) { description = implicitSwapChainDesc; }
public IAdditionalSwapChain CreateAdditionalSwapChain(IWindowHandle windowHandle, SwapChainDescription swapChainDesc) { var window = (ControlWindow)windowHandle; var aswc = new CAdditionalSwapChain(this, window, swapChainDesc, asc => additionalSwapChains.Remove(asc)); window.SetSwapChain(aswc); additionalSwapChains.Add(aswc); return aswc; }
public void Initialize(IAdapter adapter, IWindowHandle windowHandle, SwapChainDescription primarySwapChainDesc, DeviceInitializationFlags initializationFlags, IFileSystem fileSystem) { if (adapter != adapters[0]) throw new ArgumentException("Provided adapter is not on of this eye's adapters"); device = new DefaultDevice(this, (CAdapter)adapter, initializationFlags, (WindowHandle)windowHandle, ref primarySwapChainDesc, fileSystem); initialized = true; }
void ISwapChain.Reset(ref SwapChainDescription description) { implicitSwapChainDesc = description; if (fullscreenState == FullscreenState.Fullscreen) DisplayDevice.Default.RestoreResolution(); fullscreenState = FullscreenState.Windowed; WindowState = WindowState.Normal; ResetProcedure(); }
void ISwapChain.GetDescription(out SwapChainDescription description) { description = implicitSwapChainDesc; }
public void ResetToFullscreen(ref BDisplayMode displayMode, ref SwapChainDescription description) { fullscreenDisplayMode = displayMode; fullscreenState = FullscreenState.Fullscreen; implicitSwapChainDesc = description; primaryWindow.OnFullscreen(displayMode.Width, displayMode.Height, () => { }, () => { }); //todo: remove unneeded args var coopLevel = d3dDevice.TestCooperativeLevel(); if (coopLevel.Success || coopLevel == ResultCode.DeviceNotReset) ResetProcedure(); }
public void ResetToPseudoFullscreen(ref SwapChainDescription description) { fullscreenState = FullscreenState.PseudoFullscreen; implicitSwapChainDesc = description; primaryWindow.OnPseudoFullscreen(); var coopLevel = d3dDevice.TestCooperativeLevel(); if (coopLevel.Success || coopLevel == ResultCode.DeviceNotReset) ResetProcedure(); }
public void Initialize( IAdapter adapter, IWindowHandle windowHandle, SwapChainDescription primarySwapChainDescription, DeviceInitializationFlags initializationFlags, IFileSystem fileSystem) { var cAdapter = (CAdapter)adapter; var primaryWindow = (ControlWindow)windowHandle; device = new WinformsDevice(this, direct3D, cAdapter, primaryWindow, primarySwapChainDescription, initializationFlags, fileSystem); primaryWindow.SetSwapChain(device); primaryWindow.Control.Show(); windows.Add(primaryWindow); IsInitialized = true; }
void IPrimarySwapChain.ResetToFullscreen(ref DisplayMode displayMode, ref SwapChainDescription description) { fullscreenDisplayMode = displayMode; implicitSwapChainDesc = description; fullscreenState = FullscreenState.Fullscreen; DisplayDevice.Default.ChangeResolution(displayMode.Width, displayMode.Height, device.Adapter.GetFormatInfo(displayMode.FormatID).TotalBits, displayMode.RefreshRate.ToSingle()); WindowState = WindowState.Fullscreen; ResetProcedure(); }