protected override void Update(GameTime gameTime) { FormManager.Update(); DebugDevice.Update(); base.Update(gt = gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(new Color(10, 10, 10)); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, null); { } spriteBatch.End(); FormManager.Draw(); DebugDevice.Draw(spriteBatch); base.Draw(gameTime); }
protected override void OnOpenGlInit(GlInterface gl, int fb) { try { #if USE_OPENTK engine = new Engine(new OpenTKDevice(), new Configuration(), this); #else IDevice device; var real = new RealDevice(gl); #if DEBUG && DEBUG_OPENGL device = new DebugDevice(real); #else device = new RealDeviceWrapper(real); #endif engine = new Engine(device, new Configuration(), this); #endif } catch (Exception e) { Console.WriteLine(e); throw; } }
public DebugDeviceProxy(DebugDevice dd) { DebugDevice = dd; }
internal static MyRenderDeviceSettings CreateDevice(IntPtr windowHandle, MyRenderDeviceSettings?settingsToTry) { if (Device != null) { Device.Dispose(); Device = null; } FeatureLevel[] featureLevels = { FeatureLevel.Level_11_0 }; DeviceCreationFlags flags = DeviceCreationFlags.None; #if DEBUG_DEVICE flags |= DeviceCreationFlags.Debug; #endif WinApi.DEVMODE mode = new WinApi.DEVMODE(); WinApi.EnumDisplaySettings(null, WinApi.ENUM_REGISTRY_SETTINGS, ref mode); var adapters = GetAdaptersList(); int adapterIndex = settingsToTry.HasValue ? settingsToTry.Value.AdapterOrdinal : -1; adapterIndex = ValidateAdapterIndex(adapterIndex); if (adapterIndex == -1) { throw new MyRenderException("No supporting device detected!", MyRenderExceptionEnum.GpuNotSupported); } var settings = settingsToTry ?? new MyRenderDeviceSettings() { AdapterOrdinal = adapterIndex, BackBufferHeight = mode.dmPelsHeight, BackBufferWidth = mode.dmPelsWidth, WindowMode = MyWindowModeEnum.Fullscreen, RefreshRate = 60000, VSync = false, }; m_settings = settings; Device = new Device(GetFactory().Adapters[adapters[m_settings.AdapterOrdinal].AdapterDeviceId], flags, FeatureLevel.Level_11_0); // HACK: This is required for Steam overlay to work. Apparently they hook only CreateDevice methods with DriverType argument. try { using (new Device(DriverType.Hardware, flags, FeatureLevel.Level_11_0)){} } catch { } if (flags.HasFlag(DeviceCreationFlags.Debug)) { if (DebugDevice != null) { DebugDevice.Dispose(); DebugDevice = null; } DebugDevice = new DeviceDebug(Device); DebugInfoQueue = DebugDevice.QueryInterface <InfoQueue>(); new System.Threading.Thread(ProcessDebugOutput).Start(); } if (ImmediateContext != null) { ImmediateContext.Dispose(); ImmediateContext = null; } ImmediateContext = Device.ImmediateContext; m_windowHandle = windowHandle; m_resolution = new Vector2I(m_settings.BackBufferWidth, m_settings.BackBufferHeight); if (!m_initialized) { InitSubsystems(); m_initialized = true; } if (m_swapchain != null) { m_swapchain.Dispose(); m_swapchain = null; } if (m_swapchain == null) { SharpDX.DXGI.Device d = Device.QueryInterface <SharpDX.DXGI.Device>(); Adapter a = d.GetParent <Adapter>(); var factory = a.GetParent <Factory>(); var scDesc = new SwapChainDescription(); scDesc.BufferCount = MyRender11Constants.BUFFER_COUNT; scDesc.Flags = SwapChainFlags.AllowModeSwitch; scDesc.IsWindowed = true; scDesc.ModeDescription.Format = MyRender11Constants.BACKBUFFER_FORMAT; scDesc.ModeDescription.Height = m_settings.BackBufferHeight; scDesc.ModeDescription.Width = m_settings.BackBufferWidth; scDesc.ModeDescription.RefreshRate.Numerator = m_settings.RefreshRate; scDesc.ModeDescription.RefreshRate.Denominator = 1000; scDesc.ModeDescription.Scaling = DisplayModeScaling.Unspecified; scDesc.ModeDescription.ScanlineOrdering = DisplayModeScanlineOrder.Progressive; scDesc.SampleDescription.Count = 1; scDesc.SampleDescription.Quality = 0; scDesc.OutputHandle = m_windowHandle; scDesc.Usage = Usage.RenderTargetOutput; scDesc.SwapEffect = SwapEffect.Discard; m_swapchain = new SwapChain(factory, Device, scDesc); m_swapchain.GetParent <Factory>().MakeWindowAssociation(m_windowHandle, WindowAssociationFlags.IgnoreAll); } // we start with window always (DXGI recommended) m_settings.WindowMode = MyWindowModeEnum.Window; ApplySettings(settings); return(m_settings); }