public static void Initialize(GlobalInit initStruct) { // subsystem initialization // initialize low level system // File System m_FileSystem = new Filesystem.FileSystem(); m_FileSystem.Initialize(); // graphic m_Device3d = new GraphicDevice.Direct3d11.Device3dD3d11(); Device3dInit dev3dInit = new Device3dInit(); dev3dInit.hWindow = initStruct.hWindow; dev3dInit.iScreenWidth = initStruct.hWindow.ClientSize.Width; dev3dInit.iScreenHeight = initStruct.hWindow.ClientSize.Height; m_Device3d.Initialize(dev3dInit); // input m_InputManager = new Input.CInputManager(); m_InputManager.Initialize(initStruct.hWindow); // application time m_AppTimer = new CAccumTimer(); m_AppTimer.Start(); // initialize high level // world m_World = new World.CWorld(); // scene m_Scene = new Scene.Scene(); m_Scene.Load(); m_Scene.CurrWorld = m_World; }
public void Initialize(Device3dInit initStruct) { // store info from initStruct m_hWindow = initStruct.hWindow; // device state m_CurrRenderTargets = new RenderTargetView[4]; m_CurrViewports = new Viewport[4]; { // swap chain var desc = new SwapChainDescription() { BufferCount = 1, ModeDescription = new ModeDescription(initStruct.iScreenWidth, initStruct.iScreenHeight, new Rational(60, 1), Format.R8G8B8A8_UNorm), IsWindowed = true, OutputHandle = m_hWindow.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; // create device and swap chain DeviceCreationFlags flags = DeviceCreationFlags.Debug; SlimDXDevice11.CreateWithSwapChain(DriverType.Hardware, flags, desc, out m_D3dDevice, out m_SwapChain); // [Q] what SetWindowAssociation() is about? #warning "[Q] what SetWindowAssociation() is about?" m_D3dDevice.Factory.SetWindowAssociation(initStruct.hWindow.Handle, WindowAssociationFlags.IgnoreAll); } // create back buffers Texture2D backBuffer = Texture2D.FromSwapChain <Texture2D>(m_SwapChain, 0); var renderTargetView = new RenderTargetView(m_D3dDevice, backBuffer); m_RTVList.Add("BackBuffer", renderTargetView); // create depth buffer CreateDepthStencilBuffer(new CreateDepthStencilBufferCmd() { Name = "BackBuffer", Width = m_hWindow.ClientSize.Width, Height = m_hWindow.ClientSize.Height }); // create viewport var viewport = new Viewport(0.0f, 0.0f, m_hWindow.ClientSize.Width, m_hWindow.ClientSize.Height, 0.0f, 1.0f); m_ViewportList.Add("Default", viewport); SetViewport("Default"); // set our render pipeline to the default state m_D3dDevice.ImmediateContext.Rasterizer.SetViewports(m_CurrViewports); m_D3dDevice.ImmediateContext.OutputMerger.SetTargets(m_CurrDepthStencil, m_CurrRenderTargets); // success Debug.Helper.Log("Device3d D3d11 is successfully initialized"); }
public void Initialize(Device3dInit initStruct) { // store info from initStruct m_hWindow = initStruct.hWindow; // device state m_CurrRenderTargets = new RenderTargetView[4]; m_CurrViewports = new Viewport[4]; { // swap chain var desc = new SwapChainDescription() { BufferCount = 1, ModeDescription = new ModeDescription(initStruct.iScreenWidth, initStruct.iScreenHeight, new Rational(60, 1), Format.R8G8B8A8_UNorm), IsWindowed = true, OutputHandle = m_hWindow.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; // create device and swap chain DeviceCreationFlags flags = DeviceCreationFlags.Debug; SlimDXDevice11.CreateWithSwapChain(DriverType.Hardware, flags, desc, out m_D3dDevice, out m_SwapChain); // [Q] what SetWindowAssociation() is about? #warning "[Q] what SetWindowAssociation() is about?" m_D3dDevice.Factory.SetWindowAssociation(initStruct.hWindow.Handle, WindowAssociationFlags.IgnoreAll); } // create back buffers Texture2D backBuffer = Texture2D.FromSwapChain<Texture2D>(m_SwapChain, 0); var renderTargetView = new RenderTargetView(m_D3dDevice, backBuffer); m_RTVList.Add("BackBuffer", renderTargetView); // create depth buffer CreateDepthStencilBuffer(new CreateDepthStencilBufferCmd() { Name = "BackBuffer", Width = m_hWindow.ClientSize.Width, Height = m_hWindow.ClientSize.Height } ); // create viewport var viewport = new Viewport(0.0f, 0.0f, m_hWindow.ClientSize.Width, m_hWindow.ClientSize.Height, 0.0f, 1.0f); m_ViewportList.Add("Default", viewport); SetViewport("Default"); // set our render pipeline to the default state m_D3dDevice.ImmediateContext.Rasterizer.SetViewports(m_CurrViewports); m_D3dDevice.ImmediateContext.OutputMerger.SetTargets(m_CurrDepthStencil, m_CurrRenderTargets); // success Debug.Helper.Log("Device3d D3d11 is successfully initialized"); }