Exemple #1
0
        public void UpdateAndDraw()
        {
            if (Win32Window.Width != context.device.width || Win32Window.Height != context.device.height)
            {
                context.device.Resize(Win32Window.Width, Win32Window.Height);
                ImGui.GetIO().DisplaySize = new System.Numerics.Vector2(context.device.width, context.device.height);
            }

            var graphicsContext = context.graphicsContext;

            context.device.Begin();
            graphicsContext.BeginCommand();
            context.GPUUploadDatas();
            graphicsContext.SetDescriptorHeapDefault();
            graphicsContext.ScreenBeginRender();
            graphicsContext.SetRenderTargetScreen();
            graphicsContext.ClearRenderTargetScreen(new Color4(0.5f, 0.5f, 1, 1));

            //just test
            //int index1 = context.uploadBuffer.Upload<System.Numerics.Vector4>(new[] { new System.Numerics.Vector4(1, 0, 1, 1) });
            //PSODesc testDesc = new PSODesc();
            //testDesc.CullMode = Vortice.Direct3D12.CullMode.None;
            //testDesc.RenderTargetFormat = Vortice.DXGI.Format.R8G8B8A8_UNorm;
            //testDesc.RenderTargetCount = 1;
            //testDesc.PrimitiveTopologyType = Vortice.Direct3D12.PrimitiveTopologyType.Triangle;
            //testDesc.InputLayout = "";
            //graphicsContext.SetRootSignature(Pipeline12Util.FromString(context, "Cssss"));
            //graphicsContext.SetPipelineState(context.pipelineStateObjects["Test"], testDesc);
            //graphicsContext.SetMesh(context.meshes["quad"]);
            //graphicsContext.SetSRV(context.renderTargets["imgui_font"], 0);
            //context.uploadBuffer.SetCBV(graphicsContext, index1, 0);

            //graphicsContext.DrawIndexedInstanced(6, 1, 0, 0, 0);

            commonRenderPipeline.Prepare();
            commonRenderPipeline.Render();
            ImGui.SetCurrentContext(context.imguiContext);
            var previous = currentTime;

            currentTime = DateTime.Now;
            float delta = (float)(currentTime - previous).TotalSeconds;

            ImGui.GetIO().DeltaTime = delta;
            context.imguiInputHandler.Update();
            GUIRender.Render();
            graphicsContext.ScreenEndRender();
            graphicsContext.EndCommand();
            graphicsContext.Execute();
            context.device.Present(true);
        }