private void Read() { fullScreenWidth = Kernel.Registry.Manager.Instance.GetValue("Graphics.Width", fullScreenWidth); fullScreenHeight = Kernel.Registry.Manager.Instance.GetValue("Graphics.Height", fullScreenHeight); fullScreenRefresh = Kernel.Registry.Manager.Instance.GetValue("Graphics.RefreshRate", fullScreenRefresh); windowed = Kernel.Registry.Manager.Instance.GetValue("Graphics.Windowed", windowed); backBufferFormat = Kernel.Registry.Manager.Instance.GetValue("Graphics.BackBufferFormat", backBufferFormat); depthBufferFormat = Kernel.Registry.Manager.Instance.GetValue("Graphics.DepthBufferFormat", depthBufferFormat); adapterIndex = Kernel.Registry.Manager.Instance.GetValue("Graphics.Adapter", adapterIndex); deviceType = Kernel.Registry.Manager.Instance.GetValue("Graphics.DeviceType", deviceType); multiSampleLevel = Kernel.Registry.Manager.Instance.GetValue("Graphics.Multisample", multiSampleLevel); backBufferCount = Kernel.Registry.Manager.Instance.GetValue("Graphics.BackBufferCount", backBufferCount); }
public static D3D.CreateFlags GetDeviceCreateFlags(int adpNum, D3D.DeviceType type) { DebugOnly.ConsoleWrite("Getting device creation flags..."); D3D.Caps caps = D3D.Manager.GetDeviceCaps(adpNum, type); D3D.CreateFlags flags = D3D.CreateFlags.SoftwareVertexProcessing; if (caps.DeviceCaps.SupportsHardwareRasterization && caps.DeviceCaps.SupportsHardwareTransformAndLight) { flags = D3D.CreateFlags.HardwareVertexProcessing; if (caps.DeviceCaps.SupportsPureDevice) { flags |= D3D.CreateFlags.PureDevice; } } DebugOnly.ConsoleWrite("Found flags: " + flags.ToString()); return(flags); }
//*************************************************************************** // Static Methods // public static D3D.DeviceType GetDeviceType(int adpNum) { DebugOnly.ConsoleWrite("Determining device type..."); D3D.DeviceType devType = D3D.DeviceType.Reference; D3D.Caps devCaps = D3D.Manager.GetDeviceCaps(adpNum, D3D.DeviceType.Hardware); if (devCaps.DeviceCaps.SupportsHardwareRasterization) { devType = D3D.DeviceType.Hardware; } else if (devCaps.DeviceType == D3D.DeviceType.Software) { devType = D3D.DeviceType.Software; } DebugOnly.ConsoleWrite("Found DeviceType: " + devType.ToString()); return(devType); }
public bool InitializeGraphics() { try { // Now let's setup our D3D stuff Caps DevCaps = Microsoft.DirectX.Direct3D.Manager.GetDeviceCaps(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware); Microsoft.DirectX.Direct3D.DeviceType DevType = Microsoft.DirectX.Direct3D.DeviceType.Reference; CreateFlags DevFlags = CreateFlags.SoftwareVertexProcessing; if ((DevCaps.VertexShaderVersion >= new Version(2, 0)) && (DevCaps.PixelShaderVersion >= new Version(2, 0))) { DevType = Microsoft.DirectX.Direct3D.DeviceType.Hardware; if (DevCaps.DeviceCaps.SupportsHardwareTransformAndLight) { DevFlags = CreateFlags.HardwareVertexProcessing; if (DevCaps.DeviceCaps.SupportsPureDevice) { DevFlags |= CreateFlags.PureDevice; } } } presentParams.BackBufferFormat = Format.Unknown; presentParams.SwapEffect = SwapEffect.Discard; presentParams.Windowed = true; presentParams.EnableAutoDepthStencil = true; presentParams.AutoDepthStencilFormat = DepthFormat.D16; presentParams.PresentationInterval = PresentInterval.Immediate; device = new Device(0, DevType, this, DevFlags, presentParams); device.DeviceReset += new System.EventHandler(this.OnResetDevice); this.OnCreateDevice(device, null); this.OnResetDevice(device, null); pause = false; return(true); } catch (DirectXException) { return(false); } }
public void InitDevice(D3D.DeviceType forcedDevice, D3D.CreateFlags forcedFlags) { if (this._dev != null) { this.Dispose(true); } try { D3D.PresentParameters pprms = new Microsoft.DirectX.Direct3D.PresentParameters(); pprms.Windowed = this._pprmWindowed; if (!this._pprmWindowed) { pprms.BackBufferWidth = this._pprmBkBfrW; pprms.BackBufferHeight = this._pprmBkBfrH; pprms.BackBufferFormat = this._pprmBkBfrFmt; pprms.FullScreenRefreshRateInHz = this._pprmRefreshRt; } pprms.AutoDepthStencilFormat = this._pprmDepthStencilFormat; pprms.SwapEffect = this._pprmSwapEffect; pprms.PresentationInterval = this._pprmIntvl; pprms.PresentFlag = this._pprmPrsFlg; pprms.MultiSample = this._pprmMsType; pprms.MultiSampleQuality = 0; pprms.BackBufferCount = this._pprmBkBfrCnt; this._dev = new D3D.Device(this._adpNum, forcedDevice, this._hWnd, forcedFlags, pprms); this._dev.DeviceReset += new EventHandler(this.dev_onDeviceReset); this._dev.DeviceLost += new EventHandler(this.dev_onDeviceLost); this._dev.DeviceResizing += new System.ComponentModel.CancelEventHandler(this.dev_onDeviceResizing); this._disposed = false; } catch { throw; } }
private void Read() { fullScreenWidth = Kernel.Registry.Manager.Instance.GetValue("Graphics.Width",fullScreenWidth ); fullScreenHeight = Kernel.Registry.Manager.Instance.GetValue("Graphics.Height",fullScreenHeight); fullScreenRefresh = Kernel.Registry.Manager.Instance.GetValue("Graphics.RefreshRate",fullScreenRefresh); windowed = Kernel.Registry.Manager.Instance.GetValue("Graphics.Windowed",windowed ); backBufferFormat = Kernel.Registry.Manager.Instance.GetValue("Graphics.BackBufferFormat",backBufferFormat ); depthBufferFormat = Kernel.Registry.Manager.Instance.GetValue("Graphics.DepthBufferFormat",depthBufferFormat ); adapterIndex = Kernel.Registry.Manager.Instance.GetValue("Graphics.Adapter",adapterIndex ); deviceType = Kernel.Registry.Manager.Instance.GetValue("Graphics.DeviceType",deviceType ); multiSampleLevel = Kernel.Registry.Manager.Instance.GetValue("Graphics.Multisample",multiSampleLevel ); backBufferCount = Kernel.Registry.Manager.Instance.GetValue("Graphics.BackBufferCount",backBufferCount ); }
public void InitDevice() { D3D.DeviceType devType = DxGraphics.GetDeviceType(this._adpNum); D3D.CreateFlags flags = DxGraphics.GetDeviceCreateFlags(this._adpNum, devType); this.InitDevice(devType, flags); }