static void Main(string[] args) { // Create window, GraphicsDevice, and all resources necessary for the demo. VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 1280, 720, WindowState.Normal, "ImGui.NET Sample Program"), new GraphicsDeviceOptions(true, null, true), out _window, out _gd); _window.Resized += () => { _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height); _controller.WindowResized(_window.Width, _window.Height); }; _cl = _gd.ResourceFactory.CreateCommandList(); _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height); _memoryEditor = new MemoryEditor(); Random random = new Random(); _memoryEditorData = Enumerable.Range(0, 1024).Select(i => (byte)random.Next(255)).ToArray(); // Main application loop while (_window.Exists) { InputSnapshot snapshot = _window.PumpEvents(); if (!_window.Exists) { break; } _controller.Update(1f / 60f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui. SubmitUI(); _cl.Begin(); _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, new RgbaFloat(_clearColor.X, _clearColor.Y, _clearColor.Z, 1f)); _controller.Render(_gd, _cl); _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_gd.MainSwapchain); } // Clean up Veldrid resources _gd.WaitForIdle(); _controller.Dispose(); _cl.Dispose(); _gd.Dispose(); }
private static void Draw() { commandList.Begin(); commandList.SetFramebuffer(graphicsDevice.SwapchainFramebuffer); commandList.ClearColorTarget(0, RgbaFloat.CornflowerBlue); commandList.ClearDepthStencil(1f); infoTextRenderer.Draw(); demoTextRenderer.Draw(); commandList.End(); graphicsDevice.SubmitCommands(commandList); graphicsDevice.WaitForIdle(); graphicsDevice.SwapBuffers(); }
/// <summary> /// Clear the background. /// </summary> /// <param name="color">Color to set the background to.</param> public void Clear(Color color) { if (_disposed) { throw new ObjectDisposedException("Can't use renderer after it has been disposed."); } _commandList.Begin(); _commandList.SetFramebuffer(_currentTarget); var c = new RgbaFloat(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f); _commandList.ClearColorTarget(0, c); _commandList.End(); GraphicsDevice.SubmitCommands(_commandList); }
static void Main(string[] args) { _uiManager = new UiManager(); // Create window, GraphicsDevice, and all resources necessary for the demo. VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 1000, 720, WindowState.Normal, "FileDialog Demo"), new GraphicsDeviceOptions(true, null, true), out _window, out _gd); _window.Resized += _window_Resized; _cl = _gd.ResourceFactory.CreateCommandList(); _controller = new ImGuiRenderer(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height); ImGui.StyleColorsLight(); // Main application loop while (_window.Exists) { InputSnapshot snapshot = _window.PumpEvents(); if (!_window.Exists) { break; } _controller.Update(1f / 60f, snapshot); SubmitUI(); _cl.Begin(); _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, new RgbaFloat(0.5f, 0.5f, 0.5f, 1f)); _controller.Render(_gd, _cl); _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_gd.MainSwapchain); } // Clean up Veldrid resources _gd.WaitForIdle(); _controller.Dispose(); _cl.Dispose(); _gd.Dispose(); }
public void Draw() { double newElapsed = mClock.Elapsed.TotalSeconds; float deltaSeconds = (float)(newElapsed - mPreviousElapsed); mCommandList.Begin(); mCommandList.UpdateBuffer(mProjectionBuffer, 0, Matrix4x4.CreatePerspectiveFieldOfView( 1.0f, (float)mWindow.Width / mWindow.Height, 0.5f, 100f)); mCommandList.UpdateBuffer(mViewBuffer, 0, Matrix4x4.CreateLookAt(Vector3.UnitZ * 2.5f, Vector3.Zero, Vector3.UnitY)); Matrix4x4 rotation = Matrix4x4.CreateScale(mScale) * Matrix4x4.CreateFromAxisAngle(Vector3.UnitZ, mRotation.Z) * Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, mRotation.Y) * Matrix4x4.CreateFromAxisAngle(Vector3.UnitX, mRotation.X) * Matrix4x4.CreateTranslation(mTranslation); mCommandList.UpdateBuffer(mWorldBuffer, 0, ref rotation); mCommandList.SetFramebuffer(mSwapchain.Framebuffer); mCommandList.ClearColorTarget(0, RgbaFloat.Black); mCommandList.ClearDepthStencil(1f); mCommandList.SetPipeline(mPipeline); mCommandList.SetVertexBuffer(0, mVertexBuffer); mCommandList.SetIndexBuffer(mIndexBuffer, IndexFormat.UInt16); mCommandList.SetGraphicsResourceSet(0, mProjViewSet); mCommandList.SetGraphicsResourceSet(1, mWorldTextureSet); mCommandList.DrawIndexed(36, 1, 0, 0, 0); mImguiRenderer.Render(mGraphicsDevice, mCommandList); // [3] mCommandList.End(); mGraphicsDevice.SubmitCommands(mCommandList); mGraphicsDevice.SwapBuffers(mSwapchain); mGraphicsDevice.WaitForIdle(); if (mWindowResized) { mWindowResized = false; mGraphicsDevice.ResizeMainWindow((uint)mWindow.Width, (uint)mWindow.Height); mImguiRenderer.WindowResized(mWindow.Width, mWindow.Height); } }
protected virtual void Render() { _cl.Begin(); _cl.SetFramebuffer(_sc.Framebuffer); var r = new Random(); _cl.ClearColorTarget( 0, new RgbaFloat(0, 0, 0, 1)); //(float)r.NextDouble() _cl.ClearDepthStencil(1); // Do your rendering here (or call a subclass, etc.) _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_sc); }
protected override void Draw(float deltaSeconds) { UpdateAnimation(deltaSeconds); UpdateUniforms(); _cl.Begin(); _cl.SetFramebuffer(GraphicsDevice.SwapchainFramebuffer); _cl.ClearColorTarget(0, RgbaFloat.Black); _cl.ClearDepthStencil(1f); _cl.SetPipeline(_pipeline); _cl.SetGraphicsResourceSet(0, _rs); _cl.SetVertexBuffer(0, _vertexBuffer); _cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt32); _cl.DrawIndexed(_indexCount); _cl.End(); GraphicsDevice.SubmitCommands(_cl); GraphicsDevice.SwapBuffers(); }
public void Draw() { tick += 0.0001F; _cl.Begin(); Matrix4x4 modelMatrix = Matrix4x4.CreateTranslation(tick, 0, -0.01f) * Matrix4x4.CreateRotationX(0f) * Matrix4x4.CreateRotationY(0f) * Matrix4x4.CreateScale(1.0f); Matrix4x4 lookAtMatrix = Matrix4x4.CreateLookAt(machCamera._position, machCamera._position - machCamera._direction, machCamera._cameraUp); Matrix4x4 perspectiveMatrix = Matrix4x4.CreatePerspectiveFieldOfView(60.0f * (float)Math.PI / 180f, machCamera._width / (float)machCamera._height, machCamera._near, machCamera._far); _cl.UpdateBuffer(_modelBuffer, 0, ref modelMatrix); _cl.UpdateBuffer(_viewBuffer, 0, ref lookAtMatrix); _cl.UpdateBuffer(_projectionBuffer, 0, ref perspectiveMatrix); _cl.SetFramebuffer(_graphicsDevice.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, RgbaFloat.Black); _cl.ClearDepthStencil(1f); _cl.SetPipeline(pipelineDescription._pipeline); _cl.SetGraphicsResourceSet(0, shaderDescription.modelSet); _cl.SetGraphicsResourceSet(1, shaderDescription.vertexSet); _cl.SetVertexBuffer(0, _vertexBuffer); _cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); _cl.DrawIndexed( indexCount: 36, instanceCount: 1, indexStart: 0, vertexOffset: 0, instanceStart: 0); _cl.End(); _graphicsDevice.SubmitCommands(_cl); _graphicsDevice.SwapBuffers(_graphicsDevice.MainSwapchain); _graphicsDevice.WaitForIdle(); }
public void End() { #if DEBUG using Profiler fullProfiler = new Profiler(GetType()); #endif cl.SetFramebuffer(gd.SwapchainFramebuffer); if (ShouldClearBuffers) { cl.ClearDepthStencil(1f); cl.ClearColorTarget(0, ColorF.DarkGrey); } Controller.Render(gd, cl); cl.End(); gd.SubmitCommands(cl); Controller.SwapBuffers(gd); }
/// <summary> /// 目前暂时先使用单个CommandList,在单线程的情况下提交渲染对象 /// </summary> /// <param name="deltaSeconds"></param> protected virtual void Draw(float deltaSeconds) { _cl.Begin(); _cl.SetFramebuffer(GraphicsDevice.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, RgbaFloat.Black); _cl.ClearDepthStencil(1f); foreach (var item in renders) { //if (item is RayCastedGlobe) continue; item.Draw(_cl); } //最后渲染IMGUI //_controller.Render(GraphicsDevice, _cl); _cl.End(); GraphicsDevice.SubmitCommands(_cl); GraphicsDevice.SwapBuffers(GraphicsDevice.MainSwapchain); GraphicsDevice.WaitForIdle(); }
private static void Draw() { _commandList.Begin(); _commandList.SetFramebuffer(_graphicsDevice.SwapchainFramebuffer); _commandList.ClearColorTarget(0, RgbaFloat.Black); _commandList.SetVertexBuffer(0, _vertexBuffer); _commandList.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); _commandList.SetPipeline(_pipeline); _commandList.DrawIndexed( indexCount: 4, instanceCount: 1, indexStart: 0, vertexOffset: 0, instanceStart: 0); _commandList.End(); _graphicsDevice.SubmitCommands(_commandList); _graphicsDevice.SwapBuffers(); }
protected virtual void Render() { _cl.Begin(); _cl.SetFramebuffer(_sc.Framebuffer); Random r = new Random(); _cl.ClearColorTarget(0, _clearColors[(_frameIndex / _frameRepeatCount)]); _cl.ClearDepthStencil(1); // Do your rendering here (or call a subclass, etc.) _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_sc); // Do some math to loop our color picker index. _frameIndex = (_frameIndex + 1) % (_clearColors.Length * _frameRepeatCount); }
private static void Draw() { // Begin() must be called before commands can be issued. _commandList.Begin(); // We want to render directly to the output window. _commandList.SetFramebuffer(_graphicsDevice.SwapchainFramebuffer); _commandList.SetFullViewports(); _commandList.ClearColorTarget(0, RgbaFloat.Black); _commandList.SetPipeline(_pipeline); _commandList.End(); _graphicsDevice.SubmitCommands(_commandList); gui.Draw(); // Once commands have been submitted, the rendered image can be presented to the application window. _graphicsDevice.SwapBuffers(); }
private void HandleRender() { if (!IsDirty) { return; } IsDirty = false; fence.Reset(); commandList.Begin(); commandList.SetFramebuffer(Framebuffer); commandList.ClearColorTarget(0, ClearColor); commandList.ClearDepthStencil(1f); OnRender(commandList); commandList.End(); Device.SubmitCommands(commandList, fence); WindowContainer.AddFenceOnce(fence); }
static void Main(string[] args) { VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 1280, 720, WindowState.Normal, "ImGui.NET"), new GraphicsDeviceOptions(true, null, true), out m_window, out m_device); m_window.Resized += () => { m_device.MainSwapchain.Resize((uint)m_window.Width, (uint)m_window.Height); m_controller.WindowResized(m_window.Width, m_window.Height); }; m_commandList = m_device.ResourceFactory.CreateCommandList(); m_controller = new ImGuiController(m_device, m_device.MainSwapchain.Framebuffer.OutputDescription, m_window.Width, m_window.Height); // Main application loop while (m_window.Exists) { InputSnapshot snapshot = m_window.PumpEvents(); if (!m_window.Exists) { break; } m_controller.Update(1f / 60f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui. SubmitUI(); m_commandList.Begin(); m_commandList.SetFramebuffer(m_device.MainSwapchain.Framebuffer); m_commandList.ClearColorTarget(0, new RgbaFloat(m_clearColor.X, m_clearColor.Y, m_clearColor.Z, 1f)); m_controller.Render(m_device, m_commandList); m_commandList.End(); m_device.SubmitCommands(m_commandList); m_device.SwapBuffers(m_device.MainSwapchain); } // Clean up Veldrid resources m_device.WaitForIdle(); m_controller.Dispose(); m_commandList.Dispose(); m_device.Dispose(); }
protected override void Draw(float deltaSeconds) { ImGuiRenderer.Update(deltaSeconds, this.Host.InputSnapshot); if (ImGui.Begin( "Stats", ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoBackground )) { ImGui.SetWindowSize(new Vector2(200, 100)); ImGui.SetWindowPos(new Vector2(10, 10)); ImGui.TextColored(new Vector4(0, 0, 0, 1), "Vertices: " + this.shapeGeometry.Shape.Vertices.Length); ImGui.TextColored(new Vector4(0, 0, 0, 1), "Indices: " + this.shapeGeometry.Shape.Indices.Length); ImGui.TextColored(new Vector4(0, 0, 0, 1), "Triangles: " + this.shapeGeometry.Shape.Indices.Length / 3); } _ticks += deltaSeconds * 1000f; commandList.Begin(); basicMaterial.Projection = Matrix4x4.CreatePerspectiveFieldOfView(1.0f, HostAspectRatio, 0.5f, 100f); basicMaterial.View = Matrix4x4.CreateLookAt(Vector3.UnitZ * 2.5f, Vector3.Zero, Vector3.UnitY); basicMaterial.World = Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, (_ticks / 1000f)) * Matrix4x4.CreateFromAxisAngle(Vector3.UnitX, (_ticks / 3000f)); commandList.SetFramebuffer(DrawingContext.MainSwapchain.Framebuffer); commandList.ClearColorTarget(0, RgbaFloat.CornflowerBlue); commandList.ClearDepthStencil(1f); basicMaterial.Apply(commandList); shapeGeometry.Draw(commandList); ImGuiRenderer.Render(DrawingContext.GraphicsDevice, commandList); commandList.End(); DrawingContext.GraphicsDevice.SubmitCommands(commandList); DrawingContext.GraphicsDevice.SwapBuffers(DrawingContext.MainSwapchain); DrawingContext.GraphicsDevice.WaitForIdle(); }
/// <summary> /// Start the game. /// </summary> public void Run() { InitializeUi(); while (view.Exists) { if (!view.Exists) { break; } frameTimer.Reset(); frameTimer.Start(); imGui.Update((float)frameTimer.Elapsed.TotalSeconds, view.Width, view.Height); ImGui.DockSpaceOverViewport(); cl.Begin(); // Compute UI elements, render canvases uihost.Render(cl); //ImGui.ShowDemoWindow(); hotkeys.Update(true); if (hotkeys.CurrentHotkey == GlobalHotkey.Undo) { projectConnect.Undo(); } if (hotkeys.CurrentHotkey == GlobalHotkey.Redo) { projectConnect.Redo(); } Console.WriteLine(hotkeys.CurrentHotkey); //ImGui.Text(ImGui.GetIO().Framerate.ToString()); imGui.UpdateViewIO(view); cl.SetFramebuffer(gd.MainSwapchain.Framebuffer); cl.ClearColorTarget(0, new RgbaFloat(clearColor.X, clearColor.Y, clearColor.Z, 1f)); imGui.Render(gd, cl); cl.End(); gd.SubmitCommands(cl); gd.SwapBuffers(gd.MainSwapchain); imGui.SwapExtraWindows(gd); } }
protected override void Draw(float deltaSeconds) { var prj = _camera.ProjectionMatrix; var view = _camera.ViewMatrix; //生成一个不变的矩阵 //Matrix4x4 rotation = // Matrix4x4.Identity; //生成一个变换矩阵 var prjTemp = prj * view; Matrix4x4 rotation = Matrix4x4.CreateFromAxisAngle(-Vector3.UnitY, 0); //开始更新命令 _cl.Begin(); //更新变换矩阵 Vector3 cameraEyeSquared = _camera.Position * _camera.Position; _uboBase.CameraEye = _camera.Position; _uboBase.CameraEyeSquared = cameraEyeSquared; _uboBase.CameraLightPosition = _camera.Position; _uboBase.ProjectionViewModel = prjTemp; _uboBase.UseAverageDepth = _useAverageDepth; //更新数据 _cl.UpdateBuffer(_uboBuffer, 0, ref _uboBase); _cl.SetFramebuffer(MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, RgbaFloat.Black); _cl.ClearDepthStencil(1f); _cl.SetPipeline(_pipeline); _cl.SetVertexBuffer(0, _vertexBuffer); _cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); _cl.SetGraphicsResourceSet(0, _projViewSet); _cl.SetGraphicsResourceSet(1, _textureSet); _cl.DrawIndexed((uint)_mesh.Indices.Length, 1, 0, 0, 0); _controller.Render(GraphicsDevice, _cl); _cl.End(); GraphicsDevice.SubmitCommands(_cl); GraphicsDevice.SwapBuffers(MainSwapchain); GraphicsDevice.WaitForIdle(); }
public void Draw() { commandList.Begin(); commandList.SetFramebuffer(graphicsDevice.SwapchainFramebuffer); commandList.ClearColorTarget(0, RgbaFloat.Black); commandList.SetVertexBuffer(0, vertexBuffer); commandList.SetIndexBuffer(indexBuffer, IndexFormat.UInt16); commandList.SetPipeline(pipeline); commandList.DrawIndexed( indexCount: (uint)indeces.Length, instanceCount: 1, indexStart: 0, vertexOffset: 0, instanceStart: 0); commandList.End(); graphicsDevice.SubmitCommands(commandList); graphicsDevice.SwapBuffers(); }
public static CommandList BuildTest(GraphicsDevice graphicsDevice, Framebuffer framebuffer, RgbaFloat color) { CommandList _commandList = graphicsDevice.ResourceFactory.CreateCommandList(); if (_commandList == null) { return(null); } _commandList.Begin(); _commandList.SetFramebuffer(framebuffer); _commandList.ClearColorTarget(0, color); _commandList.End(); return(_commandList); }
public void Draw() { _cl.Begin(); //投影矩阵 var prj = _camera.ProjectionMatrix; var view = _camera.ViewMatrix; //这里矩阵的定义和后者是有区别的,numberic中是行列,glsl中是列行,因此这里需要反向计算 // < pre > // *m[offset + 0] m[offset + 4] m[offset + 8] m[offset + 12] //* m[offset + 1] m[offset + 5] m[offset + 9] m[offset + 13] //* m[offset + 2] m[offset + 6] m[offset + 10] m[offset + 14] //* m[offset + 3] m[offset + 7] m[offset + 11] m[offset + 15] </ pre > //glsl是列主序,C#是行主序,虽然有所差异,但是并不需要装置,glsl中的第一行实际上就是传入矩阵的第一列,此列刚好能参与计算并返回正常值。 //设置视点位置为2,2,2 ,target 为在0.2,0.2,0 var eyePosition = _camera.Position; _ubo.prj = view * prj; _ubo.CameraEye = eyePosition; _ubo.CameraEyeSquared = eyePosition * eyePosition; _ubo.CameraLightPosition = eyePosition; _cl.UpdateBuffer(_projectionBuffer, 0, _ubo); _cl.SetFramebuffer(GraphicsDevice.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, RgbaFloat.Black); _cl.ClearDepthStencil(1f); _cl.SetPipeline(_pipeline); _cl.SetVertexBuffer(0, _vertexBuffer); _cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); _cl.SetGraphicsResourceSet(0, _projViewSet); _cl.SetGraphicsResourceSet(1, _worldTextureSet); _cl.DrawIndexed((uint)_indices.Length, 1, 0, 0, 0); //_controller.Render(GraphicsDevice, _cl); _cl.End(); GraphicsDevice.SubmitCommands(_cl); GraphicsDevice.SwapBuffers(GraphicsDevice.MainSwapchain); GraphicsDevice.WaitForIdle(); }
private static void Draw() { // Begin() must be called before commands can be issued. _commandList.Begin(); // We want to render directly to the output window. _commandList.SetFramebuffer(_graphicsDevice.SwapchainFramebuffer); _commandList.ClearColorTarget(0, RgbaFloat.Clear); _commandList.SetViewport(0, new Viewport(10, 10, 1900, 1900, 0, 1)); _textRenderer.Render(_commandList, _textWindow); _textRenderer.Render(_commandList, '_', _textLayout.CursorLeft, _textLayout.CursorTop); // End() must be called before commands can be submitted for execution. _commandList.End(); _graphicsDevice.SubmitCommands(_commandList); // Once commands have been submitted, the rendered image can be presented to the application window. _graphicsDevice.SwapBuffers(); }
public void Render(CommandList cl, IColourEffectsStageModel stage, GpuSurface surface, GpuSurface source) { if (cl == null || stage == null || source == null || surface == null) { _frameworkMessenger.Report("Warning: you are feeding the Colour Effect Stage Renderer null inputs, aborting"); return; } cl.SetPipeline(_pipeline); cl.SetFramebuffer(surface.Framebuffer); _viewportManager.ConfigureViewportForActiveFramebuffer(cl); if (stage.ClearBackgroundBeforeRender) { cl.ClearColorTarget(0, stage.ClearColour); } cl.SetVertexBuffer(0, _ndcQuadVertexBuffer.Buffer); cl.SetGraphicsResourceSet(0, stage.FactorsResourceSet); cl.SetGraphicsResourceSet(1, source.ResourceSet_TexWrap); cl.Draw(6); }
private void DrawFrame() { _cl.Begin(); _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, _clearColor); _snake.Render(_spriteRenderer); _world.Render(_spriteRenderer); _spriteRenderer.Draw(_gd, _cl); Texture targetTex = _textRenderer.TextureView.Target; Vector2 textPos = new Vector2( (_window.Width / 2f) - targetTex.Width / 2f, _window.Height - targetTex.Height - 10f); _spriteRenderer.RenderText(_gd, _cl, _textRenderer.TextureView, textPos); _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_gd.MainSwapchain); }
public void Run() { InputSnapshot snapshot = _window.PumpEvents(); if (!_window.Exists) { return; } _controller.Update(1f / 60f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui. SubmitUI(); _cl.Begin(); _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, new RgbaFloat(_clearColor.X, _clearColor.Y, _clearColor.Z, 1f)); _controller.Render(_gd, _cl); _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_gd.MainSwapchain); }
public void Draw(float x, float y) { // Begin() must be called before commands can be issued. CommandList.Begin(); // We want to render directly to the output window. CommandList.SetFramebuffer(GraphicsDevice.SwapchainFramebuffer); CommandList.UpdateBuffer(ProjectionBuffer, 0, Matrix4x4.CreateOrthographicOffCenter( 0, GraphicsDevice.SwapchainFramebuffer.Width, GraphicsDevice.SwapchainFramebuffer.Height, 0, -1, 1 )); // CommandList.UpdateBuffer(WorldBuffer, 0, Matrix4x4.CreateTranslation(Vector3.Zero)); CommandList.SetPipeline(Pipeline); CommandList.SetGraphicsResourceSet(0, ResourceSet); CommandList.UpdateBuffer(WorldBuffer, 0, Matrix4x4.CreateTranslation(new Vector3(x, y, 0))); CommandList.ClearColorTarget(0, RgbaFloat.Black); // Set all relevant state to draw our quad. CommandList.SetVertexBuffer(0, VertexBuffer); CommandList.SetIndexBuffer(IndexBuffer, IndexFormat.UInt16); // Issue a Draw command for a single instance with 4 indices. CommandList.DrawIndexed( indexCount: 5, instanceCount: 1, indexStart: 0, vertexOffset: 0, instanceStart: 0); // End() must be called before commands can be submitted for execution. CommandList.End(); GraphicsDevice.SubmitCommands(CommandList); // Once commands have been submitted, the rendered image can be presented to the application window. GraphicsDevice.SwapBuffers(); }
void OnDraw(float deltaSeconds) { m_cl.Begin(); m_cl.UpdateBuffer(_projectionBuffer, 0, _camera.ProjectionMatrix); m_cl.UpdateBuffer(_viewBuffer, 0, _camera.ViewMatrix); m_cl.SetFramebuffer(Swapchain.Framebuffer); m_cl.ClearColorTarget(0, RgbaFloat.Black); m_cl.ClearDepthStencil(1f); foreach (var chunk in Chunks.Values) { chunk.Draw(m_cl, _projViewSet); } m_cl.End(); GraphicsDevice.SubmitCommands(m_cl); GraphicsDevice.SwapBuffers(Swapchain); GraphicsDevice.WaitForIdle(); }
public void Render(float elapsedTotalSeconds) { _uniformValues.iTime += elapsedTotalSeconds; _uniformValues.iTimeDelta = elapsedTotalSeconds; _uniformValues.iSampleRate = 44100; _cl.Begin(); _cl.UpdateBuffer(_uniforms, 0, ref _uniformValues); _cl.SetFramebuffer(_device.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, RgbaFloat.Black); _cl.ClearDepthStencil(1f); _cl.SetPipeline(_pipeline); _cl.SetGraphicsResourceSet(0, _resourceSet); _cl.Draw(4); _cl.End(); _device.SubmitCommands(_cl); _device.SwapBuffers(_device.MainSwapchain); _device.WaitForIdle(); }
public void Render(CommandList cl, Vector2 texelShiftSize, int numberSamplesPerSideNotIncludingCentre, GpuSurface source, GpuSurface target) { var num = numberSamplesPerSideNotIncludingCentre + 1; if (num != _currentNumSamplesIncludingCentre) { _currentNumSamplesIncludingCentre = num; UpdateWeightsAndOffsetsBuffer(cl); } UpdateGaussianUniformBuffer(cl, texelShiftSize); cl.SetFramebuffer(target.Framebuffer); cl.ClearColorTarget(0, RgbaFloat.Clear); cl.SetVertexBuffer(0, _ndcQuadVertexBuffer.Buffer); cl.SetPipeline(_pipeline); cl.SetGraphicsResourceSet(0, source.ResourceSet_TexMirror); cl.SetGraphicsResourceSet(1, _gaussianFactorsUniformBlockResourceSet); cl.SetGraphicsResourceSet(2, _weightsAndOffsetsResourceSet); cl.Draw(6); }
private static void Draw() { if (_isResized) { _isResized = false; _graphicsDevice.ResizeMainWindow((uint)_window.Width, (uint)_window.Height); ViewProjectionUpdate(); } _commandList.Begin(); _graphicsDevice.UpdateBuffer(_modelMatrixBuffer, 0, Matrix4x4.Identity); _commandList.SetFramebuffer(_graphicsDevice.MainSwapchain.Framebuffer); _commandList.ClearColorTarget(0, new RgbaFloat(239 / 255.0f, 211 / 255.0f, 169 / 255.0f, 1.0f)); _commandList.ClearDepthStencil(1f); _commandList.SetPipeline(_pipeline); _commandList.SetGraphicsResourceSet(0, _mainResourceSet); _commandList.SetVertexBuffer(0, _vertexBuffer); _commandList.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); _commandList.SetVertexBuffer(1, _instanceVB); _commandList.DrawIndexed(IrregularPentagon.IndicesCount, _instanceCount, 0, 0, 0); //_commandList.SetGraphicsResourceSet(0, _mainResourceSet); //_commandList.DrawIndexed(IrregularPentagon.IndicesCount, _instanceCount, 0, 0, 0); //_commandList.DrawIndexed(IrregularPentagon.IndicesCount, 1, 0, 0, 1); _commandList.End(); _graphicsDevice.SubmitCommands(_commandList); _graphicsDevice.WaitForIdle(); _graphicsDevice.SwapBuffers(); }